# HG changeset patch # User Boris Feld # Date 1528398556 -7200 # Node ID f2e3196a34f967e0a02570e1945e3c89c0e3db61 # Parent 688fbb758ba993d5648619b4ce03b71f1c5719d4 run-tests: follow-up on the test-case format It turns out the original regex doesn't support real test cases names like the one Mercurial is using. Update the regex to being able to precisely select them on the command line. Differential Revision: https://phab.mercurial-scm.org/D3699 diff -r 688fbb758ba9 -r f2e3196a34f9 tests/run-tests.py --- a/tests/run-tests.py Fri May 04 12:43:15 2018 +0900 +++ b/tests/run-tests.py Thu Jun 07 21:09:16 2018 +0200 @@ -120,7 +120,7 @@ } class TestRunnerLexer(lexer.RegexLexer): - testpattern = r'[\w-]+\.(t|py)(#[\w-]+)?' + testpattern = r'[\w-]+\.(t|py)(#[^\s]+)?' tokens = { 'root': [ (r'^Skipped', token.Generic.Skipped, 'skipped'), @@ -2646,7 +2646,7 @@ expanded_args.append(arg) args = expanded_args - testcasepattern = re.compile(r'([\w-]+\.t|py)(#([\w-])+)') + testcasepattern = re.compile(r'([\w-]+\.t|py)(#([^\s]+))') tests = [] for t in args: case = None diff -r 688fbb758ba9 -r f2e3196a34f9 tests/test-run-tests.t --- a/tests/test-run-tests.t Fri May 04 12:43:15 2018 +0900 +++ b/tests/test-run-tests.t Thu Jun 07 21:09:16 2018 +0200 @@ -1617,7 +1617,7 @@ python hash seed: * (glob) [1] -Support running invalid test cases +Support ignoring invalid test cases $ rt test-cases-abc.t#B test-cases-abc.t#D @@ -1640,6 +1640,81 @@ python hash seed: * (glob) [1] +Support running complex test cases names + + $ cat > test-cases-advanced-cases.t <<'EOF' + > #testcases simple case-with-dashes casewith!@#$%^&*()chars + > $ echo $TESTCASE + > simple + > EOF + + $ cat test-cases-advanced-cases.t + #testcases simple case-with-dashes casewith!@#$%^&*()chars + $ echo $TESTCASE + simple + + $ rt test-cases-advanced-cases.t + + --- $TESTTMP/anothertests/cases/test-cases-advanced-cases.t + +++ $TESTTMP/anothertests/cases/test-cases-advanced-cases.t.case-with-dashes.err + @@ -1,3 +1,3 @@ + #testcases simple case-with-dashes casewith!@#$%^&*()chars + $ echo $TESTCASE + - simple + + case-with-dashes + + ERROR: test-cases-advanced-cases.t#case-with-dashes output changed + ! + --- $TESTTMP/anothertests/cases/test-cases-advanced-cases.t + +++ $TESTTMP/anothertests/cases/test-cases-advanced-cases.t.casewith!@#$%^&*()chars.err + @@ -1,3 +1,3 @@ + #testcases simple case-with-dashes casewith!@#$%^&*()chars + $ echo $TESTCASE + - simple + + casewith!@#$%^&*()chars + + ERROR: test-cases-advanced-cases.t#casewith!@#$%^&*()chars output changed + !. + Failed test-cases-advanced-cases.t#case-with-dashes: output changed + Failed test-cases-advanced-cases.t#casewith!@#$%^&*()chars: output changed + # Ran 3 tests, 0 skipped, 2 failed. + python hash seed: * (glob) + [1] + + $ rt "test-cases-advanced-cases.t#case-with-dashes" + + --- $TESTTMP/anothertests/cases/test-cases-advanced-cases.t + +++ $TESTTMP/anothertests/cases/test-cases-advanced-cases.t.case-with-dashes.err + @@ -1,3 +1,3 @@ + #testcases simple case-with-dashes casewith!@#$%^&*()chars + $ echo $TESTCASE + - simple + + case-with-dashes + + ERROR: test-cases-advanced-cases.t#case-with-dashes output changed + ! + Failed test-cases-advanced-cases.t#case-with-dashes: output changed + # Ran 1 tests, 0 skipped, 1 failed. + python hash seed: * (glob) + [1] + + $ rt "test-cases-advanced-cases.t#casewith!@#$%^&*()chars" + + --- $TESTTMP/anothertests/cases/test-cases-advanced-cases.t + +++ $TESTTMP/anothertests/cases/test-cases-advanced-cases.t.casewith!@#$%^&*()chars.err + @@ -1,3 +1,3 @@ + #testcases simple case-with-dashes casewith!@#$%^&*()chars + $ echo $TESTCASE + - simple + + casewith!@#$%^&*()chars + + ERROR: test-cases-advanced-cases.t#casewith!@#$%^&*()chars output changed + ! + Failed test-cases-advanced-cases.t#casewith!@#$%^&*()chars: output changed + # Ran 1 tests, 0 skipped, 1 failed. + python hash seed: * (glob) + [1] + Test automatic pattern replacement ==================================