You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Gabriela Gibson <ga...@gmail.com> on 2013/05/08 19:08:43 UTC

--invoke-diff-cmd test suite woes

Hi,

All my manual tests for the current --invoke-diff-cmd work fine, but I
cannot get the test suite to work.

I added the following new test (nr 49) to diff_tests.py:

[[[
# Check the order of the arguments for an external diff tool
def diff_invoke_external_diffcmd(sbox):
   "svn diff --diff-invoke-cmd has correct arguments"

   sbox.build(read_only = True)
   os.chdir(sbox.wc_dir)

   iota_path = 'iota'
   svntest.main.file_append(iota_path, "new text in iota")

   expected_output = svntest.verify.ExpectedOutput([
       "Index: iota\n",
 
"===================================================================\n",
       "--- l1\n",
       "+++ l2\n",
       "@@ -1 +1,2 @@\n",
       "This is the file 'iota'.\n",
       "+new text in iota\n",
       "\ No newline at end of file\n",
       # os.path.abspath(svntest.wc.text_base_path("iota")) + "\n",
       #os.path.abspath("iota") + "\n
       ])

   # Check that the output of diff corresponds with the expected arguments,
   # in the correct order.
   svntest.actions.run_and_verify_svn(None, expected_output, [],
                                      'diff', '--invoke-diff-cmd="diff 
-u --label l1 %f1% --label l2 %f2%', "",
                                      iota_path)
]]]

************************************************************************

If I now run this test, svn diff correctly expands the command (as
expected, see the line starting with "W: svn: E200012:"), but svn
crashes (the test fails too, but that is I think a separate problem)


g@musashi:~/trunk_ziff/subversion/tests/cmdline$  ./diff_tests.py 49
W: subversion/svn/diff-cmd.c:412,
W: subversion/libsvn_client/diff.c:2130,
W: subversion/libsvn_client/diff.c:1654,
W: subversion/libsvn_wc/diff_local.c:500,
W: subversion/libsvn_wc/status.c:2758,
W: subversion/libsvn_wc/status.c:1460,
W: subversion/libsvn_wc/status.c:1212,
W: subversion/libsvn_wc/status.c:931,
W: subversion/libsvn_wc/diff_local.c:364,
W: subversion/libsvn_wc/diff_editor.c:568,
W: subversion/libsvn_diff/diff_tree.c:1208,
W: subversion/libsvn_wc/diff_editor.c:2708,
W: subversion/libsvn_client/diff.c:975,
W: subversion/libsvn_client/diff.c:839,
W: subversion/libsvn_subr/io.c:3040: (apr_err=SVN_ERR_EXTERNAL_PROGRAM)
W: svn: E200012: '"diff -u --label l1 %f1% --label l2 %f2%' was expanded 
to "diff -u --label l1 
/home/g/trunk_ziff/subversion/tests/cmdline/svn-test-work/working_copies/diff_tests-49/.svn/pristine/2c/2c0aa9014a0cd07f01795a333d82485ef6d083e2.svn-base 
--label l2 
/home/g/trunk_ziff/subversion/tests/cmdline/svn-test-work/working_copies/diff_tests-49/iota 
  and returned 255
W: CWD: 
/home/g/trunk_ziff/subversion/tests/cmdline/svn-test-work/working_copies/diff_tests-49
W: EXCEPTION: Failure: Command failed: 
"/home/g/trunk_ziff/subversion/svn/svn diff --invoke-diff-cmd="diff -u 
--label l1 %f1% --label l2 %f2%  ..."; exit code 1
Traceback (most recent call last):
   File "/home/g/trunk_ziff/subversion/tests/cmdline/svntest/main.py", 
line 1550, in run
     rc = self.pred.run(sandbox)
   File 
"/home/g/trunk_ziff/subversion/tests/cmdline/svntest/testcase.py", line 
176, in run
     return self.func(sandbox)
   File "./diff_tests.py", line 3304, in diff_invoke_external_diffcmd
     iota_path)
   File 
"/home/g/trunk_ziff/subversion/tests/cmdline/svntest/actions.py", line 
282, in run_and_verify_svn
     expected_exit, *varargs)
   File 
"/home/g/trunk_ziff/subversion/tests/cmdline/svntest/actions.py", line 
320, in run_and_verify_svn2
     exit_code, out, err = main.run_svn(want_err, *varargs)
   File "/home/g/trunk_ziff/subversion/tests/cmdline/svntest/main.py", 
line 682, in run_svn
     *(_with_auth(_with_config_dir(varargs))))
   File "/home/g/trunk_ziff/subversion/tests/cmdline/svntest/main.py", 
