aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/backend/ninjabackend.py5
-rwxr-xr-xmesontest.py88
2 files changed, 48 insertions, 45 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 8f64db9..00a09fc 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -710,7 +710,7 @@ int dummy;
d.install_subdirs.append([src_dir, inst_dir, dst_dir])
def generate_tests(self, outfile):
- (test_data, benchmark_data) = self.serialise_tests()
+ self.serialise_tests()
meson_exe = self.environment.get_build_command()
(base, ext) = os.path.splitext(meson_exe)
test_exe = base + 'test' + ext
@@ -719,7 +719,6 @@ int dummy;
cmd += ['--no-stdsplit']
if self.environment.coredata.get_builtin_option('errorlogs'):
cmd += ['--print-errorlogs']
- cmd += [ test_data ]
elem = NinjaBuildElement(self.all_outputs, 'test', 'CUSTOM_COMMAND', ['all', 'PHONY'])
elem.add_item('COMMAND', cmd)
elem.add_item('DESC', 'Running all tests.')
@@ -728,7 +727,7 @@ int dummy;
# And then benchmarks.
cmd = [sys.executable, test_exe, '--benchmark','--logbase',
- 'benchmarklog', '--num-processes=1', benchmark_data]
+ 'benchmarklog', '--num-processes=1']
elem = NinjaBuildElement(self.all_outputs, 'benchmark', 'CUSTOM_COMMAND', ['all', 'PHONY'])
elem.add_item('COMMAND', cmd)
elem.add_item('DESC', 'Running benchmark suite.')
diff --git a/mesontest.py b/mesontest.py
index 135d463..04f72df 100755
--- a/mesontest.py
+++ b/mesontest.py
@@ -135,6 +135,10 @@ class TestHarness:
self.collected_logs = []
self.error_count = 0
self.is_run = False
+ if self.options.benchmark:
+ self.datafile = 'meson-private/meson_benchmark_setup.dat'
+ else:
+ self.datafile = 'meson-private/meson_test_setup.dat'
def run_single_test(self, wrap, test):
if test.fname[0].endswith('.jar'):
@@ -222,14 +226,13 @@ class TestHarness:
write_json_log(jsonlogfile, name, result)
def doit(self):
- if self.options.benchmark:
- datafile = 'meson-private/meson_benchmark_setup.dat'
- else:
- datafile = 'meson-private/meson_test_setup.dat'
if self.is_run:
raise RuntimeError('Test harness object can only be used once.')
+ if not os.path.isfile(self.datafile):
+ print('Test data file. Probably this means that you did not run this in the build directory.')
+ return 1
self.is_run = True
- logfilename = self.run_tests(datafile, self.options.logbase)
+ logfilename = self.run_tests(self.datafile, self.options.logbase)
if len(self.collected_logs) > 0:
if len(self.collected_logs) > 10:
print('\nThe output from 10 first failed tests:\n')
@@ -299,6 +302,41 @@ class TestHarness:
(result, numlen, tests, name, i, logfile, jsonlogfile) = i
self.print_stats(numlen, tests, name, result.result(), i, logfile, jsonlogfile)
+ def run_special(self):
+ 'Tests run by the user, usually something like "under gdb 1000 times".'
+ if self.is_run:
+ raise RuntimeError('Can not use run_special after a full run.')
+ if self.options.wrapper is not None:
+ wrap = self.options.wrapper.split(' ')
+ else:
+ wrap = []
+ if self.options.gdb and len(wrap) > 0:
+ print('Can not specify both a wrapper and gdb.')
+ return 1
+ if os.path.isfile('build.ninja'):
+ subprocess.check_call([environment.detect_ninja(), 'all'])
+ tests = pickle.load(open(self.datafile, 'rb'))
+ if self.options.list:
+ for i in tests:
+ print(i.name)
+ return 0
+ for t in tests:
+ if t.name in self.options.args:
+ for i in range(self.options.repeat):
+ print('Running: %s %d/%d' % (t.name, i+1, self.options.repeat))
+ if self.options.gdb:
+ gdbrun(t)
+ else:
+ res = self.run_single_test(wrap, t)
+ if (res.returncode == 0 and res.should_fail) or \
+ (res.returncode != 0 and not res.should_fail):
+ print('Test failed:\n\n-- stdout --\n')
+ print(res.stdo)
+ print('\n-- stderr --\n')
+ print(res.stde)
+ return 1
+ return 0
+
def filter_tests(suite, tests):
if suite is None:
return tests
@@ -329,43 +367,9 @@ def run(args):
if options.benchmark:
options.num_processes = 1
th = TestHarness(options)
- return th.doit()
- if not os.path.isfile(datafile):
- print('Test data file. Probably this means that you did not run this in the build directory.')
- return 1
- datafile = os.path.join(os.curdir, datafile)
- if os.path.isfile('build.ninja'):
- subprocess.check_call([environment.detect_ninja(), 'all'])
- if options.wd is not None:
- os.chdir(options.wd)
- if len(options.tests) == 0:
- # Run basic tests.
- return meson_test.run(args + ['meson-private/meson_test_setup.dat'])
- if options.wrapper != '':
- wrap = options.wrapper.split(' ')
- else:
- wrap = []
- if options.gdb and len(options.wrapper) > 0:
- print('Can not specify both a wrapper and gdb.')
- return 1
- tests = pickle.load(open(datafile, 'rb'))
- if options.list:
- for i in tests:
- print(i.name)
- return 0
- for t in tests:
- if t.name in options.tests:
- for i in range(options.repeat):
- print('Running: %s %d/%d' % (t.name, i+1, options.repeat))
- if options.gdb:
- gdbrun(t)
- else:
- res = run_single_test(wrap, t)
- if (res.returncode == 0 and res.should_fail) or \
- (res.returncode != 0 and not res.should_fail):
- print(res.stdo)
- print(res.stde)
- raise RuntimeError('Test failed.')
+ if len(options.args) == 0:
+ return th.doit()
+ return th.run_special()
if __name__ == '__main__':
sys.exit(run(sys.argv[1:]))