Patchwork D3721: run-tests: restrict the test cases allowed characters

login
register
mail settings
Submitter phabricator
Date June 13, 2018, 3:42 a.m.
Message ID <04613ef1c269591887a539667bd0df50@localhost.localdomain>
Download mbox | patch
Permalink /patch/32104/
State Not Applicable
Headers show

Comments

phabricator - June 13, 2018, 3:42 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb5651ae53127: run-tests: restrict the test cases allowed characters (authored by lothiraldan, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D3721?vs=9030&id=9040#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3721?vs=9030&id=9040

REVISION DETAIL
  https://phab.mercurial-scm.org/D3721

AFFECTED FILES
  tests/run-tests.py
  tests/test-run-tests.t

CHANGE DETAILS




To: lothiraldan, #hg-reviewers, mharbison72, durin42
Cc: mharbison72, mercurial-devel

Patch

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
@@ -1643,40 +1643,40 @@ 
 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
 
   $ 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
+   #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
+  +++ $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]
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 @@ 
         }
 
     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