changeset 32622:931bb962e0eb

tests: fix run-tests when there's a bad #if in a test That has (and still does) caused the test to be skipped, but without this fix it was possible to exit this block of code without clearing the output channel, which poisoned the channel list for later test method runs. Fix this by always clearing the channel in a finally. The test for this is somewhat unfortunate. Sadly, I couldn't get a way to reproduce this with less than 2n+1 test cases, nor could I get it to reproduce reliably without the sleep statements. It's also crucial that the test with the broken #if be smaller (in terms of byte count) than the sleeping tests, so that it runs first and would poison the channel list prior to another test needing that entry from the list.
author Augie Fackler <augie@google.com>
date Tue, 30 May 2017 20:48:43 -0400
parents c59451e11cbf
children ed566a59f660
files tests/run-tests.py tests/test-run-tests.t
diffstat 2 files changed, 29 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Tue May 30 20:47:00 2017 -0400
+++ b/tests/run-tests.py	Tue May 30 20:48:43 2017 -0400
@@ -1778,10 +1778,11 @@
             except: # re-raises
                 done.put(('!', test, 'run-test raised an error, see traceback'))
                 raise
-            try:
-                channels[channel] = ''
-            except IndexError:
-                pass
+            finally:
+                try:
+                    channels[channel] = ''
+                except IndexError:
+                    pass
 
         def stat():
             count = 0
--- a/tests/test-run-tests.t	Tue May 30 20:47:00 2017 -0400
+++ b/tests/test-run-tests.t	Tue May 30 20:48:43 2017 -0400
@@ -903,6 +903,30 @@
 
   $ cd ..
 
+Test a broken #if statement doesn't break run-tests threading.
+==============================================================
+  $ mkdir broken
+  $ cd broken
+  $ cat > test-broken.t <<EOF
+  > true
+  > #if notarealhghavefeature
+  >   $ false
+  > #endif
+  > EOF
+  $ for f in 1 2 3 4 ; do
+  > cat > test-works-$f.t <<EOF
+  > This is test case $f
+  >   $ sleep 1
+  > EOF
+  > done
+  $ rt -j 2
+  ....
+  # Ran 5 tests, 0 skipped, 0 warned, 0 failed.
+  skipped: unknown feature: notarealhghavefeature
+  
+  $ cd ..
+  $ rm -rf broken
+
 Test cases in .t files
 ======================
   $ mkdir cases