Index: subversion/tests/clients/cmdline/commit_tests.py =================================================================== --- subversion/tests/clients/cmdline/commit_tests.py (revision 17264) +++ subversion/tests/clients/cmdline/commit_tests.py (working copy) @@ -1970,13 +1970,17 @@ # Setup the hook configs to echo data back post_commit_hook = svntest.main.get_post_commit_hook_path (repo_dir) - svntest.main.file_append (post_commit_hook, - """#!/bin/sh - echo "Post-commit Hook says nothing doing on stderr" > /dev/stderr - exit -1 - """) - os.chmod (post_commit_hook, 0755) + # create a post-commit hoook + post_commit_hook_code = ( "#!"+ sys.executable +"\n" + "import sys\n" + "\n" + "sys.stderr.write('Post-commit Hook says nothing " + "doing on stderr')\n" + "sys.exit(-1)\n") + svntest.main.create_python_hook_script (post_commit_hook, + post_commit_hook_code) + # Modify iota just so there is something to commit. iota_path = os.path.join (wc_dir, "iota") svntest.main.file_append (iota_path, "lakalakalakalaka") @@ -1989,8 +1993,8 @@ "Committed revision 2.\n", "\n", "Warning:'post-commit' hook failed with error output:\n", - "Post-commit Hook says nothing doing on stderr\n", - "\n"] + "Post-commit Hook says nothing doing on stderr\n" + ] svntest.actions.run_and_verify_svn (None, expected_output, [], 'ci', '-m', 'log msg', iota_path) Index: subversion/tests/clients/cmdline/svntest/main.py =================================================================== --- subversion/tests/clients/cmdline/svntest/main.py (revision 17264) +++ subversion/tests/clients/cmdline/svntest/main.py (working copy) @@ -218,7 +218,6 @@ return os.path.join(repo_dir, "hooks", "post-commit") - # Run any binary, logging the command line (TODO: and return code) def run_command(command, error_expected, binary_mode=0, *varargs): """Run COMMAND with VARARGS; return stdout, stderr as lists of lines. @@ -494,6 +493,35 @@ else: return input + +# create_python_hook_script : Create a hook script with the given +# python code +# Parameters : hook_name - full path of the target +# hook file to be created. +# hook_script_code - python code for +# the hook. +def create_python_hook_script (hook_name, hook_script_code): + if sys.platform == 'win32': + # on windows, create a batch file wrapper to the python script + hook_py = os.path.join (hook_name, ".py") + hook = os.path.join (hook_name, ".bat") + # fill the python file + file_append (hook_py, + "#!"+ sys.executable +"\n") + file_append (hook_py, + hook_script_code) + # fill the batch wrapper file + file_append (hook, + "@echo off\n", + hook_py) + else: # For all other platforms + file_append (hook_name, + "#!"+ sys.executable +"\n") + file_append (hook_name, + hook_script_code) + os.chmod (hook_name, 0755) + + ###################################################################### # Sandbox handling