line 365, in run_command
     None, *varargs)
   File "/home/g/trunk_ziff/subversion/tests/cmdline/svntest/main.py", 
line 557, in run_command_stdin
     '"; exit code ' + str(exit_code))
Failure: Command failed: "/home/g/trunk_ziff/subversion/svn/svn diff 
--invoke-diff-cmd="diff -u --label l1 %f1% --label l2 %f2%  ..."; exit 
code 1
FAIL:  diff_tests.py 49: svn diff --diff-invoke-cmd has correct arguments
g@musashi:~/trunk_ziff/subversion/tests/cmdline$

************************************************************************

Running the rejected output without svn works:

g@musashi:~/trunk_ziff/subversion/tests/cmdline$ diff -u --label l1 
/home/g/trunk_ziff/subversion/tests/cmdline/svn-test-work/working_copies/diff_tests-49/.svn/pristine/2c/2c0aa9014a0cd07f01795a333d82485ef6d083e2.svn-base 
--label l2 
/home/g/trunk_ziff/subversion/tests/cmdline/svn-test-work/working_copies/diff_tests-49/iota
--- l1
+++ l2
@@ -1 +1,2 @@
  This is the file 'iota'.
+new text in iota
\ No newline at end of file
g@musashi:~/trunk_ziff/subversion/tests/cmdline$
************************************************************************
So does running svn with the rejected output without the test suite:

g@musashi:~/trunk_ziff/subversion/tests/cmdline$ 
/home/g/trunk_ziff/subversion/svn/svn diff --invoke-diff-cmd="diff -u 
--label l1 %f1% --label l2 %f2%"
Index: diff_tests.py
===================================================================
--- l1
+++ l2
@@ -3274,6 +3274,34 @@

... normal diff ensues ...


************************************************************************
So does changing into the directory I think it's normally operating in 
and using the rejected output:

g@musashi:~/trunk_ziff/subversion/tests/cmdline$ cd 
svn-test-work/working_copies/diff_tests-49/

g@musashi:~/trunk_ziff/subversion/tests/cmdline/svn-test-work/working_copies/diff_tests-49$ 
/home/g/trunk_ziff/subversion/svn/svn diff --invoke-diff-cmd="diff -u 
--label l1 %f1% --label l2 %f2%"
Index: iota
===================================================================
--- l1
+++ l2
@@ -1 +1,2 @@
  This is the file 'iota'.
+new text in iota
\ No newline at end of file
g@musashi:~/trunk_ziff/subversion/tests/cmdline/svn-test-work/working_copies/diff_tests-49$ 



************************************************************************

many thanks for any hints you might have for me,

Gabriela

Re: --invoke-diff-cmd test suite woes

Posted by Stefan Sperling <st...@elego.de>.
On Wed, May 08, 2013 at 09:10:49PM +0300, Daniel Shahaf wrote:
> You could use tools/diff/diff.

Or 'svn diff --old some-file --new some-other-file' :)

Re: --invoke-diff-cmd test suite woes

Posted by Daniel Shahaf <da...@elego.de>.
Ben Reser wrote on Wed, May 08, 2013 at 10:53:48 -0700:
> On Wed, May 8, 2013 at 10:08 AM, Gabriela Gibson
> <ga...@gmail.com> wrote:
> > All my manual tests for the current --invoke-diff-cmd work fine, but I
> > cannot get the test suite to work.
> 
> 1) You're not providing a path for the diff command are you sure that
> it's on the PATH in the environment that svn is running the command
> with?
> 
> 2) You probably don't want to write your test using the system
> provided diff command.  There are platforms such as Windows that
> provide no diff command by default.  Even if the platform provides a
> diff command the output may not match your expected output.

You could use tools/diff/diff.  (As a bonus, I think that binary is
currently untested, so the test will test both the external-diff
functionality and the tools/ utility.)

Re: --invoke-diff-cmd test suite woes

Posted by Ben Reser <be...@reser.org>.
On Wed, May 8, 2013 at 10:08 AM, Gabriela Gibson
<ga...@gmail.com> wrote:
> All my manual tests for the current --invoke-diff-cmd work fine, but I
> cannot get the test suite to work.

1) You're not providing a path for the diff command are you sure that
it's on the PATH in the environment that svn is running the command
with?

2) You probably don't want to write your test using the system
provided diff command.  There are platforms such as Windows that
provide no diff command by default.  Even if the platform provides a
diff command the output may not match your expected output.

You probably want to write out a python script of some sort to act as
your diff command.  The python script doesn't even have to actually
produce a diff, it just needs to verify that the command is run with
the expected arguments and that SVN passes the output back through to
the user.  So in this case I'd make a tiny python script that just
prints out the command line arguments and the test suite can look for
that output.