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))