You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Ramkumar Ramachandra <ar...@gmail.com> on 2010/07/24 13:16:11 UTC
[PATCH] Make display_lines() spawn diff
Hi,
This patch is not intended for inclusion, but I hope it conveys the
idea- I want display_lines() to display a diff instead of the full
actual and expected outputs.
Thanks.
Index: subversion/tests/cmdline/svntest/verify.py
===================================================================
--- subversion/tests/cmdline/svntest/verify.py (revision 978817)
+++ subversion/tests/cmdline/svntest/verify.py (working copy)
@@ -24,7 +24,7 @@
# under the License.
######################################################################
-import re, sys
+import re, sys, tempfile
import svntest
@@ -275,22 +275,16 @@ def display_lines(message, label, expected, actual
Both EXPECTED and ACTUAL may be strings or lists of strings."""
if message is not None:
print(message)
- if expected is not None:
- output = 'EXPECTED %s' % label
- if expected_is_regexp:
- output += ' (regexp)'
- if expected_is_unordered:
- output += ' (unordered)'
- output += ':'
- print(output)
- for x in expected:
- sys.stdout.write(x)
- if expected_is_regexp:
- sys.stdout.write('\n')
- if actual is not None:
- print('ACTUAL %s:' % label)
- for x in actual:
- sys.stdout.write(x)
+ actual_file = tempfile.NamedTemporaryFile(delete=False)
+ expected_file = tempfile.NamedTemporaryFile(delete=False)
+ actual_file.write("".join(actual))
+ expected_file.write("".join(expected))
+ actual_file.close()
+ expected_file.close()
+ exit_code, stdout_output, stderr_output = \
+ svntest.main.run_command("diff", 1, 0, '-a', '-u', \
+ actual_file.name, expected_file.name)
+ print "".join(stdout_output)
def compare_and_display_lines(message, label, expected, actual,
raisable=None):
Re: [PATCH] Make display_lines() spawn diff
Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Stefan Sperling wrote on Sat, Jul 24, 2010 at 15:55:19 +0200:
> On Sat, Jul 24, 2010 at 06:46:11PM +0530, Ramkumar Ramachandra wrote:
> > Hi,
> >
> > This patch is not intended for inclusion, but I hope it conveys the
> > idea- I want display_lines() to display a diff instead of the full
> > actual and expected outputs.
>
> That would be nice indeed, but ...
>
+1
> > + exit_code, stdout_output, stderr_output = \
> > + svntest.main.run_command("diff", 1, 0, '-a', '-u', \
> > + actual_file.name, expected_file.name)
> > + print "".join(stdout_output)
>
> ... this won't work on windows.
>
> We'll need a utility function in our test suite that prints diffs.
>
The test suite could use tools/diff/diff?
> > def compare_and_display_lines(message, label, expected, actual,
> > raisable=None):
Re: [PATCH] Make display_lines() spawn diff
Posted by Ramkumar Ramachandra <ar...@gmail.com>.
Hi Stefan,
Stefan Sperling writes:
> ... this won't work on windows.
>
> We'll need a utility function in our test suite that prints diffs.
Right. How about this?
Index: subversion/tests/cmdline/svntest/verify.py
===================================================================
--- subversion/tests/cmdline/svntest/verify.py (revision 978817)
+++ subversion/tests/cmdline/svntest/verify.py (working copy)
@@ -25,6 +25,7 @@
######################################################################
import re, sys
+from difflib import context_diff
import svntest
@@ -275,22 +276,8 @@ def display_lines(message, label, expected, actual
Both EXPECTED and ACTUAL may be strings or lists of strings."""
if message is not None:
print(message)
- if expected is not None:
- output = 'EXPECTED %s' % label
- if expected_is_regexp:
- output += ' (regexp)'
- if expected_is_unordered:
- output += ' (unordered)'
- output += ':'
- print(output)
- for x in expected:
- sys.stdout.write(x)
- if expected_is_regexp:
- sys.stdout.write('\n')
- if actual is not None:
- print('ACTUAL %s:' % label)
- for x in actual:
- sys.stdout.write(x)
+ for line in context_diff(actual, expected, fromfile="actual", tofile="expected"):
+ print line,
def compare_and_display_lines(message, label, expected, actual,
raisable=None):
Re: [PATCH] Make display_lines() spawn diff
Posted by Stefan Sperling <st...@elego.de>.
On Sat, Jul 24, 2010 at 06:46:11PM +0530, Ramkumar Ramachandra wrote:
> Hi,
>
> This patch is not intended for inclusion, but I hope it conveys the
> idea- I want display_lines() to display a diff instead of the full
> actual and expected outputs.
That would be nice indeed, but ...
> + exit_code, stdout_output, stderr_output = \
> + svntest.main.run_command("diff", 1, 0, '-a', '-u', \
> + actual_file.name, expected_file.name)
> + print "".join(stdout_output)
... this won't work on windows.
We'll need a utility function in our test suite that prints diffs.
> def compare_and_display_lines(message, label, expected, actual,
> raisable=None):