On Fri, Feb 4, 2011 at 2:11 PM, Hyrum K Wright <hyrum_at_hyrumwright.org> wrote:
> On Fri, Feb 4, 2011 at 7:03 PM, Blair Zajac <blair_at_orcaware.com> wrote:
>>
>> On Feb 4, 2011, at 9:15 AM, Hyrum K Wright wrote:
>>
>>> We currently mark tests XFail (or Skip, or something else) by wrapping
>>> them in the test_list in the test suite. Â Rather than doing it there,
>>> I think it makes more sense to use Python's decorator syntax to mark
>>> tests as XFail right at their definition, rather than down in the test
>>> list. Â Keeping all attributes of a test in close proximity is a Good
>>> Thing, imo. Â Attached is a patch which demonstrates this.
>>>
>>> Decorators were added to Python in 2.4, which is the minimal version
>>> required for our test suite. Â In addition to the functional
>>> decorators, we should be able to add ones which record other
>>> information, such as the issues which the tests were added for. Â (In
>>> some future world, we could also divide up the test suite into
>>> "levels", and decorators could be added to indicate that.)
>>>
>>> Thoughts?
>>
>> Sounds good to me.
>>
>> The decorators could have a required issue version number as a parameter, thereby forcing an issue to exist in the issue tracker.
>
> I don't think we should require all tests to have an issue number
> associated with them,
Not *every* issue, I agree, but perhaps requiring *XFails* to have an
associated issue wouldn't be such a bad idea (once we have issues
associated with all the current XFails of course). It would certainly
make the "What XFailing tests are release blockers?" question a lot
easier to answer.
Paul
> but having this information programatically is a Good Thing.
> I've updated the patch to introduce an "issues"
> decorator, and resolve conflicts introduced by Paul's recent commit.
>
> [I plan on cleaning up references and the like before committing.]
>
> -Hyrum
>
> [[[
>
> Index: subversion/tests/cmdline/svntest/testcase.py
> ===================================================================
> --- subversion/tests/cmdline/svntest/testcase.py     (revision 1067239)
> +++ subversion/tests/cmdline/svntest/testcase.py     (working copy)
> @@ -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):
> @@ -207,6 +214,27 @@ class XFail(TestCase):
> Â Â return self._delegate.list_mode() or 'XFAIL'
>
>
> +def xfail_deco(func):
> + Â if isinstance(func, TestCase):
> + Â Â return XFail(func, issues=func.issues)
> + Â else:
> + Â Â return XFail(func)
> +
> +
> +def issue_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
> +
> +
> Â class Wimp(XFail):
> Â """Like XFail, but indicates a work-in-progress: an unexpected pass
> Â is not considered a test failure."""
> @@ -259,8 +287,8 @@ 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)
> Index: subversion/tests/cmdline/basic_tests.py
> ===================================================================
> --- subversion/tests/cmdline/basic_tests.py   (revision 1067239)
> +++ subversion/tests/cmdline/basic_tests.py   (working copy)
> @@ -1961,6 +1961,8 @@ def basic_rm_urls_one_repo(sbox):
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â expected_status)
>
> Â # Test for issue #1199
> +@svntest.testcase.xfail_deco
> +@svntest.testcase.issue_deco(1199)
> Â def basic_rm_urls_multi_repos(sbox):
> Â "remotely remove directories from two repositories"
>
> @@ -2721,7 +2723,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,
> ]]]
>
Received on 2011-02-04 20:21:06 CET