diff options
author | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2017-07-09 23:25:02 -0400 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-07-15 10:04:55 +0200 |
commit | 5d1e35fa0153cb40428d67ae6553d33b25e01ff8 (patch) | |
tree | 0c7c8baab59239e82260161214eff432280dc82b /mesontest.py | |
parent | 39c7b0492c078a159def3e11443b8f7174eeca2e (diff) | |
download | meson-5d1e35fa0153cb40428d67ae6553d33b25e01ff8.zip meson-5d1e35fa0153cb40428d67ae6553d33b25e01ff8.tar.gz meson-5d1e35fa0153cb40428d67ae6553d33b25e01ff8.tar.bz2 |
Print real error if mesontest used on invalid directory.
Diffstat (limited to 'mesontest.py')
-rwxr-xr-x | mesontest.py | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/mesontest.py b/mesontest.py index 8325e69..62ca4b2 100755 --- a/mesontest.py +++ b/mesontest.py @@ -22,6 +22,7 @@ import pickle from mesonbuild import build from mesonbuild import environment from mesonbuild.dependencies import ExternalProgram +from mesonbuild import mesonlib from mesonbuild import mlog import time, datetime, multiprocessing, json @@ -101,6 +102,11 @@ parser.add_argument('--test-args', default=[], type=shlex.split, parser.add_argument('args', nargs='*', help='Optional list of tests to run') + +class TestException(mesonlib.MesonException): + pass + + class TestRun: def __init__(self, res, returncode, should_fail, duration, stdo, stde, cmd, env): @@ -172,9 +178,12 @@ class TestHarness: self.tests = None self.suites = None if self.options.benchmark: - self.load_datafile(os.path.join(options.wd, 'meson-private', 'meson_benchmark_setup.dat')) + datafile = os.path.join(options.wd, 'meson-private', 'meson_benchmark_setup.dat') else: - self.load_datafile(os.path.join(options.wd, 'meson-private', 'meson_test_setup.dat')) + datafile = os.path.join(options.wd, 'meson-private', 'meson_test_setup.dat') + if not os.path.isfile(datafile): + raise TestException('Directory %s does not seem to be a Meson build directory.' % options.wd) + self.load_datafile(datafile) def run_single_test(self, wrap, test): if test.fname[0].endswith('.jar'): @@ -604,13 +613,18 @@ def run(args): if not rebuild_all(options.wd): sys.exit(-1) - th = TestHarness(options) - if options.list: - list_tests(th) - return 0 - if not options.args: - return th.doit() - return th.run_special() + try: + th = TestHarness(options) + if options.list: + list_tests(th) + return 0 + if not options.args: + return th.doit() + return th.run_special() + except TestException as e: + print('Mesontest encountered an error:\n') + print(e) + return 1 if __name__ == '__main__': sys.exit(run(sys.argv[1:])) |