Author: julianfoad
Date: Wed Dec 23 14:33:46 2009
New Revision: 893527
URL: http://svn.apache.org/viewvc?rev=893527&view=rev
Log:
In the test suite, move the hook_failure_message() function into actions.py
so that it can be shared by all tests that use hooks.
* subversion/tests/cmdline/commit_tests.py
(hook_failure_message): Move to actions.py.
(post_commit_hook_test, start_commit_hook_test, pre_commit_hook_test):
Adjust calls to it accordingly.
* subversion/tests/cmdline/svntest/actions.py
(hook_failure_message): Move from commit_tests.py.
Modified:
subversion/trunk/subversion/tests/cmdline/commit_tests.py
subversion/trunk/subversion/tests/cmdline/svntest/actions.py
Modified: subversion/trunk/subversion/tests/cmdline/commit_tests.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/commit_tests.py?rev=893527&r1=893526&r2=893527&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/commit_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/commit_tests.py Wed Dec 23
14:33:46 2009
@@ -2062,28 +2062,6 @@
os.path.join(wc_dir, 'A', 'mu'),
os.path.join(wc_dir, 'A', 'yu'))
-# Helper for hook tests: returns the "hook failed" line, with precise
-# wording that changed with Subversion 1.5.
-def hook_failure_message(hookname):
- if svntest.main.server_minor_version < 5:
- return "'%s' hook failed with error output:\n" % hookname
- else:
- if hookname in ["start-commit", "pre-commit"]:
- action = "Commit"
- elif hookname == "pre-revprop-change":
- action = "Revprop change"
- elif hookname == "pre-lock":
- action = "Lock"
- elif hookname == "pre-unlock":
- action = "Unlock"
- else:
- action = None
- if action is None:
- message = "%s hook failed (exit code 1)" % (hookname,)
- else:
- message = "%s blocked by %s hook (exit code 1)" % (action, hookname)
- return message + " with output:\n"
-
#----------------------------------------------------------------------
# Test if the post-commit error message is returned back to the svn
@@ -2112,7 +2090,8 @@
"Transmitting file data .\n",
"Committed revision 2.\n",
"\n",
- "Warning: " + hook_failure_message('post-commit'),
+ "Warning: " +
+ svntest.actions.hook_failure_message('post-commit'),
"Post-commit hook failed\n",
]
@@ -2488,7 +2467,8 @@
# contain source code file and line numbers.
if len(actual_stderr) > 2:
actual_stderr = actual_stderr[-2:]
- expected_stderr = [ "svn: " + hook_failure_message('start-commit'),
+ expected_stderr = [ "svn: " +
+ svntest.actions.hook_failure_message('start-commit'),
"Start-commit hook failed\n"
]
svntest.verify.compare_and_display_lines('Start-commit hook test',
@@ -2531,7 +2511,8 @@
# contain source code file and line numbers.
if len(actual_stderr) > 2:
actual_stderr = actual_stderr[-2:]
- expected_stderr = [ "svn: " + hook_failure_message('pre-commit'),
+ expected_stderr = [ "svn: " +
+ svntest.actions.hook_failure_message('pre-commit'),
"Pre-commit hook failed\n"
]
svntest.verify.compare_and_display_lines('Pre-commit hook test',
Modified: subversion/trunk/subversion/tests/cmdline/svntest/actions.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/actions.py?rev=893527&r1=893526&r2=893527&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/actions.py Wed Dec 23
14:33:46 2009
@@ -1573,6 +1573,28 @@
"Return the BASE revision of the working copy at WC_DIR."
return run_and_parse_info(wc_dir)[0]['Revision']
+def hook_failure_message(hook_name):
+ """Return the error message that the client prints for failure of the
+ specified hook HOOK_NAME. The wording changed with Subversion 1.5."""
+ if svntest.main.server_minor_version < 5:
+ return "'%s' hook failed with error output:\n" % hook_name
+ else:
+ if hook_name in ["start-commit", "pre-commit"]:
+ action = "Commit"
+ elif hook_name == "pre-revprop-change":
+ action = "Revprop change"
+ elif hook_name == "pre-lock":
+ action = "Lock"
+ elif hook_name == "pre-unlock":
+ action = "Unlock"
+ else:
+ action = None
+ if action is None:
+ message = "%s hook failed (exit code 1)" % (hook_name,)
+ else:
+ message = "%s blocked by %s hook (exit code 1)" % (action, hook_name)
+ return message + " with output:\n"
+
def create_failing_hook(repo_dir, hook_name, text):
"""Create a HOOK_NAME hook in the repository at REPO_DIR that prints
TEXT to stderr and exits with an error."""