On 26 Jan 2021, Daniel Shahaf wrote:
>+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.
Well, things turn out to be a bit more complicated than I thought.
My original patch was just to replace
svneditor_script = os.path.join(sys.path[0], 'svneditor.py')
with
svneditor_script = sys.executable + " " + \
os.path.join(sys.path[0], 'svneditor.py')
in subversion/tests/cmdline/svntest/main.py. Unfortunately, exactly one
test still fails with that:
FAIL: update_tests.py 38: update --accept automatic conflict resolution
See [1] for details.
So then I tried a slightly fancier and experimental change. I'll
present it in straight-code form here, instead of patch, but it's just
replacing the same line as before:
# Create a shell script that invokes the Python executable (the
# one that the test suite is using) on svneditor.py and its args.
svneditor_script = os.path.join(sys.path[0], 'svneditor.sh')
with open(svneditor_script, 'w') as fp:
fp.write("#!/bin/sh\n\n")
fp.write("'%s' '%s' $@\n" % (sys.executable,
os.path.join(sys.path[0], 'svneditor.py')))
svneditor_script_st = os.stat(svneditor_script)
os.chmod(svneditor_script, svneditor_script_st.st_mode | stat.S_IEXEC)
Pretty straightforward, right? I know, I know: it doesn't clean up the
shell script afterwards or anything yet. I'm just experimenting.
To my surprise, this still fails on the same update test, but in a
different way! [2] gives the details. I haven't figured out yet why
it's getting that "usage" error. I mean, it should be straightforward
replacement of the original Python script with a shell script that
invokes the Python script, and just passes along all the rest of the
arguments. I expected it to work.
I guess my next step is to install the dang 'python-is-python3' package
on my Debian box and see if the test passes then without any changes?
Anyway, I'm posting this now in case you or anyone spots the problem,
and/or comes up with a better solution.
Responding to James McCoy:
>Thanks for the patch! I have a hacky patch to just force the #! line to
>a Python version in the Debian packaging currently. I had meant to
>follow up about this, and propose a patch similar to yours, but ran into
>other unrelated issues at the time and the forgot about it.
Well, looks like we're not quite there yet, but getting closer maybe.
Best regards,
-Karl
[1] Failure with the first attempted patch:
W: The external merge tool '"/usr/bin/python2"
/home/kfogel/src/subversion/subversion/tests/cmdline/svneditor.py' exited with
exit code 255.
W: svn: warning: apr_err=SVN_ERR_EXTERNAL_PROGRAM
W: svn: warning: W200012: The external merge tool '"/usr/bin/python2"
/home/kfogel/src/subversion/subversion/tests/cmdline/svneditor.py' exited with
exit code 255.
W: subversion/svn/update-cmd.c:188,
W: subversion/svn/resolve-cmd.c:157:
(apr_err=SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE)
W: svn: E155027: Failure occurred resolving one or more conflicts
W: CWD: /home/kfogel/src/subversion/subversion/tests/cmdline
W: EXCEPTION: Failure: Command failed:
"/home/kfogel/src/subversion/subversion/svn/svn update --accept=launch
--force-interactive ..."; exit code 1
Traceback (most recent call last):
File
"/home/kfogel/src/subversion/subversion/tests/cmdline/svntest/main.py", line
1930, in run
rc = self.pred.run(sandbox)
File
"/home/kfogel/src/subversion/subversion/tests/cmdline/svntest/testcase.py",
line 178, in run
result = self.func(sandbox)
File
"/home/kfogel/src/subversion/subversion/tests/cmdline/update_tests.py", line
3774, in update_accept_conflicts
rho_path_backup)
File
"/home/kfogel/src/subversion/subversion/tests/cmdline/svntest/actions.py", line
340, in run_and_verify_svn
expected_exit, *varargs)
File
"/home/kfogel/src/subversion/subversion/tests/cmdline/svntest/actions.py", line
378, in run_and_verify_svn2
exit_code, out, err = main.run_svn(want_err, *varargs)
File
"/home/kfogel/src/subversion/subversion/tests/cmdline/svntest/main.py", line
821, in run_svn
*(_with_auth(_with_config_dir(varargs))))
File
"/home/kfogel/src/subversion/subversion/tests/cmdline/svntest/main.py", line
448, in run_command
None, *varargs)
File
"/home/kfogel/src/subversion/subversion/tests/cmdline/svntest/main.py", line
669, in run_command_stdin
'"; exit code ' + str(exit_code))
Failure: Command failed: "/home/kfogel/src/subversion/subversion/svn/svn
update --accept=launch --force-interactive ..."; exit code 1
FAIL: update_tests.py 38: update --accept automatic conflict resolution
[2] Failure with the 2nd attempted patch:
W: Unexpected output
W: EXPECTED STDOUT (match_all=True):
W: | Updating 'svn-test-work/working_copies/update_tests-38.backup/A/D/G/p;
i':
W: | C svn-test-work/working_copies/update_tests-38.backup/A/D/G/p; i
W: | Updated to revision 3.
W: | Merge conflicts in
'svn-test-work/working_copies/update_tests-38.backup/A/D/G/p; i' marked as
resolved.
W: | Summary of conflicts:
W: | Text conflicts: 0 remaining (and 1 already resolved)
W: ACTUAL STDOUT:
W: | Updating 'svn-test-work/working_copies/update_tests-38.backup/A/D/G/p;
i':
W: | C svn-test-work/working_copies/update_tests-38.backup/A/D/G/p; i
W: | Updated to revision 3.
W: | usage: svneditor.py file
W: | svneditor.py base theirs mine merged wc_path
W: | arguments passed were:
['/home/kfogel/src/subversion/subversion/tests/cmdline/svneditor.py', 'p;', 'i']
W: | Merge conflicts in
'svn-test-work/working_copies/update_tests-38.backup/A/D/G/p; i' marked as
resolved.
W: | Summary of conflicts:
W: | Text conflicts: 0 remaining (and 1 already resolved)
W: DIFF STDOUT (match_all=True):
W: | --- EXPECTED STDOUT (match_all=True)
W: | +++ ACTUAL STDOUT
W: | @@ -1,6 +1,9 @@
W: | Updating
'svn-test-work/working_copies/update_tests-38.backup/A/D/G/p; i':
W: | C svn-test-work/working_copies/update_tests-38.backup/A/D/G/p; i
W: | Updated to revision 3.
W: | +usage: svneditor.py file
W: | + svneditor.py base theirs mine merged wc_path
W: | +arguments passed were:
['/home/kfogel/src/subversion/subversion/tests/cmdline/svneditor.py', 'p;', 'i']
W: | Merge conflicts in
'svn-test-work/working_copies/update_tests-38.backup/A/D/G/p; i' marked as
resolved.
W: | Summary of conflicts:
W: | Text conflicts: 0 remaining (and 1 already resolved)
W: CWD: /home/kfogel/src/subversion/subversion/tests/cmdline
W: EXCEPTION: SVNLineUnequal
Traceback (most recent call last):
File
"/home/kfogel/src/subversion/subversion/tests/cmdline/svntest/main.py", line
1935, in run
rc = self.pred.run(sandbox)
File
"/home/kfogel/src/subversion/subversion/tests/cmdline/svntest/testcase.py",
line 178, in run
result = self.func(sandbox)
File
"/home/kfogel/src/subversion/subversion/tests/cmdline/update_tests.py", line
3765, in update_accept_conflicts
p_i_path_backup)
File
"/home/kfogel/src/subversion/subversion/tests/cmdline/svntest/actions.py", line
380, in run_and_verify_svn2
expected_stdout, expected_stderr)
File
"/home/kfogel/src/subversion/subversion/tests/cmdline/svntest/verify.py", line
531, in verify_outputs
compare_and_display_lines(message, label, expected, actual, raisable)
File
"/home/kfogel/src/subversion/subversion/tests/cmdline/svntest/verify.py", line
504, in compare_and_display_lines
raise raisable
SVNLineUnequal
FAIL: update_tests.py 38: update --accept automatic conflict resolution