Show More
@@ -285,12 +285,12 b' def parsettestcases(path):' | |||
|
285 | 285 | |
|
286 | 286 | If path does not exist, return an empty set. |
|
287 | 287 | """ |
|
288 |
cases = |
|
|
288 | cases = [] | |
|
289 | 289 | try: |
|
290 | 290 | with open(path, 'rb') as f: |
|
291 | 291 | for l in f: |
|
292 | 292 | if l.startswith(b'#testcases '): |
|
293 |
cases. |
|
|
293 | cases.append(sorted(l[11:].split())) | |
|
294 | 294 | except IOError as ex: |
|
295 | 295 | if ex.errno != errno.ENOENT: |
|
296 | 296 | raise |
@@ -1242,14 +1242,15 b' class TTest(Test):' | |||
|
1242 | 1242 | |
|
1243 | 1243 | def __init__(self, path, *args, **kwds): |
|
1244 | 1244 | # accept an extra "case" parameter |
|
1245 |
case = kwds.pop('case', |
|
|
1245 | case = kwds.pop('case', []) | |
|
1246 | 1246 | self._case = case |
|
1247 | self._allcases = parsettestcases(path) | |
|
1247 | self._allcases = {x for y in parsettestcases(path) for x in y} | |
|
1248 | 1248 | super(TTest, self).__init__(path, *args, **kwds) |
|
1249 | 1249 | if case: |
|
1250 |
|
|
|
1251 |
self.e |
|
|
1252 | self._tmpname += b'-%s' % case | |
|
1250 | casepath = _strpath('#'.join(case)) | |
|
1251 | self.name = '%s#%s' % (self.name, casepath) | |
|
1252 | self.errpath = b'%s#%s.err' % (self.errpath[:-4], casepath) | |
|
1253 | self._tmpname += b'-%s' % casepath | |
|
1253 | 1254 | self._have = {} |
|
1254 | 1255 | |
|
1255 | 1256 | @property |
@@ -1323,10 +1324,10 b' class TTest(Test):' | |||
|
1323 | 1324 | reqs = [] |
|
1324 | 1325 | for arg in args: |
|
1325 | 1326 | if arg.startswith(b'no-') and arg[3:] in self._allcases: |
|
1326 |
if arg[3:] |
|
|
1327 | if arg[3:] in self._case: | |
|
1327 | 1328 | return False |
|
1328 | 1329 | elif arg in self._allcases: |
|
1329 |
if arg |
|
|
1330 | if arg not in self._case: | |
|
1330 | 1331 | return False |
|
1331 | 1332 | else: |
|
1332 | 1333 | reqs.append(arg) |
@@ -1370,10 +1371,11 b' class TTest(Test):' | |||
|
1370 | 1371 | if os.getenv('MSYSTEM'): |
|
1371 | 1372 | script.append(b'alias pwd="pwd -W"\n') |
|
1372 | 1373 | if self._case: |
|
1374 | casestr = '#'.join(self._case) | |
|
1373 | 1375 | if isinstance(self._case, str): |
|
1374 |
quoted = shellquote( |
|
|
1376 | quoted = shellquote(casestr) | |
|
1375 | 1377 | else: |
|
1376 |
quoted = shellquote( |
|
|
1378 | quoted = shellquote(casestr.decode('utf8')).encode('utf8') | |
|
1377 | 1379 | script.append(b'TESTCASE=%s\n' % quoted) |
|
1378 | 1380 | script.append(b'export TESTCASE\n') |
|
1379 | 1381 | |
@@ -2666,31 +2668,42 b' class TestRunner(object):' | |||
|
2666 | 2668 | expanded_args.append(arg) |
|
2667 | 2669 | args = expanded_args |
|
2668 | 2670 | |
|
2669 | testcasepattern = re.compile(br'([\w-]+\.t|py)(#([a-zA-Z0-9_\-\.]+))') | |
|
2671 | testcasepattern = re.compile(br'([\w-]+\.t|py)(#([a-zA-Z0-9_\-\.#]+))') | |
|
2670 | 2672 | tests = [] |
|
2671 | 2673 | for t in args: |
|
2672 |
case = |
|
|
2674 | case = [] | |
|
2673 | 2675 | |
|
2674 | 2676 | if not (os.path.basename(t).startswith(b'test-') |
|
2675 | 2677 | and (t.endswith(b'.py') or t.endswith(b'.t'))): |
|
2676 | 2678 | |
|
2677 | 2679 | m = testcasepattern.match(t) |
|
2678 | 2680 | if m is not None: |
|
2679 | t, _, case = m.groups() | |
|
2681 | t, _, casestr = m.groups() | |
|
2682 | if casestr: | |
|
2683 | case = casestr.split('#') | |
|
2680 | 2684 | else: |
|
2681 | 2685 | continue |
|
2682 | 2686 | |
|
2683 | 2687 | if t.endswith(b'.t'): |
|
2684 | 2688 | # .t file may contain multiple test cases |
|
2685 |
cases = |
|
|
2686 | if cases: | |
|
2687 | if case is not None and case in cases: | |
|
2688 | tests += [{'path': t, 'case': case}] | |
|
2689 |
|
|
|
2689 | casedimensions = parsettestcases(t) | |
|
2690 | if casedimensions: | |
|
2691 | cases = [] | |
|
2692 | def addcases(case, casedimensions): | |
|
2693 | if not casedimensions: | |
|
2694 | cases.append(case) | |
|
2695 | else: | |
|
2696 | for c in casedimensions[0]: | |
|
2697 | addcases(case + [c], casedimensions[1:]) | |
|
2698 | addcases([], casedimensions) | |
|
2699 | if case and case in cases: | |
|
2700 | cases = [case] | |
|
2701 | elif case: | |
|
2690 | 2702 | # Ignore invalid cases |
|
2691 |
|
|
|
2703 | cases = [] | |
|
2692 | 2704 | else: |
|
2693 | tests += [{'path': t, 'case': c} for c in sorted(cases)] | |
|
2705 | pass | |
|
2706 | tests += [{'path': t, 'case': c} for c in sorted(cases)] | |
|
2694 | 2707 | else: |
|
2695 | 2708 | tests.append({'path': t}) |
|
2696 | 2709 | else: |
@@ -2701,7 +2714,7 b' class TestRunner(object):' | |||
|
2701 | 2714 | def _reloadtest(test, i): |
|
2702 | 2715 | # convert a test back to its description dict |
|
2703 | 2716 | desc = {'path': test.path} |
|
2704 |
case = getattr(test, '_case', |
|
|
2717 | case = getattr(test, '_case', []) | |
|
2705 | 2718 | if case: |
|
2706 | 2719 | desc['case'] = case |
|
2707 | 2720 | return self._gettest(desc, i) |
@@ -2713,7 +2726,8 b' class TestRunner(object):' | |||
|
2713 | 2726 | desc = testdescs[0] |
|
2714 | 2727 | # desc['path'] is a relative path |
|
2715 | 2728 | if 'case' in desc: |
|
2716 |
|
|
|
2729 | casestr = '#'.join(desc['case']) | |
|
2730 | errpath = b'%s#%s.err' % (desc['path'], casestr) | |
|
2717 | 2731 | else: |
|
2718 | 2732 | errpath = b'%s.err' % desc['path'] |
|
2719 | 2733 | errpath = os.path.join(self._outputdir, errpath) |
@@ -896,6 +896,40 b' When "#testcases" is used in .t files' | |||
|
896 | 896 | .. |
|
897 | 897 | # Ran 2 tests, 0 skipped, 0 failed. |
|
898 | 898 | |
|
899 | When using multiple dimensions of "#testcases" in .t files | |
|
900 | ||
|
901 | $ cat > test-cases.t <<'EOF' | |
|
902 | > #testcases a b | |
|
903 | > #testcases c d | |
|
904 | > #if a d | |
|
905 | > $ echo $TESTCASE | |
|
906 | > a#d | |
|
907 | > #endif | |
|
908 | > #if b c | |
|
909 | > $ echo yes | |
|
910 | > no | |
|
911 | > #endif | |
|
912 | > EOF | |
|
913 | $ rt test-cases.t | |
|
914 | .. | |
|
915 | --- $TESTTMP/test-cases.t | |
|
916 | +++ $TESTTMP/test-cases.t#b#c.err | |
|
917 | @@ -6,5 +6,5 @@ | |
|
918 | #endif | |
|
919 | #if b c | |
|
920 | $ echo yes | |
|
921 | - no | |
|
922 | + yes | |
|
923 | #endif | |
|
924 | ||
|
925 | ERROR: test-cases.t#b#c output changed | |
|
926 | !. | |
|
927 | Failed test-cases.t#b#c: output changed | |
|
928 | # Ran 4 tests, 0 skipped, 1 failed. | |
|
929 | python hash seed: * (glob) | |
|
930 | [1] | |
|
931 | ||
|
932 | $ rm test-cases.t#b#c.err | |
|
899 | 933 | $ rm test-cases.t |
|
900 | 934 | |
|
901 | 935 | (reinstall) |
General Comments 0
You need to be logged in to leave comments.
Login now