/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-01-17 02:04:32 UTC
  • mfrom: (2213.2.3 test_first)
  • Revision ID: pqm@pqm.ubuntu.com-20070117020432-338f7296818dc56e
(mbp) add selftest --first flag (r=aaron)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1658
1658
    return result
1659
1659
 
1660
1660
 
 
1661
def sort_suite_by_re(suite, pattern):
 
1662
    first = []
 
1663
    second = []
 
1664
    filter_re = re.compile(pattern)
 
1665
    for test in iter_suite_tests(suite):
 
1666
        if filter_re.search(test.id()):
 
1667
            first.append(test)
 
1668
        else:
 
1669
            second.append(test)
 
1670
    return TestUtil.TestSuite(first + second)
 
1671
 
 
1672
 
1661
1673
def run_suite(suite, name='test', verbose=False, pattern=".*",
1662
1674
              stop_on_failure=False, keep_output=False,
1663
 
              transport=None, lsprof_timed=None, bench_history=None):
 
1675
              transport=None, lsprof_timed=None, bench_history=None,
 
1676
              matching_tests_first=None):
1664
1677
    TestCase._gather_lsprof_in_benchmarks = lsprof_timed
1665
1678
    if verbose:
1666
1679
        verbosity = 2
1673
1686
                            bench_history=bench_history)
1674
1687
    runner.stop_on_failure=stop_on_failure
1675
1688
    if pattern != '.*':
1676
 
        suite = filter_suite_by_re(suite, pattern)
 
1689
        if matching_tests_first:
 
1690
            suite = sort_suite_by_re(suite, pattern)
 
1691
        else:
 
1692
            suite = filter_suite_by_re(suite, pattern)
1677
1693
    result = runner.run(suite)
1678
1694
    return result.wasSuccessful()
1679
1695
 
1683
1699
             transport=None,
1684
1700
             test_suite_factory=None,
1685
1701
             lsprof_timed=None,
1686
 
             bench_history=None):
 
1702
             bench_history=None,
 
1703
             matching_tests_first=None):
1687
1704
    """Run the whole test suite under the enhanced runner"""
1688
1705
    # XXX: Very ugly way to do this...
1689
1706
    # Disable warning about old formats because we don't want it to disturb
1705
1722
                     stop_on_failure=stop_on_failure, keep_output=keep_output,
1706
1723
                     transport=transport,
1707
1724
                     lsprof_timed=lsprof_timed,
1708
 
                     bench_history=bench_history)
 
1725
                     bench_history=bench_history,
 
1726
                     matching_tests_first=matching_tests_first)
1709
1727
    finally:
1710
1728
        default_transport = old_transport
1711
1729