[PATCH 2 of 2] tests: fix run-tests when there's a bad #if in a test
raf at durin42.com
Tue May 30 21:12:31 EDT 2017
# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1496191723 14400
# Tue May 30 20:48:43 2017 -0400
# Node ID 48ea485539377729a711959c15ac4262550234fc
# Parent 361bf17d190dbd3410be4b7fd8ff4d27ddb48739
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.
diff --git a/tests/run-tests.py b/tests/run-tests.py
@@ -1778,10 +1778,11 @@ class TestSuite(unittest.TestSuite):
except: # re-raises
done.put(('!', test, 'run-test raised an error, see traceback'))
- channels[channel] = ''
- except IndexError:
+ channels[channel] = ''
+ except IndexError:
count = 0
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
@@ -903,6 +903,30 @@ support for bisecting failed tests autom
$ 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
More information about the Mercurial-devel