run-tests: restrict the test cases allowed characters
authorBoris Feld <boris.feld@octobus.net>
Tue, 12 Jun 2018 23:04:27 +0200
changeset 38290 b5651ae53127
parent 38289 f9c426385853
child 38291 c07424ec633c
run-tests: restrict the test cases allowed characters Most test cases in core and in extension only use `A-Za-z0-9-` but a few tests in extensions also have a `.` in their test cases names. Also add a `_` to allow all kind of case naming format. Differential Revision: https://phab.mercurial-scm.org/D3721
tests/run-tests.py
tests/test-run-tests.t
--- a/tests/run-tests.py	Sat Jun 09 13:34:47 2018 +0900
+++ b/tests/run-tests.py	Tue Jun 12 23:04:27 2018 +0200
@@ -120,7 +120,7 @@
         }
 
     class TestRunnerLexer(lexer.RegexLexer):
-        testpattern = r'[\w-]+\.(t|py)(#[^\s]+)?'
+        testpattern = r'[\w-]+\.(t|py)(#[a-zA-Z0-9_\-\.]+)?'
         tokens = {
             'root': [
                 (r'^Skipped', token.Generic.Skipped, 'skipped'),
@@ -2646,7 +2646,7 @@
                 expanded_args.append(arg)
         args = expanded_args
 
-        testcasepattern = re.compile(br'([\w-]+\.t|py)(#([^\s]+))')
+        testcasepattern = re.compile(br'([\w-]+\.t|py)(#([a-zA-Z0-9_\-\.]+))')
         tests = []
         for t in args:
             case = None
--- a/tests/test-run-tests.t	Sat Jun 09 13:34:47 2018 +0900
+++ b/tests/test-run-tests.t	Tue Jun 12 23:04:27 2018 +0200
@@ -1643,13 +1643,13 @@
 Support running complex test cases names
 
   $ cat > test-cases-advanced-cases.t <<'EOF'
-  > #testcases simple case-with-dashes casewith!@#$%^&*()chars
+  > #testcases simple case-with-dashes casewith_-.chars
   >   $ echo $TESTCASE
   >   simple
   > EOF
 
   $ cat test-cases-advanced-cases.t
-  #testcases simple case-with-dashes casewith!@#$%^&*()chars
+  #testcases simple case-with-dashes casewith_-.chars
     $ echo $TESTCASE
     simple
 
@@ -1658,7 +1658,7 @@
   --- $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
+   #testcases simple case-with-dashes casewith_-.chars
      $ echo $TESTCASE
   -  simple
   +  case-with-dashes
@@ -1666,17 +1666,17 @@
   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
+  +++ $TESTTMP/anothertests/cases/test-cases-advanced-cases.t.casewith_-.chars.err
   @@ -1,3 +1,3 @@
-   #testcases simple case-with-dashes casewith!@#$%^&*()chars
+   #testcases simple case-with-dashes casewith_-.chars
      $ echo $TESTCASE
   -  simple
-  +  casewith!@#$%^&*()chars
+  +  casewith_-.chars
   
-  ERROR: test-cases-advanced-cases.t#casewith!@#$%^&*()chars output changed
+  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
+  Failed test-cases-advanced-cases.t#casewith_-.chars: output changed
   # Ran 3 tests, 0 skipped, 2 failed.
   python hash seed: * (glob)
   [1]
@@ -1686,7 +1686,7 @@
   --- $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
+   #testcases simple case-with-dashes casewith_-.chars
      $ echo $TESTCASE
   -  simple
   +  case-with-dashes
@@ -1698,19 +1698,19 @@
   python hash seed: * (glob)
   [1]
 
-  $ rt "test-cases-advanced-cases.t#casewith!@#$%^&*()chars"
+  $ 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
+  +++ $TESTTMP/anothertests/cases/test-cases-advanced-cases.t.casewith_-.chars.err
   @@ -1,3 +1,3 @@
-   #testcases simple case-with-dashes casewith!@#$%^&*()chars
+   #testcases simple case-with-dashes casewith_-.chars
      $ echo $TESTCASE
   -  simple
-  +  casewith!@#$%^&*()chars
+  +  casewith_-.chars
   
-  ERROR: test-cases-advanced-cases.t#casewith!@#$%^&*()chars output changed
+  ERROR: test-cases-advanced-cases.t#casewith_-.chars output changed
   !
-  Failed 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]