> From: Karl Fogel
> Subject: [PATCH] Fix tests failing on Debian due to lack of 'python' command.
Yay! *gestures* Here's your old chair, right where you left it; I think you'll
find the only difference from when you last occupied it is that your DHCP lease
may have expired ;-)
> But in practice [all the Python-based test files are] actually invoked using
> whatever Python is specified by the environment variable SVN_TEST_PYTHON,
> which is set to Python's 'sys.executable' as part of running the tests.
AFAICT:
1. SVN_TEST_PYTHON is only used by the svneditor.bat, not by anything else in
the test suite.
2. When «make check» invokes foo_tests.py, it doesn't _execute_ it but
_imports_ it, so the #! line doesn't even come into play at all. (See
build/run_tests.py)
> The problem is that SVN_TEST_PYTHON is not used for the invocation of
> svneditor.py -- instead, svneditor.py is just run directly, as per this code
> in subversion/tests/cmdline/svntest/main.py:
>
> # The location of our mock svneditor script.
> if windows:
> svneditor_script = os.path.join(sys.path[0], 'svneditor.bat')
> else:
> svneditor_script = os.path.join(sys.path[0], 'svneditor.py')
>
The test suite should never run its own auxiliary Python scripts with
«/usr/bin/env python»; rather, it should use sys.executable. There's precedent
for this throughout the test suite.
> So, one solution would be to just commit this change...
>
> Index: subversion/tests/cmdline/svntest/main.py
> ===================================================================
> --- subversion/tests/cmdline/svntest/main.py (revision 1885910)
> +++ subversion/tests/cmdline/svntest/main.py (working copy)
> @@ -129,7 +129,8 @@
> if windows:
> svneditor_script = os.path.join(sys.path[0], 'svneditor.bat')
> else:
> - svneditor_script = os.path.join(sys.path[0], 'svneditor.py')
> + svneditor_script = sys.executable + " " + \
> + os.path.join(sys.path[0], 'svneditor.py')
>
> # Username and password used by the working copies
> wc_author = 'jrandom'
>
> ...which, somewhat to my surprise, seems to work :-), at least with
> preliminary testing. I'd run it through the full test suite before
> committing, of course.
>
> Another solution would be to create a 'svneditor.sh' that just runs
> '${SVN_TEST_PYTHON} /path/to/svneditor.py $@'.
Compare create_python_hook_script() — which, incidentally, isn't careful about
using proper shell quoting where needed (or ensuring the value is safe to use
unquoted).
> I'm posting to get others' thoughts on how best to solve this. If the above
> patch looks good, let me know and I'll test & commit it.
+1 to using sys.executable. Fixing the quoting while in there would be nice to
have, but as it's not a regression it's not a blocker either. Happy to leave
the details to you.
> (This is all yak-shaving on the way to a somewhat more interesting, albeit
> minor, patch that I'll post once we get this resolved.)
:-)
Cheers,
Daniel