Details
Details
- Reviewers
quark pulkit durin42 - Group Reviewers
hg-reviewers - Commits
- rHG507bdc40bb17: run-tests: add support for running specific test cases
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
| quark | |
| pulkit | |
| durin42 |
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | tests/run-tests.py (19 lines) | |||
| M | tests/test-run-tests.t (70 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| Boris Feld | Apr 26 2018, 5:57 PM |
| Status | Author | Revision | |
|---|---|---|---|
| Closed | lothiraldan | ||
| Closed | lothiraldan |
| if os.path.isdir(arg): | if os.path.isdir(arg): | ||||
| if not arg.endswith(b'/'): | if not arg.endswith(b'/'): | ||||
| arg += b'/' | arg += b'/' | ||||
| expanded_args.extend([arg + a for a in os.listdir(arg)]) | expanded_args.extend([arg + a for a in os.listdir(arg)]) | ||||
| else: | else: | ||||
| expanded_args.append(arg) | expanded_args.append(arg) | ||||
| args = expanded_args | args = expanded_args | ||||
| testcasepattern = re.compile(r'([\w-]+\.t|py)( \(case ([\w-])+\))') | |||||
| tests = [] | tests = [] | ||||
| for t in args: | for t in args: | ||||
| case = None | |||||
| if not (os.path.basename(t).startswith(b'test-') | if not (os.path.basename(t).startswith(b'test-') | ||||
| and (t.endswith(b'.py') or t.endswith(b'.t'))): | and (t.endswith(b'.py') or t.endswith(b'.t'))): | ||||
| m = testcasepattern.match(t) | |||||
| if m is not None: | |||||
| t, _, case = m.groups() | |||||
| else: | |||||
| continue | continue | ||||
| if t.endswith(b'.t'): | if t.endswith(b'.t'): | ||||
| # .t file may contain multiple test cases | # .t file may contain multiple test cases | ||||
| cases = sorted(parsettestcases(t)) | cases = sorted(parsettestcases(t)) | ||||
| if cases: | if 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)] | tests += [{'path': t, 'case': c} for c in sorted(cases)] | ||||
| else: | else: | ||||
| tests.append({'path': t}) | tests.append({'path': t}) | ||||
| else: | else: | ||||
| tests.append({'path': t}) | tests.append({'path': t}) | ||||
| return tests | return tests | ||||
| def _runtests(self, testdescs): | def _runtests(self, testdescs): | ||||
| def _reloadtest(test, i): | def _reloadtest(test, i): | ||||
| > $ dostuff | > $ dostuff | ||||
| > In case B | > In case B | ||||
| > #endif | > #endif | ||||
| > EOF | > EOF | ||||
| $ rt test-cases-ab.t | $ rt test-cases-ab.t | ||||
| .. | .. | ||||
| # Ran 2 tests, 0 skipped, 0 failed. | # 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 | Test automatic pattern replacement | ||||
| ================================== | |||||
| $ cat << EOF >> common-pattern.py | $ cat << EOF >> common-pattern.py | ||||
| > substitutions = [ | > substitutions = [ | ||||
| > (br'foo-(.*)\\b', | > (br'foo-(.*)\\b', | ||||
| > br'\$XXX=\\1\$'), | > br'\$XXX=\\1\$'), | ||||
| > (br'bar\\n', | > (br'bar\\n', | ||||
| > br'\$YYY$\\n'), | > br'\$YYY$\\n'), | ||||
| > ] | > ] | ||||