run-tests: handle --jobs and --first gracefully
authorAugie Fackler <raf@durin42.com>
Thu, 09 Oct 2014 15:10:40 -0400
changeset 22838 9a20f53e436f
parent 22837 2be7d5ebd4d0
child 22839 9f0f50c63e16
run-tests: handle --jobs and --first gracefully Without this change, --first causes currently-running tests to explode in violent and surprising ways when their temporary directory gets cleaned up. Now we just suppress failure messages from non-first failures when running in --first mode.
tests/run-tests.py
tests/test-run-tests.t
--- a/tests/run-tests.py	Mon Oct 06 16:35:02 2014 -0400
+++ b/tests/run-tests.py	Thu Oct 09 15:10:40 2014 -0400
@@ -1189,6 +1189,11 @@
 
     def addOutputMismatch(self, test, ret, got, expected):
         """Record a mismatch in test output for a particular test."""
+        if self.shouldStop:
+            # don't print, some other test case already failed and
+            # printed, we're just stale and probably failed due to our
+            # temp dir getting cleaned up.
+            return
 
         accepted = False
         failed = False
--- a/tests/test-run-tests.t	Mon Oct 06 16:35:02 2014 -0400
+++ b/tests/test-run-tests.t	Thu Oct 09 15:10:40 2014 -0400
@@ -215,8 +215,29 @@
   python hash seed: * (glob)
   [1]
 
+failures in parallel with --first should only print one failure
+  >>> f = open('test-nothing.t', 'w')
+  >>> f.write('foo\n' * 1024)
+  >>> f.write('  $ sleep 1')
+  $ $TESTDIR/run-tests.py --with-hg=`which hg` --jobs 2 --first
+  
+  --- $TESTTMP/test-failure*.t (glob)
+  +++ $TESTTMP/test-failure*.t.err (glob)
+  @@ -1,4 +1,4 @@
+     $ echo babar
+  -  rataxes
+  +  babar
+   This is a noop statement so that
+   this test is still more bytes than success.
+  
+  Failed test-failure*.t: output changed (glob)
+  # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
+  python hash seed: * (glob)
+  [1]
+
+
 (delete the duplicated test file)
-  $ rm test-failure-copy.t
+  $ rm test-failure-copy.t test-nothing.t
 
 
 Interactive run