[PATCH v3] run-tests: automatically add (glob) to "saved backup bundle to" lines

Mads Kiilerich mads at kiilerich.com
Tue Jan 6 03:56:12 UTC 2015


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1417050270 -3600
#      Thu Nov 27 02:04:30 2014 +0100
# Node ID 6fba071b2da5cafb59408b71953affcda988c399
# Parent  d944492445fa0d0b9c164336afab68127080a1f3
run-tests: automatically add (glob) to "saved backup bundle to" lines

Avoid spending too much time adding (glob) after running run-tests -i. This
doesn't handle all cases but it helps.

The run-tests tests add a bit of escaping of trailing (glob) in the output to
avoid interference from the outer test runner.

The regexp for matching the output lines contains a group for making multiline
substitute in a way that works with Python before 2.7.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -627,6 +627,7 @@ class Test(unittest.TestCase):
             (r':%s\b' % self._startport, ':$HGPORT'),
             (r':%s\b' % (self._startport + 1), ':$HGPORT1'),
             (r':%s\b' % (self._startport + 2), ':$HGPORT2'),
+            (r'(?m)^(saved backup bundle to .*\.hg)( \(glob\))?$', r'\1 (glob)'),
             ]
 
         if os.name == 'nt':
@@ -1025,6 +1026,9 @@ class TTest(Test):
             if el.endswith(" (re)\n"):
                 return TTest.rematch(el[:-6], l)
             if el.endswith(" (glob)\n"):
+                # ignore '(glob)' added to l by 'replacements'
+                if l.endswith(" (glob)\n"):
+                    l = l[:-8] + "\n"
                 return TTest.globmatch(el[:-8], l)
             if os.altsep and l.replace('\\', '/') == el:
                 return '+glob'
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -297,24 +297,43 @@ View the fix
 
 Accept the fix
 
-  $ echo 'y' | $TESTDIR/run-tests.py --with-hg=`which hg` -i
+  $ echo "  $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
+  $ echo "  saved backup bundle to \$TESTTMP/foo.hg" >> test-failure.t
+  $ echo "  $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
+  $ echo "  saved backup bundle to \$TESTTMP/foo.hg (glob)" >> test-failure.t
+  $ echo "  $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
+  $ echo "  saved backup bundle to \$TESTTMP/*.hg (glob)" >> test-failure.t
+  $ echo 'y' | $TESTDIR/run-tests.py --with-hg=`which hg` -i 2>&1 | \
+  >   sed -e 's,(glob)$,&<,g'
   
   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/test-failure.t.err
-  @@ -1,4 +1,4 @@
+  @@ -1,9 +1,9 @@
      $ echo babar
   -  rataxes
   +  babar
    This is a noop statement so that
    this test is still more bytes than success.
+     $ echo 'saved backup bundle to $TESTTMP/foo.hg'
+  -  saved backup bundle to $TESTTMP/foo.hg
+  +  saved backup bundle to $TESTTMP/foo.hg (glob)<
+     $ echo 'saved backup bundle to $TESTTMP/foo.hg'
+     saved backup bundle to $TESTTMP/foo.hg (glob)<
+     $ echo 'saved backup bundle to $TESTTMP/foo.hg'
   Accept this change? [n] ..
   # Ran 2 tests, 0 skipped, 0 warned, 0 failed.
 
-  $ cat test-failure.t
+  $ sed -e 's,(glob)$,&<,g' test-failure.t
     $ echo babar
     babar
   This is a noop statement so that
   this test is still more bytes than success.
+    $ echo 'saved backup bundle to $TESTTMP/foo.hg'
+    saved backup bundle to $TESTTMP/foo.hg (glob)<
+    $ echo 'saved backup bundle to $TESTTMP/foo.hg'
+    saved backup bundle to $TESTTMP/foo.hg (glob)<
+    $ echo 'saved backup bundle to $TESTTMP/foo.hg'
+    saved backup bundle to $TESTTMP/*.hg (glob)<
 
 (reinstall)
   $ mv backup test-failure.t


More information about the Mercurial-devel mailing list