aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-01-11 19:30:11 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2017-01-15 21:54:26 +0200
commit11f9425a5e123e7e4bb6296f4453a8e072eb95ed (patch)
treea20c91ddb92438ca27eba83b5ed8b73f6b839c24
parentcfc33ac4212cb59b4ace3d3f404227366ffa5daf (diff)
downloadmeson-11f9425a5e123e7e4bb6296f4453a8e072eb95ed.zip
meson-11f9425a5e123e7e4bb6296f4453a8e072eb95ed.tar.gz
meson-11f9425a5e123e7e4bb6296f4453a8e072eb95ed.tar.bz2
Can use targets directly in test arguments.
-rw-r--r--mesonbuild/backend/backends.py10
-rw-r--r--mesonbuild/interpreter.py12
-rw-r--r--test cases/common/125 shared module/meson.build2
3 files changed, 18 insertions, 6 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index 16cb041..56c786b 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -432,9 +432,17 @@ class Backend():
extra_paths = []
cmd_args = []
for a in t.cmd_args:
+ if hasattr(a, 'held_object'):
+ a = a.held_object
if isinstance(a, mesonlib.File):
a = os.path.join(self.environment.get_build_dir(), a.rel_to_builddir(self.build_to_src))
- cmd_args.append(a)
+ cmd_args.append(a)
+ elif isinstance(a, str):
+ cmd_args.append(a)
+ elif isinstance(a, build.Target):
+ cmd_args.append(self.get_target_filename(a))
+ else:
+ raise MesonException('Bad object in test command.')
ts = TestSerialisation(t.get_name(), t.suite, fname, is_cross, exe_wrapper,
t.is_parallel, cmd_args, t.env, t.should_fail,
t.timeout, t.workdir, extra_paths)
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 407507a..35adc59 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -495,7 +495,11 @@ class GeneratedObjectsHolder(InterpreterObject):
super().__init__()
self.held_object = held_object
-class BuildTargetHolder(InterpreterObject):
+class TargetHolder(InterpreterObject):
+ def __init__(self):
+ super().__init__()
+
+class BuildTargetHolder(TargetHolder):
def __init__(self, target, interp):
super().__init__()
self.held_object = target
@@ -557,7 +561,7 @@ class JarHolder(BuildTargetHolder):
def __init__(self, target, interp):
super().__init__(target, interp)
-class CustomTargetHolder(InterpreterObject):
+class CustomTargetHolder(TargetHolder):
def __init__(self, object_to_hold, interp):
super().__init__()
self.held_object = object_to_hold
@@ -2063,8 +2067,8 @@ requirements use the version keyword argument instead.''')
if not isinstance(cmd_args, list):
cmd_args = [cmd_args]
for i in cmd_args:
- if not isinstance(i, (str, mesonlib.File)):
- raise InterpreterException('Command line arguments must be strings')
+ if not isinstance(i, (str, mesonlib.File, TargetHolder)):
+ raise InterpreterException('Command line arguments must be strings, files or targets.')
env = self.unpack_env_kwarg(kwargs)
should_fail = kwargs.get('should_fail', False)
if not isinstance(should_fail, bool):
diff --git a/test cases/common/125 shared module/meson.build b/test cases/common/125 shared module/meson.build
index 6fd21c2..7c15bcc 100644
--- a/test cases/common/125 shared module/meson.build
+++ b/test cases/common/125 shared module/meson.build
@@ -8,5 +8,5 @@ l = shared_library('runtime', 'runtime.c')
# at runtime
m = shared_module('mymodule', 'module.c')
e = executable('prog', 'prog.c', link_with : l, dependencies : dl)
-test('import test', e, args : [m.full_path()])
+test('import test', e, args : m)