D3555: run-tests: add support for running specific test cases

2018-06-04 Thread lothiraldan (Boris Feld)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG507bdc40bb17: run-tests: add support for running specific 
test cases (authored by lothiraldan, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3555?vs=8867=8971

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

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

CHANGE DETAILS

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
@@ -1571,7 +1571,77 @@
   ..
   # Ran 2 tests, 0 skipped, 0 failed.
 
+Support running a specific test case
+
+  $ rt "test-cases-abc.t (case B)"
+  
+  --- $TESTTMP/anothertests/cases/test-cases-abc.t
+  +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
+  @@ -7,7 +7,7 @@
+ $ V=C
+   #endif
+ $ echo $V | sed 's/A/C/'
+  -  C
+  +  B
+   #if C
+ $ [ $V = C ]
+   #endif
+  
+  ERROR: test-cases-abc.t (case B) output changed
+  !
+  Failed test-cases-abc.t (case B): output changed
+  # Ran 1 tests, 0 skipped, 1 failed.
+  python hash seed: * (glob)
+  [1]
+
+Support running multiple test cases in the same file
+
+  $ rt "test-cases-abc.t (case B)" "test-cases-abc.t (case C)"
+  
+  --- $TESTTMP/anothertests/cases/test-cases-abc.t
+  +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
+  @@ -7,7 +7,7 @@
+ $ V=C
+   #endif
+ $ echo $V | sed 's/A/C/'
+  -  C
+  +  B
+   #if C
+ $ [ $V = C ]
+   #endif
+  
+  ERROR: test-cases-abc.t (case B) output changed
+  !.
+  Failed test-cases-abc.t (case B): output changed
+  # Ran 2 tests, 0 skipped, 1 failed.
+  python hash seed: * (glob)
+  [1]
+
+Support running invalid test cases
+
+  $ rt "test-cases-abc.t (case B)" "test-cases-abc.t (case D)"
+  
+  --- $TESTTMP/anothertests/cases/test-cases-abc.t
+  +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
+  @@ -7,7 +7,7 @@
+ $ V=C
+   #endif
+ $ echo $V | sed 's/A/C/'
+  -  C
+  +  B
+   #if C
+ $ [ $V = C ]
+   #endif
+  
+  ERROR: test-cases-abc.t (case B) output changed
+  !
+  Failed test-cases-abc.t (case B): output changed
+  # Ran 1 tests, 0 skipped, 1 failed.
+  python hash seed: * (glob)
+  [1]
+
 Test automatic pattern replacement
+==
 
   $ cat << EOF >> common-pattern.py
   > substitutions = [
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2646,16 +2646,31 @@
 expanded_args.append(arg)
 args = expanded_args
 
+testcasepattern = re.compile(r'([\w-]+\.t|py)( \(case ([\w-])+\))')
 tests = []
 for t in args:
+case = None
+
 if not (os.path.basename(t).startswith(b'test-')
 and (t.endswith(b'.py') or t.endswith(b'.t'))):
-continue
+
+m = testcasepattern.match(t)
+if m is not None:
+t, _, case = m.groups()
+else:
+continue
+
 if t.endswith(b'.t'):
 # .t file may contain multiple test cases
 cases = sorted(parsettestcases(t))
 if cases:
-tests += [{'path': t, 'case': c} for c in sorted(cases)]
+if case is not None and case in cases:
+tests += [{'path': t, 'case': case}]
+elif case is not None and case not in cases:
+# Ignore invalid cases
+pass
+else:
+tests += [{'path': t, 'case': c} for c in 
sorted(cases)]
 else:
 tests.append({'path': t})
 else:



To: lothiraldan, #hg-reviewers, quark, pulkit, durin42
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3555: run-tests: add support for running specific test cases

2018-05-22 Thread lothiraldan (Boris Feld)
lothiraldan updated this revision to Diff 8867.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3555?vs=8677=8867

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

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

CHANGE DETAILS

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
@@ -1571,7 +1571,77 @@
   ..
   # Ran 2 tests, 0 skipped, 0 failed.
 
+Support running a specific test case
+
+  $ rt "test-cases-abc.t (case B)"
+  
+  --- $TESTTMP/anothertests/cases/test-cases-abc.t
+  +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
+  @@ -7,7 +7,7 @@
+ $ V=C
+   #endif
+ $ echo $V | sed 's/A/C/'
+  -  C
+  +  B
+   #if C
+ $ [ $V = C ]
+   #endif
+  
+  ERROR: test-cases-abc.t (case B) output changed
+  !
+  Failed test-cases-abc.t (case B): output changed
+  # Ran 1 tests, 0 skipped, 1 failed.
+  python hash seed: * (glob)
+  [1]
+
+Support running multiple test cases in the same file
+
+  $ rt "test-cases-abc.t (case B)" "test-cases-abc.t (case C)"
+  
+  --- $TESTTMP/anothertests/cases/test-cases-abc.t
+  +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
+  @@ -7,7 +7,7 @@
+ $ V=C
+   #endif
+ $ echo $V | sed 's/A/C/'
+  -  C
+  +  B
+   #if C
+ $ [ $V = C ]
+   #endif
+  
+  ERROR: test-cases-abc.t (case B) output changed
+  !.
+  Failed test-cases-abc.t (case B): output changed
+  # Ran 2 tests, 0 skipped, 1 failed.
+  python hash seed: * (glob)
+  [1]
+
+Support running invalid test cases
+
+  $ rt "test-cases-abc.t (case B)" "test-cases-abc.t (case D)"
+  
+  --- $TESTTMP/anothertests/cases/test-cases-abc.t
+  +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
+  @@ -7,7 +7,7 @@
+ $ V=C
+   #endif
+ $ echo $V | sed 's/A/C/'
+  -  C
+  +  B
+   #if C
+ $ [ $V = C ]
+   #endif
+  
+  ERROR: test-cases-abc.t (case B) output changed
+  !
+  Failed test-cases-abc.t (case B): output changed
+  # Ran 1 tests, 0 skipped, 1 failed.
+  python hash seed: * (glob)
+  [1]
+
 Test automatic pattern replacement
+==
 
   $ cat << EOF >> common-pattern.py
   > substitutions = [
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2646,16 +2646,31 @@
 expanded_args.append(arg)
 args = expanded_args
 
+testcasepattern = re.compile(r'([\w-]+\.t|py)( \(case ([\w-])+\))')
 tests = []
 for t in args:
+case = None
+
 if not (os.path.basename(t).startswith(b'test-')
 and (t.endswith(b'.py') or t.endswith(b'.t'))):
-continue
+
+m = testcasepattern.match(t)
+if m is not None:
+t, _, case = m.groups()
+else:
+continue
+
 if t.endswith(b'.t'):
 # .t file may contain multiple test cases
 cases = sorted(parsettestcases(t))
 if cases:
-tests += [{'path': t, 'case': c} for c in sorted(cases)]
+if case is not None and case in cases:
+tests += [{'path': t, 'case': case}]
+elif case is not None and case not in cases:
+# Ignore invalid cases
+pass
+else:
+tests += [{'path': t, 'case': c} for c in 
sorted(cases)]
 else:
 tests.append({'path': t})
 else:



To: lothiraldan, #hg-reviewers, quark, pulkit
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D3555: run-tests: add support for running specific test cases

2018-05-13 Thread lothiraldan (Boris Feld)
lothiraldan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

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

CHANGE DETAILS

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
@@ -1571,7 +1571,77 @@
   ..
   # Ran 2 tests, 0 skipped, 0 failed.
 
+Support running a specific test case
+
+  $ rt "test-cases-abc.t (case B)"
+  
+  --- $TESTTMP/anothertests/cases/test-cases-abc.t
+  +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
+  @@ -7,7 +7,7 @@
+ $ V=C
+   #endif
+ $ echo $V | sed 's/A/C/'
+  -  C
+  +  B
+   #if C
+ $ [ $V = C ]
+   #endif
+  
+  ERROR: test-cases-abc.t (case B) output changed
+  !
+  Failed test-cases-abc.t (case B): output changed
+  # Ran 1 tests, 0 skipped, 1 failed.
+  python hash seed: * (glob)
+  [1]
+
+Support running multiple test cases in the same file
+
+  $ rt "test-cases-abc.t (case B)" "test-cases-abc.t (case C)"
+  
+  --- $TESTTMP/anothertests/cases/test-cases-abc.t
+  +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
+  @@ -7,7 +7,7 @@
+ $ V=C
+   #endif
+ $ echo $V | sed 's/A/C/'
+  -  C
+  +  B
+   #if C
+ $ [ $V = C ]
+   #endif
+  
+  ERROR: test-cases-abc.t (case B) output changed
+  !.
+  Failed test-cases-abc.t (case B): output changed
+  # Ran 2 tests, 0 skipped, 1 failed.
+  python hash seed: * (glob)
+  [1]
+
+Support running invalid test cases
+
+  $ rt "test-cases-abc.t (case B)" "test-cases-abc.t (case D)"
+  
+  --- $TESTTMP/anothertests/cases/test-cases-abc.t
+  +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
+  @@ -7,7 +7,7 @@
+ $ V=C
+   #endif
+ $ echo $V | sed 's/A/C/'
+  -  C
+  +  B
+   #if C
+ $ [ $V = C ]
+   #endif
+  
+  ERROR: test-cases-abc.t (case B) output changed
+  !
+  Failed test-cases-abc.t (case B): output changed
+  # Ran 1 tests, 0 skipped, 1 failed.
+  python hash seed: * (glob)
+  [1]
+
 Test automatic pattern replacement
+==
 
   $ cat << EOF >> common-pattern.py
   > substitutions = [
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2646,16 +2646,28 @@
 expanded_args.append(arg)
 args = expanded_args
 
+testcasepattern = re.compile(r'([\w-]+\.t|py)( \(case ([\w-])+\))')
 tests = []
 for t in args:
+case = None
+
 if not (os.path.basename(t).startswith(b'test-')
 and (t.endswith(b'.py') or t.endswith(b'.t'))):
-continue
+
+m = testcasepattern.match(t)
+if m is not None:
+t, _, case = m.groups()
+else:
+continue
+
 if t.endswith(b'.t'):
 # .t file may contain multiple test cases
 cases = sorted(parsettestcases(t))
 if cases:
-tests += [{'path': t, 'case': c} for c in sorted(cases)]
+if case is not None and case in cases:
+tests += [{'path': t, 'case': case}]
+else:
+tests += [{'path': t, 'case': c} for c in 
sorted(cases)]
 else:
 tests.append({'path': t})
 else:



To: lothiraldan, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel