# HG changeset patch # User Augie Fackler # Date 1496191723 14400 # Node ID 931bb962e0ebfb53a73e6993628aa305098cbeec # Parent c59451e11cbfec538ef7b3dd612ce750020d38a3 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 -r c59451e11cbf -r 931bb962e0eb tests/run-tests.py --- 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 diff -r c59451e11cbf -r 931bb962e0eb tests/test-run-tests.t --- 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 < true + > #if notarealhghavefeature + > $ false + > #endif + > EOF + $ for f in 1 2 3 4 ; do + > cat > test-works-$f.t < 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