You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2011/02/04 21:16:10 UTC
svn commit: r1067273 - in /subversion/trunk/subversion/tests/cmdline:
basic_tests.py svntest/testcase.py
Author: hwright
Date: Fri Feb 4 20:16:09 2011
New Revision: 1067273
URL: http://svn.apache.org/viewvc?rev=1067273&view=rev
Log:
Introduce a new method of documenting XFail, Skip, and SkipUnless tests, along
with issues associated with tests (even PASSing ones). Use this new technique
in basic_tests.py (with a plan to implement it across the python test suite).
* subversion/tests/cmdline/svntest/testcase.py
(TestCase.set_issues): New.
(FunctionTestCase): Accept an optional issues parameter.
(create_test_case): Same.
(XFail_deco, Skip_deco, SkipUnless_deco, Issues_deco, Issue_deco): New.
* subversion/tests/cmdline/basic_tests.py:
Change abbreviations to point to the decorators, and decorate test cases
with their various attributes. Remove wrapping from test_list.
Modified:
subversion/trunk/subversion/tests/cmdline/basic_tests.py
subversion/trunk/subversion/tests/cmdline/svntest/testcase.py
Modified: subversion/trunk/subversion/tests/cmdline/basic_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/basic_tests.py?rev=1067273&r1=1067272&r2=1067273&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/basic_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/basic_tests.py Fri Feb 4 20:16:09 2011
@@ -32,9 +32,11 @@ import svntest
from svntest import wc
# (abbreviation)
-Skip = svntest.testcase.Skip
-SkipUnless = svntest.testcase.SkipUnless
-XFail = svntest.testcase.XFail
+Skip = svntest.testcase.Skip_deco
+SkipUnless = svntest.testcase.SkipUnless_deco
+XFail = svntest.testcase.XFail_deco
+Issues = svntest.testcase.Issues_deco
+Issue = svntest.testcase.Issue_deco
Wimp = svntest.testcase.Wimp
Item = wc.StateItem
@@ -1209,7 +1211,7 @@ def basic_checkout_deleted(sbox):
# Issue 846, changing a deleted file to an added directory was not
# supported before WC-NG. But we can handle it.
-
+@Issue(846)
def basic_node_kind_change(sbox):
"attempt to change node kind"
@@ -1428,6 +1430,7 @@ def nonexistent_repository(sbox):
#----------------------------------------------------------------------
# Issue 1064. This test is only useful if running over a non-local RA
# with authentication enabled, otherwise it will pass trivially.
+@Issue(1064)
def basic_auth_cache(sbox):
"basic auth caching"
@@ -1493,6 +1496,7 @@ def basic_add_ignores(sbox):
#----------------------------------------------------------------------
+@Issue(2243)
def basic_add_local_ignores(sbox):
'ignore files matching local ignores in added dirs'
@@ -1768,6 +1772,7 @@ def info_nonhead(sbox):
#----------------------------------------------------------------------
# Issue #2442.
+@Issue(2442)
def ls_nonhead(sbox):
"ls a path no longer in HEAD"
@@ -1798,6 +1803,7 @@ def ls_nonhead(sbox):
#----------------------------------------------------------------------
# Issue #2315.
+@Issue(2315)
def cat_added_PREV(sbox):
"cat added file using -rPREV"
@@ -1816,6 +1822,7 @@ def cat_added_PREV(sbox):
'cat', '-rPREV', f_path)
# Issue #2612.
+@Issue(2612)
def ls_space_in_repo_name(sbox):
'basic ls of repos with space in name'
@@ -1961,6 +1968,8 @@ def basic_rm_urls_one_repo(sbox):
expected_status)
# Test for issue #1199
+@XFail
+@Issue(1199)
def basic_rm_urls_multi_repos(sbox):
"remotely remove directories from two repositories"
@@ -2420,6 +2429,7 @@ def basic_relative_url_with_peg_revision
# Issue 2242, auth cache picking up password from wrong username entry
+@Issue(2242)
def basic_auth_test(sbox):
"basic auth test"
@@ -2480,6 +2490,7 @@ def basic_add_svn_format_file(sbox):
# Issue 2586, Unhelpful error message: Unrecognized URL scheme for ''
# See also input_validation_tests.py:invalid_mkdir_targets(), which tests
# the same thing the other way around.
+@Issue(2586)
def basic_mkdir_mix_targets(sbox):
"mkdir mix url and local path should error"
@@ -2510,6 +2521,7 @@ def delete_from_url_with_spaces(sbox):
'rm', sbox.repo_url + '/Dir%20With/Spaces',
'-m', 'Deleted')
+@SkipUnless(svntest.main.is_ra_type_dav)
def meta_correct_library_being_used(sbox):
"verify that neon/serf are compiled if tested"
expected_re = (r'^\* ra_%s :' % svntest.main.options.http_library)
@@ -2721,7 +2733,7 @@ test_list = [ None,
delete_keep_local_twice,
windows_paths_in_repos,
basic_rm_urls_one_repo,
- XFail(basic_rm_urls_multi_repos, issues=1199),
+ basic_rm_urls_multi_repos,
automatic_conflict_resolution,
info_nonexisting_file,
basic_relative_url_using_current_dir,
@@ -2733,8 +2745,7 @@ test_list = [ None,
basic_add_svn_format_file,
basic_mkdir_mix_targets,
delete_from_url_with_spaces,
- SkipUnless(meta_correct_library_being_used,
- svntest.main.is_ra_type_dav),
+ meta_correct_library_being_used,
delete_and_add_same_file,
delete_child_parent_update,
basic_relocate,
Modified: subversion/trunk/subversion/tests/cmdline/svntest/testcase.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/testcase.py?rev=1067273&r1=1067272&r2=1067273&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/testcase.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/testcase.py Fri Feb 4 20:16:09 2011
@@ -108,6 +108,13 @@ class TestCase:
"""
return self._delegate.get_sandbox_name()
+ def set_issues(self, issues):
+ """Set the issues associated with this test."""
+ if type(issues) == type(0):
+ self.issues = [issues]
+ else:
+ self.issues = issues
+
def run(self, sandbox):
"""Run the test within the given sandbox."""
return self._delegate.run(sandbox)
@@ -134,7 +141,7 @@ class FunctionTestCase(TestCase):
is derived from the file name in which FUNC was defined)
"""
- def __init__(self, func):
+ def __init__(self, func, issues=None):
# it better be a function that accepts an sbox parameter and has a
# docstring on it.
assert isinstance(func, types.FunctionType)
@@ -158,7 +165,7 @@ class FunctionTestCase(TestCase):
assert doc[0].lower() == doc[0], \
"%s's docstring should not be capitalized" % name
- TestCase.__init__(self, doc=doc)
+ TestCase.__init__(self, doc=doc, issues=issues)
self.func = func
def get_function_name(self):
@@ -259,8 +266,47 @@ class SkipUnless(Skip):
Skip.__init__(self, test_case, lambda c=cond_func: not c())
-def create_test_case(func):
+def create_test_case(func, issues=None):
if isinstance(func, TestCase):
return func
else:
- return FunctionTestCase(func)
+ return FunctionTestCase(func, issues=issues)
+
+
+# Various decorators to make declaring tests as such simpler
+def XFail_deco(func):
+ if isinstance(func, TestCase):
+ return XFail(func, issues=func.issues)
+ else:
+ return XFail(func)
+
+
+def Skip_deco(cond_func):
+ def _second(func):
+ return Skip(func, cond_func)
+
+ return _second
+
+
+def SkipUnless_deco(cond_func):
+ def _second(func):
+ return Skip(func, lambda c=cond_func: not c())
+
+ return _second
+
+
+def Issues_deco(issues):
+ def _second(func):
+ if isinstance(func, TestCase):
+ # if the wrapped thing is already a test case, just set the issues
+ func.set_issues(issues)
+ return func
+
+ else:
+ # we need to wrap the function
+ return create_test_case(func, issues=issues)
+
+ return _second
+
+# Create a singular alias, for linguistic correctness
+Issue_deco = Issues_deco