run-tests: follow-up on the test-case format
authorBoris Feld <boris.feld@octobus.net>
Thu, 07 Jun 2018 21:09:16 +0200
changeset 38257 f2e3196a34f9
parent 38256 688fbb758ba9
child 38258 46dcb9f14900
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
tests/run-tests.py
tests/test-run-tests.t
--- 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
--- 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
 ==================================