##// END OF EJS Templates
run-tests: move bisect logic to a separate method...
Jun Wu -
r34803:9c7548eb default
parent child Browse files
Show More
@@ -2085,47 +2085,7 b' class TextTestRunner(unittest.TextTestRu'
2085 savetimes(self._runner._outputdir, result)
2085 savetimes(self._runner._outputdir, result)
2086
2086
2087 if failed and self._runner.options.known_good_rev:
2087 if failed and self._runner.options.known_good_rev:
2088 bisectcmd = ['hg', 'bisect']
2088 self._bisecttests(t for t, m in result.failures)
2089 bisectrepo = self._runner.options.bisect_repo
2090 if bisectrepo:
2091 bisectcmd.extend(['-R', os.path.abspath(bisectrepo)])
2092 def nooutput(args):
2093 p = subprocess.Popen(args, stderr=subprocess.STDOUT,
2094 stdout=subprocess.PIPE)
2095 p.stdout.read()
2096 p.wait()
2097 for test, msg in result.failures:
2098 nooutput(bisectcmd + ['--reset']),
2099 nooutput(bisectcmd + ['--bad', '.'])
2100 nooutput(bisectcmd + ['--good',
2101 self._runner.options.known_good_rev])
2102 # TODO: we probably need to forward more options
2103 # that alter hg's behavior inside the tests.
2104 opts = ''
2105 withhg = self._runner.options.with_hg
2106 if withhg:
2107 opts += ' --with-hg=%s ' % shellquote(_strpath(withhg))
2108 rtc = '%s %s %s %s' % (sys.executable, sys.argv[0], opts,
2109 test)
2110 sub = subprocess.Popen(bisectcmd + ['--command', rtc],
2111 stderr=subprocess.STDOUT,
2112 stdout=subprocess.PIPE)
2113 data = sub.stdout.read()
2114 sub.wait()
2115 m = re.search(
2116 (br'\nThe first (?P<goodbad>bad|good) revision '
2117 br'is:\nchangeset: +\d+:(?P<node>[a-f0-9]+)\n.*\n'
2118 br'summary: +(?P<summary>[^\n]+)\n'),
2119 data, (re.MULTILINE | re.DOTALL))
2120 if m is None:
2121 self.stream.writeln(
2122 'Failed to identify failure point for %s' % test)
2123 continue
2124 dat = m.groupdict()
2125 verb = 'broken' if dat['goodbad'] == 'bad' else 'fixed'
2126 self.stream.writeln(
2127 '%s %s by %s (%s)' % (
2128 test, verb, dat['node'], dat['summary']))
2129 self.stream.writeln(
2089 self.stream.writeln(
2130 '# Ran %d tests, %d skipped, %d failed.'
2090 '# Ran %d tests, %d skipped, %d failed.'
2131 % (result.testsRun, skipped + ignored, failed))
2091 % (result.testsRun, skipped + ignored, failed))
@@ -2138,6 +2098,49 b' class TextTestRunner(unittest.TextTestRu'
2138
2098
2139 return result
2099 return result
2140
2100
2101 def _bisecttests(self, tests):
2102 bisectcmd = ['hg', 'bisect']
2103 bisectrepo = self._runner.options.bisect_repo
2104 if bisectrepo:
2105 bisectcmd.extend(['-R', os.path.abspath(bisectrepo)])
2106 def nooutput(args):
2107 p = subprocess.Popen(args, stderr=subprocess.STDOUT,
2108 stdout=subprocess.PIPE)
2109 p.stdout.read()
2110 p.wait()
2111 for test in tests:
2112 nooutput(bisectcmd + ['--reset']),
2113 nooutput(bisectcmd + ['--bad', '.'])
2114 nooutput(bisectcmd + ['--good',
2115 self._runner.options.known_good_rev])
2116 # TODO: we probably need to forward more options
2117 # that alter hg's behavior inside the tests.
2118 opts = ''
2119 withhg = self._runner.options.with_hg
2120 if withhg:
2121 opts += ' --with-hg=%s ' % shellquote(_strpath(withhg))
2122 rtc = '%s %s %s %s' % (sys.executable, sys.argv[0], opts,
2123 test)
2124 sub = subprocess.Popen(bisectcmd + ['--command', rtc],
2125 stderr=subprocess.STDOUT,
2126 stdout=subprocess.PIPE)
2127 data = sub.stdout.read()
2128 sub.wait()
2129 m = re.search(
2130 (br'\nThe first (?P<goodbad>bad|good) revision '
2131 br'is:\nchangeset: +\d+:(?P<node>[a-f0-9]+)\n.*\n'
2132 br'summary: +(?P<summary>[^\n]+)\n'),
2133 data, (re.MULTILINE | re.DOTALL))
2134 if m is None:
2135 self.stream.writeln(
2136 'Failed to identify failure point for %s' % test)
2137 continue
2138 dat = m.groupdict()
2139 verb = 'broken' if dat['goodbad'] == 'bad' else 'fixed'
2140 self.stream.writeln(
2141 '%s %s by %s (%s)' % (
2142 test, verb, dat['node'], dat['summary']))
2143
2141 def printtimes(self, times):
2144 def printtimes(self, times):
2142 # iolock held by run
2145 # iolock held by run
2143 self.stream.writeln('# Producing time report')
2146 self.stream.writeln('# Producing time report')
General Comments 0
You need to be logged in to leave comments. Login now