##// END OF EJS Templates
run-tests: add support for running specific test cases...
Boris Feld -
r38224:507bdc40 default
parent child Browse files
Show More
@@ -2646,16 +2646,31 b' class TestRunner(object):'
2646 expanded_args.append(arg)
2646 expanded_args.append(arg)
2647 args = expanded_args
2647 args = expanded_args
2648
2648
2649 testcasepattern = re.compile(r'([\w-]+\.t|py)( \(case ([\w-])+\))')
2649 tests = []
2650 tests = []
2650 for t in args:
2651 for t in args:
2652 case = None
2653
2651 if not (os.path.basename(t).startswith(b'test-')
2654 if not (os.path.basename(t).startswith(b'test-')
2652 and (t.endswith(b'.py') or t.endswith(b'.t'))):
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 if t.endswith(b'.t'):
2663 if t.endswith(b'.t'):
2655 # .t file may contain multiple test cases
2664 # .t file may contain multiple test cases
2656 cases = sorted(parsettestcases(t))
2665 cases = sorted(parsettestcases(t))
2657 if cases:
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 else:
2674 else:
2660 tests.append({'path': t})
2675 tests.append({'path': t})
2661 else:
2676 else:
@@ -1571,7 +1571,77 b' Test TESTCASE variable'
1571 ..
1571 ..
1572 # Ran 2 tests, 0 skipped, 0 failed.
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 Test automatic pattern replacement
1643 Test automatic pattern replacement
1644 ==================================
1575
1645
1576 $ cat << EOF >> common-pattern.py
1646 $ cat << EOF >> common-pattern.py
1577 > substitutions = [
1647 > substitutions = [
General Comments 0
You need to be logged in to leave comments. Login now