Show More
@@ -2646,16 +2646,31 b' class TestRunner(object):' | |||
|
2646 | 2646 | expanded_args.append(arg) |
|
2647 | 2647 | args = expanded_args |
|
2648 | 2648 | |
|
2649 | testcasepattern = re.compile(r'([\w-]+\.t|py)( \(case ([\w-])+\))') | |
|
2649 | 2650 | tests = [] |
|
2650 | 2651 | for t in args: |
|
2652 | case = None | |
|
2653 | ||
|
2651 | 2654 | if not (os.path.basename(t).startswith(b'test-') |
|
2652 | 2655 | and (t.endswith(b'.py') or t.endswith(b'.t'))): |
|
2653 | continue | |
|
2656 | ||
|
2657 | m = testcasepattern.match(t) | |
|
2658 | if m is not None: | |
|
2659 | t, _, case = m.groups() | |
|
2660 | else: | |
|
2661 | continue | |
|
2662 | ||
|
2654 | 2663 | if t.endswith(b'.t'): |
|
2655 | 2664 | # .t file may contain multiple test cases |
|
2656 | 2665 | cases = sorted(parsettestcases(t)) |
|
2657 | 2666 | if cases: |
|
2658 | tests += [{'path': t, 'case': c} for c in sorted(cases)] | |
|
2667 | if case is not None and case in cases: | |
|
2668 | tests += [{'path': t, 'case': case}] | |
|
2669 | elif case is not None and case not in cases: | |
|
2670 | # Ignore invalid cases | |
|
2671 | pass | |
|
2672 | else: | |
|
2673 | tests += [{'path': t, 'case': c} for c in sorted(cases)] | |
|
2659 | 2674 | else: |
|
2660 | 2675 | tests.append({'path': t}) |
|
2661 | 2676 | else: |
@@ -1571,7 +1571,77 b' Test TESTCASE variable' | |||
|
1571 | 1571 | .. |
|
1572 | 1572 | # Ran 2 tests, 0 skipped, 0 failed. |
|
1573 | 1573 | |
|
1574 | Support running a specific test case | |
|
1575 | ||
|
1576 | $ rt "test-cases-abc.t (case B)" | |
|
1577 | ||
|
1578 | --- $TESTTMP/anothertests/cases/test-cases-abc.t | |
|
1579 | +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err | |
|
1580 | @@ -7,7 +7,7 @@ | |
|
1581 | $ V=C | |
|
1582 | #endif | |
|
1583 | $ echo $V | sed 's/A/C/' | |
|
1584 | - C | |
|
1585 | + B | |
|
1586 | #if C | |
|
1587 | $ [ $V = C ] | |
|
1588 | #endif | |
|
1589 | ||
|
1590 | ERROR: test-cases-abc.t (case B) output changed | |
|
1591 | ! | |
|
1592 | Failed test-cases-abc.t (case B): output changed | |
|
1593 | # Ran 1 tests, 0 skipped, 1 failed. | |
|
1594 | python hash seed: * (glob) | |
|
1595 | [1] | |
|
1596 | ||
|
1597 | Support running multiple test cases in the same file | |
|
1598 | ||
|
1599 | $ rt "test-cases-abc.t (case B)" "test-cases-abc.t (case C)" | |
|
1600 | ||
|
1601 | --- $TESTTMP/anothertests/cases/test-cases-abc.t | |
|
1602 | +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err | |
|
1603 | @@ -7,7 +7,7 @@ | |
|
1604 | $ V=C | |
|
1605 | #endif | |
|
1606 | $ echo $V | sed 's/A/C/' | |
|
1607 | - C | |
|
1608 | + B | |
|
1609 | #if C | |
|
1610 | $ [ $V = C ] | |
|
1611 | #endif | |
|
1612 | ||
|
1613 | ERROR: test-cases-abc.t (case B) output changed | |
|
1614 | !. | |
|
1615 | Failed test-cases-abc.t (case B): output changed | |
|
1616 | # Ran 2 tests, 0 skipped, 1 failed. | |
|
1617 | python hash seed: * (glob) | |
|
1618 | [1] | |
|
1619 | ||
|
1620 | Support running invalid test cases | |
|
1621 | ||
|
1622 | $ rt "test-cases-abc.t (case B)" "test-cases-abc.t (case D)" | |
|
1623 | ||
|
1624 | --- $TESTTMP/anothertests/cases/test-cases-abc.t | |
|
1625 | +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err | |
|
1626 | @@ -7,7 +7,7 @@ | |
|
1627 | $ V=C | |
|
1628 | #endif | |
|
1629 | $ echo $V | sed 's/A/C/' | |
|
1630 | - C | |
|
1631 | + B | |
|
1632 | #if C | |
|
1633 | $ [ $V = C ] | |
|
1634 | #endif | |
|
1635 | ||
|
1636 | ERROR: test-cases-abc.t (case B) output changed | |
|
1637 | ! | |
|
1638 | Failed test-cases-abc.t (case B): output changed | |
|
1639 | # Ran 1 tests, 0 skipped, 1 failed. | |
|
1640 | python hash seed: * (glob) | |
|
1641 | [1] | |
|
1642 | ||
|
1574 | 1643 | Test automatic pattern replacement |
|
1644 | ================================== | |
|
1575 | 1645 | |
|
1576 | 1646 | $ cat << EOF >> common-pattern.py |
|
1577 | 1647 | > substitutions = [ |
General Comments 0
You need to be logged in to leave comments.
Login now