# HG changeset patch # User Boris Feld # Date 2018-06-07 19:09:16 # 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 --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -120,7 +120,7 @@ if pygmentspresent: } 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 @@ class TestRunner(object): 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 --git a/tests/test-run-tests.t b/tests/test-run-tests.t --- a/tests/test-run-tests.t +++ b/tests/test-run-tests.t @@ -1617,7 +1617,7 @@ Support running multiple test cases in t 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 @@ Support running invalid test cases 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 ==================================