##// END OF EJS Templates
run-tests: add support for automatically bisecting test failures
Augie Fackler -
r28596:99499506 default
parent child Browse files
Show More
@@ -270,6 +270,10 b' def getparser():'
270 help='allow extremely slow tests')
270 help='allow extremely slow tests')
271 parser.add_option('--showchannels', action='store_true',
271 parser.add_option('--showchannels', action='store_true',
272 help='show scheduling channels')
272 help='show scheduling channels')
273 parser.add_option('--known-good-rev', type="string",
274 metavar="known_good_rev",
275 help=("Automatically bisect any failures using this "
276 "revision as a known-good revision."))
273
277
274 for option, (envvar, default) in defaults.items():
278 for option, (envvar, default) in defaults.items():
275 defaults[option] = type(default)(os.environ.get(envvar, default))
279 defaults[option] = type(default)(os.environ.get(envvar, default))
@@ -1812,6 +1816,40 b' class TextTestRunner(unittest.TextTestRu'
1812 self._runner._checkhglib('Tested')
1816 self._runner._checkhglib('Tested')
1813
1817
1814 savetimes(self._runner._testdir, result)
1818 savetimes(self._runner._testdir, result)
1819
1820 if failed and self._runner.options.known_good_rev:
1821 def nooutput(args):
1822 p = subprocess.Popen(args, stderr=subprocess.STDOUT,
1823 stdout=subprocess.PIPE)
1824 p.stdout.read()
1825 p.wait()
1826 for test, msg in result.failures:
1827 nooutput(['hg', 'bisect', '--reset']),
1828 nooutput(['hg', 'bisect', '--bad', '.'])
1829 nooutput(['hg', 'bisect', '--good',
1830 self._runner.options.known_good_rev])
1831 # TODO: we probably need to forward some options
1832 # that alter hg's behavior inside the tests.
1833 rtc = '%s %s %s' % (sys.executable, sys.argv[0], test)
1834 sub = subprocess.Popen(['hg', 'bisect', '--command', rtc],
1835 stderr=subprocess.STDOUT,
1836 stdout=subprocess.PIPE)
1837 data = sub.stdout.read()
1838 sub.wait()
1839 m = re.search(
1840 (r'\nThe first (?P<goodbad>bad|good) revision '
1841 r'is:\nchangeset: +\d:(?P<node>[a-f0-9]+)\n.*\n'
1842 r'summary: +(?P<summary>[^\n]+)\n'),
1843 data, (re.MULTILINE | re.DOTALL))
1844 if m is None:
1845 self.stream.writeln(
1846 'Failed to identify failure point for %s' % test)
1847 continue
1848 dat = m.groupdict()
1849 verb = 'broken' if dat['goodbad'] == 'bad' else 'fixed'
1850 self.stream.writeln(
1851 '%s %s by %s (%s)' % (
1852 test, verb, dat['node'], dat['summary']))
1815 self.stream.writeln(
1853 self.stream.writeln(
1816 '# Ran %d tests, %d skipped, %d warned, %d failed.'
1854 '# Ran %d tests, %d skipped, %d warned, %d failed.'
1817 % (result.testsRun,
1855 % (result.testsRun,
@@ -758,3 +758,36 b' support for running a test outside the c'
758 $ rt nonlocal/test-is-not-here.t
758 $ rt nonlocal/test-is-not-here.t
759 .
759 .
760 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
760 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
761
762 support for bisecting failed tests automatically
763 $ hg init bisect
764 $ cd bisect
765 $ cat >> test-bisect.t <<EOF
766 > $ echo pass
767 > pass
768 > EOF
769 $ hg add test-bisect.t
770 $ hg ci -m 'good'
771 $ cat >> test-bisect.t <<EOF
772 > $ echo pass
773 > fail
774 > EOF
775 $ hg ci -m 'bad'
776 $ rt --known-good-rev=0 test-bisect.t
777
778 --- $TESTTMP/anothertests/bisect/test-bisect.t
779 +++ $TESTTMP/anothertests/bisect/test-bisect.t.err
780 @@ -1,4 +1,4 @@
781 $ echo pass
782 pass
783 $ echo pass
784 - fail
785 + pass
786
787 ERROR: test-bisect.t output changed
788 !
789 Failed test-bisect.t: output changed
790 test-bisect.t broken by 72cbf122d116 (bad)
791 # Ran 1 tests, 0 skipped, 0 warned, 1 failed.
792 python hash seed: * (glob)
793 [1]
General Comments 0
You need to be logged in to leave comments. Login now