[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1344616 - in /subversion/trunk/subversion/tests/cmdline/svntest: actions.py main.py

From: Johan Corveleyn <jcorvel_at_gmail.com>
Date: Thu, 14 Jun 2012 14:25:15 +0200

On Mon, Jun 4, 2012 at 10:53 PM, Johan Corveleyn <jcorvel_at_gmail.com> wrote:
> On Mon, Jun 4, 2012 at 9:25 PM, Johan Corveleyn <jcorvel_at_gmail.com> wrote:
>> On Thu, May 31, 2012 at 11:28 AM,  <rhuijben_at_apache.org> wrote:
>>> Author: rhuijben
>>> Date: Thu May 31 09:28:13 2012
>>> New Revision: 1344616
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1344616&view=rev
>>> Log:
>>> Avoid firing up both cmd.exe and python.exe in the most common hook scripts
>>> of our test suite on Windows.
>>>
>>> * subversion/tests/cmdline/svntest/actions.py
>>>  (enable_revprop_changes,
>>>   disable_revprop_changes,
>>>   create_failing_post_commit_hook) Provide a cmd alternative hook script.
>>>     Print all arguments from disable_revprop_changes() instead of just a set.
>>>
>>> * subversion/tests/cmdline/svntest/main.py
>>>  (create_python_hook_script): When a cmd alternative is passed write that
>>>    to the .bat file instead of calling a python script.
>>>
>>> Modified:
>>>    subversion/trunk/subversion/tests/cmdline/svntest/actions.py
>>>    subversion/trunk/subversion/tests/cmdline/svntest/main.py
>>>
>>> Modified: subversion/trunk/subversion/tests/cmdline/svntest/actions.py
>>> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/actions.py?rev=1344616&r1=1344615&r2=1344616&view=diff
>>> ==============================================================================
>>> --- subversion/trunk/subversion/tests/cmdline/svntest/actions.py (original)
>>> +++ subversion/trunk/subversion/tests/cmdline/svntest/actions.py Thu May 31 09:28:13 2012
>>> @@ -1868,7 +1868,8 @@ def enable_revprop_changes(repo_dir):
>>>   pre-revprop-change hook script and (if appropriate) making it executable."""
>>>
>>>   hook_path = main.get_pre_revprop_change_hook_path(repo_dir)
>>> -  main.create_python_hook_script(hook_path, 'import sys; sys.exit(0)')
>>> +  main.create_python_hook_script(hook_path, 'import sys; sys.exit(0)',
>>> +                                 cmd_alternative='@exit /b 0')
>>>
>>>  def disable_revprop_changes(repo_dir):
>>>   """Disable revprop changes in the repository at REPO_DIR by creating a
>>> @@ -1878,8 +1879,12 @@ def disable_revprop_changes(repo_dir):
>>>   hook_path = main.get_pre_revprop_change_hook_path(repo_dir)
>>>   main.create_python_hook_script(hook_path,
>>>                                  'import sys\n'
>>> -                                 'sys.stderr.write("pre-revprop-change %s" % " ".join(sys.argv[1:6]))\n'
>>> -                                 'sys.exit(1)\n')
>>> +                                 'sys.stderr.write("pre-revprop-change %s" %'
>>> +                                                  ' " ".join(sys.argv[1:]))\n'
>>> +                                 'sys.exit(1)\n',
>>> +                                 cmd_alternative=
>>> +                                       '@echo pre-revprop-change %* 1>&2\n'
>>> +                                       '@exit /b 1\n')
>>>
>>>  def create_failing_post_commit_hook(repo_dir):
>>>   """Create a post-commit hook script in the repository at REPO_DIR that always
>>> @@ -1888,7 +1893,10 @@ def create_failing_post_commit_hook(repo
>>>   hook_path = main.get_post_commit_hook_path(repo_dir)
>>>   main.create_python_hook_script(hook_path, 'import sys\n'
>>>     'sys.stderr.write("Post-commit hook failed")\n'
>>> -    'sys.exit(1)')
>>> +    'sys.exit(1)\n',
>>> +    cmd_alternative=
>>> +            '@echo Post-commit hook failed 1>&2\n'
>>> +            '@exit /b 1\n')
>>>
>>>  # set_prop can be used for properties with NULL characters which are not
>>>  # handled correctly when passed to subprocess.Popen() and values like "*"
>>>
>>> Modified: subversion/trunk/subversion/tests/cmdline/svntest/main.py
>>> URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/main.py?rev=1344616&r1=1344615&r2=1344616&view=diff
>>> ==============================================================================
>>> --- subversion/trunk/subversion/tests/cmdline/svntest/main.py (original)
>>> +++ subversion/trunk/subversion/tests/cmdline/svntest/main.py Thu May 31 09:28:13 2012
>>> @@ -934,18 +934,23 @@ def canonicalize_url(input):
>>>     return input
>>>
>>>
>>> -def create_python_hook_script(hook_path, hook_script_code):
>>> +def create_python_hook_script(hook_path, hook_script_code,
>>> +                              cmd_alternative=None):
>>>   """Create a Python hook script at HOOK_PATH with the specified
>>>      HOOK_SCRIPT_CODE."""
>>>
>>>   if windows:
>>> -    # Use an absolute path since the working directory is not guaranteed
>>> -    hook_path = os.path.abspath(hook_path)
>>> -    # Fill the python file.
>>> -    file_write("%s.py" % hook_path, hook_script_code)
>>> -    # Fill the batch wrapper file.
>>> -    file_append("%s.bat" % hook_path,
>>> -                "@\"%s\" %s.py %%*\n" % (sys.executable, hook_path))
>>> +    if cmd_alternative is not None:
>>> +      file_write("%s.bat" % hook_path,
>>> +                  cmd_alternative)
>>> +    else:
>>> +      # Use an absolute path since the working directory is not guaranteed
>>> +      hook_path = os.path.abspath(hook_path)
>>> +      # Fill the python file.
>>> +      file_write("%s.py" % hook_path, hook_script_code)
>>> +      # Fill the batch wrapper file.
>>> +      file_write("%s.bat" % hook_path,
>>> +                 "@\"%s\" %s.py %%*\n" % (sys.executable, hook_path))
>>>   else:
>>>     # For all other platforms
>>>     file_write(hook_path, "#!%s\n%s" % (sys.executable, hook_script_code))
>>>
>> This commit makes prop_tests.py 12 fail for me (on Windows XP).
>>
>> I haven't looked at it in detail (busy figuring out other problems).
>> Bert (or anyone), if you spot (and can fix) the problem, that would be
>> most helpful.
>>
>> Output at default log level:
>> [[[
>> W: EXPECTED STDERR (regexp):
>> .*pre-revprop-change.* 0 jrandom cash-sound A
>> W: ACTUAL STDERR:
>> W: CWD: R:\test\subversion\tests\cmdline
>> W: EXCEPTION: SVNUnmatchedError
>> Traceback (most recent call last):
>>  File "C:\research\svn\client_build\trunk2\subversion\tests\cmdline\svntest\main.py",
>> line 1340, in run
>>    rc = self.pred.run(sandbox)
>>  File "C:\research\svn\client_build\trunk2\subversion\tests\cmdline\svntest\testcase.py",
>> line 254, in run
>>    return self._delegate.run(sandbox)
>>  File "C:\research\svn\client_build\trunk2\subversion\tests\cmdline\svntest\testcase.py",
>> line 114, in run
>>    return self._delegate.run(sandbox)
>>  File "C:\research\svn\client_build\trunk2\subversion\tests\cmdline\svntest\testcase.py",
>> line 176, in run
>>    return self.func(sandbox)
>>  File "C:\research\svn\client_build\trunk2\subversion\tests\cmdline\prop_tests.py",
>> line 822, in revprop_change
>>    'cash-sound', 'cha-ching!', sbox.wc_dir)
>>  File "C:\research\svn\client_build\trunk2\subversion\tests\cmdline\svntest\actions.py",
>> line 285, in run_and_verify_svn
>>    expected_exit, *varargs)
>>  File "C:\research\svn\client_build\trunk2\subversion\tests\cmdline\svntest\actions.py",
>> line 324, in run_and_verify_svn2
>>    verify.verify_outputs(message, out, err, expected_stdout, expected_stderr)
>>  File "C:\research\svn\client_build\trunk2\subversion\tests\cmdline\svntest\verify.py",
>> line 396, in verify_outputs
>>    compare_and_display_lines(message, label, expected, actual, raisable)
>>  File "C:\research\svn\client_build\trunk2\subversion\tests\cmdline\svntest\verify.py",
>> line 369, in compare_and_display_lines
>>    raise raisable
>> SVNUnmatchedError
>> FAIL:  prop_tests.py 12: set, get, and delete a revprop change
>> ]]]
>>
>> See fails.log in attachment with output at DEBUG log-level.
>
> I don't get it.
>
> There is a pre-revprop-change.bat with the right content in
> svn-test-work\repositories\prop_tests-12\hooks. If I invoke it
> directly, it gives the correct output and exit code:
>
> [[[
> R:\test\subversion\tests\cmdline\svn-test-work\repositories\prop_tests-12\hooks>pre-revprop-change
> a b c > NUL
> pre-revprop-change a b c
>
> R:\test\subversion\tests\cmdline\svn-test-work\repositories\prop_tests-12\hooks>echo
> %errorlevel%
> 1
> ]]]
>
> But if I execute a revprop change, it doesn't fail:
>
> [[[
> R:\test\subversion\tests\cmdline>svn.exe propset --revprop -r 0
> cash-sound cha-ching! svn-test-work\working_copies\prop_tests-12
> --config-dir R:\test\subversion\tests\cmdline\svn-test-work\local_tmp\config
> --password rayjandom --no-auth-cache --username jrandom
> property 'cash-sound' set on repository revision 0
> ]]]
>
> I'm confused.
>
> --
> Johan

Apparently, Windows XP's cmd.exe works slightly differently than more
recent cmd's, the way it's invoked when running hooks. It seems those
hooks need to exit with "exit X" instead of "exit /b X".

I changed the setting of the cmd_alternative when creating hooks in
the test-suite in r1350208, which fixes this test for me (and
hopefully doesn't break it on other systems).

-- 
Johan
Received on 2012-06-14 14:26:12 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.