changeset 11040:8f951ed6c63c

run-tests: add --view switch to use external diff viewer
author Matt Mackall <mpm@selenic.com>
date Thu, 29 Apr 2010 22:04:05 -0500
parents cf0a309f6c4d
children 623fe42a649e
files tests/run-tests.py
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Thu Apr 29 18:25:45 2010 -0500
+++ b/tests/run-tests.py	Thu Apr 29 22:04:05 2010 -0500
@@ -132,6 +132,8 @@
              " (implies --keep-tmpdir)")
     parser.add_option("-v", "--verbose", action="store_true",
         help="output verbose messages")
+    parser.add_option("--view", type="string",
+        help="external diff viewer")
     parser.add_option("--with-hg", type="string",
         metavar="HG",
         help="test using specified hg script rather than a "
@@ -573,6 +575,7 @@
     mark = '.'
 
     skipped = (ret == SKIPPED_STATUS)
+
     # If we're not in --debug mode and reference output file exists,
     # check test output against it.
     if options.debug:
@@ -584,6 +587,13 @@
     else:
         refout = []
 
+    if (ret != 0 or out != refout) and not skipped and not options.debug:
+        # Save errors to a file for diagnosis
+        f = open(err, "wb")
+        for line in out:
+            f.write(line)
+        f.close()
+
     if skipped:
         mark = 's'
         if out is None:                 # debug mode: nothing to parse
@@ -605,7 +615,10 @@
         else:
             fail("output changed")
         if not options.nodiff:
-            showdiff(refout, out, ref, err)
+            if options.view:
+                os.system("%s %s %s" % (options.view, ref, err))
+            else:
+                showdiff(refout, out, ref, err)
         ret = 1
     elif ret:
         mark = '!'
@@ -615,13 +628,6 @@
         sys.stdout.write(mark)
         sys.stdout.flush()
 
-    if ret != 0 and not skipped and not options.debug:
-        # Save errors to a file for diagnosis
-        f = open(err, "wb")
-        for line in out:
-            f.write(line)
-        f.close()
-
     killdaemons()
 
     os.chdir(TESTDIR)