From abcaf7c222c9e74774f7f5396e16cac40774c236 Mon Sep 17 00:00:00 2001 From: Hemmo Nieminen Date: Sun, 10 Sep 2017 10:15:50 +0300 Subject: [PATCH] Namespace test setups. Use $project_name:$test_setup namespace scheme for test setups. This allows one to choose from which (sub)project a test setup is taken from should there be several sharing the same name. Defaults to the main project. E.g. "meson test --setup subproj:valgrind". --- mesonbuild/interpreter.py | 16 +++++++--------- mesonbuild/mtest.py | 9 +++++---- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index c937a5ad7..0ef1587b5 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2892,8 +2892,10 @@ different subdirectory. if len(args) != 1: raise InterpreterException('Add_test_setup needs one argument for the setup name.') setup_name = args[0] - if re.fullmatch('[_a-zA-Z][_0-9a-zA-Z]*', setup_name) is None: + if re.fullmatch('([_a-zA-Z][_0-9a-zA-Z]*:)?[_a-zA-Z][_0-9a-zA-Z]*', setup_name) is None: raise InterpreterException('Setup name may only contain alphanumeric characters.') + if ":" not in setup_name: + setup_name = (self.subproject if self.subproject else self.build.project_name) + ":" + setup_name try: inp = extract_as_list(kwargs, 'exe_wrapper') exe_wrapper = [] @@ -2917,14 +2919,10 @@ different subdirectory. if not isinstance(timeout_multiplier, int): raise InterpreterException('Timeout multiplier must be a number.') env = self.unpack_env_kwarg(kwargs) - setupobj = build.TestSetup(exe_wrapper=exe_wrapper, - gdb=gdb, - timeout_multiplier=timeout_multiplier, - env=env) - if self.subproject == '': - # Dunno what we should do with subprojects really. Let's start simple - # and just use the master project ones. - self.build.test_setups[setup_name] = setupobj + self.build.test_setups[setup_name] = build.TestSetup(exe_wrapper=exe_wrapper, + gdb=gdb, + timeout_multiplier=timeout_multiplier, + env=env) @permittedKwargs(permitted_kwargs['add_global_arguments']) @stringArgs diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index a6971063b..8480e3d69 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -446,7 +446,7 @@ TIMEOUT: %4d if self.options.wrapper: namebase = os.path.basename(self.get_wrapper()[0]) elif self.options.setup: - namebase = self.options.setup + namebase = self.options.setup.replace(":", "_") if namebase: logfile_base += '-' + namebase.replace(' ', '_') @@ -553,10 +553,11 @@ def merge_suite_options(options): buildfile = os.path.join(options.wd, 'meson-private/build.dat') with open(buildfile, 'rb') as f: build = pickle.load(f) - setups = build.test_setups - if options.setup not in setups: + if ":" not in options.setup: + options.setup = (build.subproject if build.subproject else build.project_name) + ":" + options.setup + if options.setup not in build.test_setups: sys.exit('Unknown test setup: %s' % options.setup) - current = setups[options.setup] + current = build.test_setups[options.setup] if not options.gdb: options.gdb = current.gdb if options.timeout_multiplier is None: