mesontest: Respect repeat argument even when running testsuites

pull/1128/head
Thibault Saunier 8 years ago
parent 1cb9d2bc0d
commit 3d05b91e37
  1. 68
      mesontest.py

@ -164,6 +164,7 @@ class TestHarness:
else: else:
cmd = test.fname cmd = test.fname
failling = False
if cmd is None: if cmd is None:
res = 'SKIP' res = 'SKIP'
duration = 0.0 duration = 0.0
@ -217,6 +218,7 @@ class TestHarness:
stde = decode(stde) stde = decode(stde)
if timed_out: if timed_out:
res = 'TIMEOUT' res = 'TIMEOUT'
failling = True
if p.returncode == GNU_SKIP_RETURNCODE: if p.returncode == GNU_SKIP_RETURNCODE:
res = 'SKIP' res = 'SKIP'
elif (not test.should_fail and p.returncode == 0) or \ elif (not test.should_fail and p.returncode == 0) or \
@ -224,8 +226,14 @@ class TestHarness:
res = 'OK' res = 'OK'
else: else:
res = 'FAIL' res = 'FAIL'
failling = True
returncode = p.returncode returncode = p.returncode
return TestRun(res, returncode, test.should_fail, duration, stdo, stde, cmd, test.env) result = TestRun(res, returncode, test.should_fail, duration, stdo, stde, cmd, test.env)
if failling:
self.failled_tests.append(result)
return result
def print_stats(self, numlen, tests, name, result, i, logfile, jsonlogfile): def print_stats(self, numlen, tests, name, result, i, logfile, jsonlogfile):
startpad = ' '*(numlen - len('%d' % (i+1))) startpad = ' '*(numlen - len('%d' % (i+1)))
@ -298,27 +306,28 @@ class TestHarness:
logfile.write('Log of Meson test suite run on %s.\n\n' % logfile.write('Log of Meson test suite run on %s.\n\n' %
datetime.datetime.now().isoformat()) datetime.datetime.now().isoformat())
for i, test in enumerate(filtered_tests): for i in range(self.options.repeat):
if test.suite[0] == '': for i, test in enumerate(filtered_tests):
visible_name = test.name if test.suite[0] == '':
else: visible_name = test.name
if self.options.suite is not None:
visible_name = self.options.suite + ' / ' + test.name
else: else:
visible_name = test.suite[0] + ' / ' + test.name if self.options.suite is not None:
visible_name = self.options.suite + ' / ' + test.name
if not test.is_parallel: else:
self.drain_futures(futures) visible_name = test.suite[0] + ' / ' + test.name
futures = []
res = self.run_single_test(wrap, test) if not test.is_parallel:
if not self.options.verbose: self.drain_futures(futures)
self.print_stats(numlen, filtered_tests, visible_name, res, i, futures = []
logfile, jsonlogfile) res = self.run_single_test(wrap, test)
else: if not self.options.verbose:
f = executor.submit(self.run_single_test, wrap, test) self.print_stats(numlen, filtered_tests, visible_name, res, i,
if not self.options.verbose: logfile, jsonlogfile)
futures.append((f, numlen, filtered_tests, visible_name, i, else:
logfile, jsonlogfile)) f = executor.submit(self.run_single_test, wrap, test)
if not self.options.verbose:
futures.append((f, numlen, filtered_tests, visible_name, i,
logfile, jsonlogfile))
self.drain_futures(futures, logfile, jsonlogfile) self.drain_futures(futures, logfile, jsonlogfile)
finally: finally:
if jsonlogfile: if jsonlogfile:
@ -332,8 +341,23 @@ class TestHarness:
def drain_futures(self, futures, logfile, jsonlogfile): def drain_futures(self, futures, logfile, jsonlogfile):
for i in futures: for i in futures:
(result, numlen, tests, name, i, logfile, jsonlogfile) = i (result, numlen, tests, name, i, logfile, jsonlogfile) = i
if not self.options.verbose: if self.options.repeat > 1 and self.failled_tests:
result.cancel()
elif not self.options.verbose:
self.print_stats(numlen, tests, name, result.result(), i, logfile, jsonlogfile) self.print_stats(numlen, tests, name, result.result(), i, logfile, jsonlogfile)
else:
result.result()
if self.options.repeat > 1 and self.failled_tests:
if not self.options.verbose:
for res in self.failled_tests:
print('Test failed:\n\n-- stdout --\n')
print(res.stdo)
print('\n-- stderr --\n')
print(res.stde)
return 1
return
def run_special(self): def run_special(self):
'Tests run by the user, usually something like "under gdb 1000 times".' 'Tests run by the user, usually something like "under gdb 1000 times".'

Loading…
Cancel
Save