You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Daniel Rall <dl...@collab.net> on 2007/06/11 15:46:02 UTC
Re: svn commit: r25357 - in trunk/subversion/tests/cmdline: . svntest
On Mon, 11 Jun 2007, kameshj@tigris.org wrote:
> Author: kameshj
> Date: Mon Jun 11 05:05:31 2007
> New Revision: 25357
>
> Log:
> Skip condition is made as a lamda function.
This should be written in a more active voice:
"svntest: Allow Skip condition to be a lambda function."
> * subversion/tests/cmdline/svntest/testcase.py
> (Skip.__init__): Signature change cond -> cond_func a lamda function callable
> at test runtime. Call this lambda function, if it returns True set
> list_mode_text to 'SKIP'.
> (Skip.need_sandbox): Call cond_func.
> (Skip.run): Call cond_func.
>
> * subversion/tests/cmdline/svntest/main.py
> (is_non_posix_os): New function.
I'd rather see this API written using non-negative logic (case in
point, that phrasing was more difficult to understand that needed to
be):
is_posix_os()
...
> --- trunk/subversion/tests/cmdline/prop_tests.py (original)
> +++ trunk/subversion/tests/cmdline/prop_tests.py Mon Jun 11 05:05:31 2007
> @@ -28,6 +28,8 @@
> XFail = svntest.testcase.XFail
> Item = svntest.wc.StateItem
>
> +def is_non_posix_and_non_windows_os():
A doc string stating that this is used as a lambda function in
test_list might be useful here.
> + return svntest.main.is_non_posix_os() and sys.platform != 'win32'
>
> # Helper functions
> def check_prop(name, path, exp_out):
> @@ -1366,8 +1368,7 @@
> copy_inherits_special_props,
> # If we learn how to write a pre-revprop-change hook for
> # non-Posix platforms, we won't have to skip here:
> - Skip(revprop_change, (os.name != 'posix'
> - and sys.platform != 'win32')),
> + Skip(revprop_change, is_non_posix_and_non_windows_os),
> prop_value_conversions,
> binary_props,
> recursive_base_wc_ops,
...
Re: svn commit: r25357 - in trunk/subversion/tests/cmdline: . svntest
Posted by Daniel Rall <dl...@collab.net>.
On Tue, 12 Jun 2007, Kamesh Jayachandran wrote:
> Hi Dan,
>
> >This should be written in a more active voice:
> >
> >"svntest: Allow Skip condition to be a lambda function."
> >
> >
> Fixed.
> >I'd rather see this API written using non-negative logic (case in
> >point, that phrasing was more difficult to understand that needed to
> >be):
> >
> > is_posix_os()
...
> I originally thought on the same lines. But I could not pass a negating
> expression as a lambda function.
Yup. I was thinking it could be passed as a boolean instead of a
lambda function.
Re: svn commit: r25357 - in trunk/subversion/tests/cmdline: . svntest
Posted by Daniel Rall <dl...@collab.net>.
On Thu, 14 Jun 2007, Kamesh Jayachandran wrote:
...
> I had a similar patch, i.e instead of SkipUnless, making Skip to accept
> expected val from the conditional.
I don't think having this functionality would hurt. I thought we
actually support this in other spots.
Re: svn commit: r25357 - in trunk/subversion/tests/cmdline: . svntest
Posted by Kamesh Jayachandran <ka...@collab.net>.
Dan,
Looks fine with me.
I had a similar patch, i.e instead of SkipUnless, making Skip to accept
expected val from the conditional.
With regards
Kamesh Jayachandran
Daniel Rall wrote:
> On Tue, 12 Jun 2007, David Glasser wrote:
>
>
>> On 6/12/07, Kamesh Jayachandran <ka...@collab.net> wrote:
>>
>>> I originally thought on the same lines. But I could not pass a negating
>>> expression as a lambda function.
>>>
>> SkipUnless?
>>
>
> Ah, good suggestion. How about this patch (attached), which adds and
> uses the new predicate?
>
> ------------------------------------------------------------------------
>
> Index: subversion/tests/cmdline/import_tests.py
> ===================================================================
> --- subversion/tests/cmdline/import_tests.py (revision 25383)
> +++ subversion/tests/cmdline/import_tests.py (working copy)
> @@ -25,6 +25,7 @@
>
> # (abbreviation)
> Skip = svntest.testcase.Skip
> +SkipUnless = svntest.testcase.SkipUnless
> XFail = svntest.testcase.XFail
> Item = wc.StateItem
>
> @@ -369,7 +370,7 @@
>
> # list all tests here, starting with None:
> test_list = [ None,
> - Skip(import_executable, svntest.main.is_non_posix_os),
> + SkipUnless(import_executable, svntest.main.is_posix_os),
> import_ignores,
> import_avoid_empty_revision,
> import_no_ignores,
> Index: subversion/tests/cmdline/lock_tests.py
> ===================================================================
> --- subversion/tests/cmdline/lock_tests.py (revision 25383)
> +++ subversion/tests/cmdline/lock_tests.py (working copy)
> @@ -27,6 +27,7 @@
>
> # (abbreviation)
> Skip = svntest.testcase.Skip
> +SkipUnless = svntest.testcase.SkipUnless
> XFail = svntest.testcase.XFail
> Item = svntest.wc.StateItem
>
> @@ -1552,8 +1553,8 @@
> lock_several_files,
> lock_switched_files,
> lock_uri_encoded,
> - Skip(lock_and_exebit1, svntest.main.is_non_posix_os),
> - Skip(lock_and_exebit2, svntest.main.is_non_posix_os),
> + SkipUnless(lock_and_exebit1, svntest.main.is_posix_os),
> + SkipUnless(lock_and_exebit2, svntest.main.is_posix_os),
> commit_xml_unsafe_file_unlock,
> repos_lock_with_info,
> unlock_already_unlocked_files,
> Index: subversion/tests/cmdline/copy_tests.py
> ===================================================================
> --- subversion/tests/cmdline/copy_tests.py (revision 25383)
> +++ subversion/tests/cmdline/copy_tests.py (working copy)
> @@ -27,6 +27,7 @@
>
> # (abbreviation)
> Skip = svntest.testcase.Skip
> +SkipUnless = svntest.testcase.SkipUnless
> XFail = svntest.testcase.XFail
> Item = svntest.wc.StateItem
>
> @@ -3689,7 +3690,8 @@
> copy_files_with_properties,
> copy_delete_commit,
> mv_and_revert_directory,
> - Skip(copy_preserve_executable_bit, svntest.main.is_non_posix_os),
> + SkipUnless(copy_preserve_executable_bit,
> + svntest.main.is_posix_os),
> wc_to_repos,
> repos_to_wc,
> copy_to_root,
> Index: subversion/tests/cmdline/stat_tests.py
> ===================================================================
> --- subversion/tests/cmdline/stat_tests.py (revision 25383)
> +++ subversion/tests/cmdline/stat_tests.py (working copy)
> @@ -26,6 +26,7 @@
>
> # (abbreviation)
> Skip = svntest.testcase.Skip
> +SkipUnless = svntest.testcase.SkipUnless
> XFail = svntest.testcase.XFail
> Item = svntest.wc.StateItem
>
> @@ -1498,7 +1499,8 @@
> status_shows_all_in_current_dir,
> status_missing_file,
> status_type_change,
> - Skip(status_type_change_to_symlink, svntest.main.is_non_posix_os),
> + SkipUnless(status_type_change_to_symlink,
> + svntest.main.is_posix_os),
> status_with_new_files_pending,
> status_for_unignored_file,
> status_for_nonexistent_file,
> Index: subversion/tests/cmdline/special_tests.py
> ===================================================================
> --- subversion/tests/cmdline/special_tests.py (revision 25383)
> +++ subversion/tests/cmdline/special_tests.py (working copy)
> @@ -25,6 +25,7 @@
>
> # (abbreviation)
> Skip = svntest.testcase.Skip
> +SkipUnless = svntest.testcase.SkipUnless
> XFail = svntest.testcase.XFail
> Item = svntest.wc.StateItem
>
> @@ -605,19 +606,19 @@
>
> # list all tests here, starting with None:
> test_list = [ None,
> - Skip(general_symlink, svntest.main.is_non_posix_os),
> - Skip(replace_file_with_symlink, svntest.main.is_non_posix_os),
> - Skip(import_export_symlink, svntest.main.is_non_posix_os),
> - Skip(copy_tree_with_symlink, svntest.main.is_non_posix_os),
> - Skip(replace_symlink_with_file, svntest.main.is_non_posix_os),
> - Skip(remove_symlink, svntest.main.is_non_posix_os),
> - Skip(merge_symlink_into_file, svntest.main.is_non_posix_os),
> - Skip(merge_file_into_symlink, svntest.main.is_non_posix_os),
> + SkipUnless(general_symlink, svntest.main.is_posix_os),
> + SkipUnless(replace_file_with_symlink, svntest.main.is_posix_os),
> + SkipUnless(import_export_symlink, svntest.main.is_posix_os),
> + SkipUnless(copy_tree_with_symlink, svntest.main.is_posix_os),
> + SkipUnless(replace_symlink_with_file, svntest.main.is_posix_os),
> + SkipUnless(remove_symlink, svntest.main.is_posix_os),
> + SkipUnless(merge_symlink_into_file, svntest.main.is_posix_os),
> + SkipUnless(merge_file_into_symlink, svntest.main.is_posix_os),
> checkout_repo_with_symlinks,
> - XFail(Skip(diff_symlink_to_dir, svntest.main.is_non_posix_os)),
> + XFail(SkipUnless(diff_symlink_to_dir, svntest.main.is_posix_os)),
> checkout_repo_with_unknown_special_type,
> replace_symlink_with_dir,
> - Skip(update_obstructing_symlink, svntest.main.is_non_posix_os),
> + SkipUnless(update_obstructing_symlink, svntest.main.is_posix_os),
> ]
>
> if __name__ == '__main__':
> Index: subversion/tests/cmdline/prop_tests.py
> ===================================================================
> --- subversion/tests/cmdline/prop_tests.py (revision 25383)
> +++ subversion/tests/cmdline/prop_tests.py (working copy)
> @@ -25,12 +25,13 @@
>
> # (abbreviation)
> Skip = svntest.testcase.Skip
> +SkipUnless = svntest.testcase.SkipUnless
> XFail = svntest.testcase.XFail
> Item = svntest.wc.StateItem
>
> def is_non_posix_and_non_windows_os():
> """lambda function to skip revprop_change test"""
> - return svntest.main.is_non_posix_os() and sys.platform != 'win32'
> + return (not svntest.main.is_posix_os()) and sys.platform != 'win32'
>
> # Helper functions
> def check_prop(name, path, exp_out):
> Index: subversion/tests/cmdline/commit_tests.py
> ===================================================================
> --- subversion/tests/cmdline/commit_tests.py (revision 25383)
> +++ subversion/tests/cmdline/commit_tests.py (working copy)
> @@ -25,6 +25,7 @@
>
> # (abbreviation)
> Skip = svntest.testcase.Skip
> +SkipUnless = svntest.testcase.SkipUnless
> XFail = svntest.testcase.XFail
> Item = svntest.wc.StateItem
>
> @@ -34,7 +35,7 @@
> #
>
> def is_non_posix_os_or_cygwin_platform():
> - return svntest.main.is_non_posix_os() or sys.platform == 'cygwin'
> + return (not svntest.main.is_posix_os()) or sys.platform == 'cygwin'
>
> def get_standard_state(wc_dir):
> """Return a status list reflecting the local mods made by
> Index: subversion/tests/cmdline/authz_tests.py
> ===================================================================
> --- subversion/tests/cmdline/authz_tests.py (revision 25383)
> +++ subversion/tests/cmdline/authz_tests.py (working copy)
> @@ -30,6 +30,7 @@
> Item = svntest.wc.StateItem
> XFail = svntest.testcase.XFail
> Skip = svntest.testcase.Skip
> +SkipUnless = svntest.testcase.SkipUnless
>
> ######################################################################
> # Tests
> @@ -815,9 +816,6 @@
> def authz_svnserve_anon_access_read(sbox):
> "authz issue #2712"
>
> - if not svntest.main.is_ra_type_svn():
> - raise svntest.Skip
> -
> sbox.build(create_wc = False)
> svntest.main.safe_rmtree(sbox.wc_dir)
> B_path = os.path.join(sbox.wc_dir, 'A', 'B')
> @@ -862,7 +860,8 @@
> authz_aliases,
> authz_validate,
> authz_locking,
> - authz_svnserve_anon_access_read,
> + SkipUnless(authz_svnserve_anon_access_read,
> + svntest.main.is_ra_type_svn),
> ]
>
> if __name__ == '__main__':
> Index: subversion/tests/cmdline/schedule_tests.py
> ===================================================================
> --- subversion/tests/cmdline/schedule_tests.py (revision 25383)
> +++ subversion/tests/cmdline/schedule_tests.py (working copy)
> @@ -26,6 +26,7 @@
>
> # (abbreviation)
> Skip = svntest.testcase.Skip
> +SkipUnless = svntest.testcase.SkipUnless
> XFail = svntest.testcase.XFail
> Item = svntest.wc.StateItem
>
> @@ -624,7 +625,7 @@
> revert_add_files,
> revert_add_directories,
> revert_nested_adds,
> - Skip(revert_add_executable, svntest.main.is_non_posix_os),
> + SkipUnless(revert_add_executable, svntest.main.is_posix_os),
> revert_delete_files,
> revert_delete_dirs,
> unschedule_missing_added,
> Index: subversion/tests/cmdline/svntest/testcase.py
> ===================================================================
> --- subversion/tests/cmdline/svntest/testcase.py (revision 25385)
> +++ subversion/tests/cmdline/svntest/testcase.py (working copy)
> @@ -157,7 +157,7 @@
>
>
> class Skip(TestCase):
> - """A test that will be skipped if condition COND is true."""
> + """A test that will be skipped if its conditional is true."""
>
> def __init__(self, test_case, cond_func=lambda:1):
> """Create an Skip instance based on TEST_CASE. COND_FUNC is a
> @@ -173,7 +173,7 @@
> self.test_case = create_test_case(test_case)
> self.cond_func = cond_func
> try:
> - if self.cond_func():
> + if self.conditional():
> self._list_mode_text = 'SKIP'
> except svntest.Failure:
> pass
> @@ -183,20 +183,36 @@
> self.convert_result = self.test_case.convert_result
>
> def need_sandbox(self):
> - if self.cond_func():
> + if self.conditional():
> return 0
> else:
> return self.test_case.need_sandbox()
>
> def run(self, sandbox=None):
> - if self.cond_func():
> + if self.conditional():
> raise svntest.Skip
> elif self.need_sandbox():
> return self.test_case.run(sandbox=sandbox)
> else:
> return self.test_case.run()
>
> + def conditional(self):
> + """Invoke SELF.cond_func(), and return the result evaluated
> + against the expected value."""
> + return self.cond_func()
>
> +
> +class SkipUnless(Skip):
> + """A test that will be skipped if its conditional is false."""
> +
> + def __init__(self, test_case, cond_func):
> + Skip.__init__(self, test_case, cond_func)
> +
> + def conditional(self):
> + "Return the negation of SELF.cond_func()."
> + return not self.cond_func()
> +
> +
> def create_test_case(func):
> if isinstance(func, TestCase):
> return func
> Index: subversion/tests/cmdline/svntest/main.py
> ===================================================================
> --- subversion/tests/cmdline/svntest/main.py (revision 25383)
> +++ subversion/tests/cmdline/svntest/main.py (working copy)
> @@ -667,8 +667,8 @@
> def is_os_windows():
> return (os.name == 'nt')
>
> -def is_non_posix_os():
> - return (os.name != 'posix')
> +def is_posix_os():
> + return (os.name == 'posix')
>
> ######################################################################
> # Sandbox handling
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: r25357 - in trunk/subversion/tests/cmdline: . svntest
Posted by David Glasser <gl...@mit.edu>.
On 6/14/07, Daniel Rall <dl...@collab.net> wrote:
> On Wed, 13 Jun 2007, David Glasser wrote:
> > Looks good to me (though maybe the predicates in prop_tests and
> > commit_tests want to move into svntest.main too?).
>
> I committed the patch in r25406.
>
> I thought of moving the other predicates, but wonder at the value if
> they're only used in that one source file (ATM). Do you think it's
> worth moving them into the test framework itself doing so to avoid the
> chance of redundant implementations springing up at a later date?
I think we first moved predicates into svntest.main after somebody
noticed me adding redundant implementations, so yeah, why not.
--dave
--
David Glasser | glasser@mit.edu | http://www.davidglasser.net/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: r25357 - in trunk/subversion/tests/cmdline: . svntest
Posted by Daniel Rall <dl...@collab.net>.
On Wed, 13 Jun 2007, David Glasser wrote:
> On 6/13/07, Daniel Rall <dl...@collab.net> wrote:
> >On Tue, 12 Jun 2007, David Glasser wrote:
> >
> >> On 6/12/07, Kamesh Jayachandran <ka...@collab.net> wrote:
> >> >I originally thought on the same lines. But I could not pass a negating
> >> >expression as a lambda function.
> >>
> >> SkipUnless?
> >
> >Ah, good suggestion. How about this patch (attached), which adds and
> >uses the new predicate?
>
> Looks good to me (though maybe the predicates in prop_tests and
> commit_tests want to move into svntest.main too?).
I committed the patch in r25406.
I thought of moving the other predicates, but wonder at the value if
they're only used in that one source file (ATM). Do you think it's
worth moving them into the test framework itself doing so to avoid the
chance of redundant implementations springing up at a later date?
Re: svn commit: r25357 - in trunk/subversion/tests/cmdline: . svntest
Posted by David Glasser <gl...@mit.edu>.
On 6/13/07, Daniel Rall <dl...@collab.net> wrote:
> On Tue, 12 Jun 2007, David Glasser wrote:
>
> > On 6/12/07, Kamesh Jayachandran <ka...@collab.net> wrote:
> > >I originally thought on the same lines. But I could not pass a negating
> > >expression as a lambda function.
> >
> > SkipUnless?
>
> Ah, good suggestion. How about this patch (attached), which adds and
> uses the new predicate?
Looks good to me (though maybe the predicates in prop_tests and
commit_tests want to move into svntest.main too?).
--dave
--
David Glasser | glasser@mit.edu | http://www.davidglasser.net/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: r25357 - in trunk/subversion/tests/cmdline: . svntest
Posted by Daniel Rall <dl...@collab.net>.
On Tue, 12 Jun 2007, David Glasser wrote:
> On 6/12/07, Kamesh Jayachandran <ka...@collab.net> wrote:
> >I originally thought on the same lines. But I could not pass a negating
> >expression as a lambda function.
>
> SkipUnless?
Ah, good suggestion. How about this patch (attached), which adds and
uses the new predicate?
Re: svn commit: r25357 - in trunk/subversion/tests/cmdline: . svntest
Posted by David Glasser <gl...@mit.edu>.
On 6/12/07, Kamesh Jayachandran <ka...@collab.net> wrote:
> I originally thought on the same lines. But I could not pass a negating
> expression as a lambda function.
SkipUnless?
--dave
--
David Glasser | glasser@mit.edu | http://www.davidglasser.net/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: r25357 - in trunk/subversion/tests/cmdline: . svntest
Posted by Kamesh Jayachandran <ka...@collab.net>.
Hi Dan,
> This should be written in a more active voice:
>
> "svntest: Allow Skip condition to be a lambda function."
>
>
Fixed.
> I'd rather see this API written using non-negative logic (case in
> point, that phrasing was more difficult to understand that needed to
> be):
>
> is_posix_os()
>
> ...
>
I originally thought on the same lines. But I could not pass a negating
expression as a lambda function.
>> --- trunk/subversion/tests/cmdline/prop_tests.py (original)
>> +++ trunk/subversion/tests/cmdline/prop_tests.py Mon Jun 11 05:05:31 2007
>> @@ -28,6 +28,8 @@
>> XFail = svntest.testcase.XFail
>> Item = svntest.wc.StateItem
>>
>> +def is_non_posix_and_non_windows_os():
>>
>
> A doc string stating that this is used as a lambda function in
> test_list might be useful here.
>
>
Fixed in r25372.
Thanks for the review.
With regards
Kamesh Jayachandran
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org