aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2015-08-21 22:11:26 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2015-08-21 22:11:26 +0300
commit24d23c3086afe687cc93b26a07f504902f4a0b02 (patch)
tree39ae2dbf27d898118fecf17d0bc502d80c7eb2bb
parentcd38e793018c2af2344e74d22fc1c672c325b399 (diff)
downloadmeson-24d23c3086afe687cc93b26a07f504902f4a0b02.zip
meson-24d23c3086afe687cc93b26a07f504902f4a0b02.tar.gz
meson-24d23c3086afe687cc93b26a07f504902f4a0b02.tar.bz2
Can add file objects to command line arguments. Closes #235.
-rw-r--r--backends.py7
-rw-r--r--interpreter.py2
-rw-r--r--test cases/common/48 test args/meson.build1
-rwxr-xr-xtest cases/common/48 test args/tester.py6
-rw-r--r--test cases/common/48 test args/testfile.txt1
5 files changed, 15 insertions, 2 deletions
diff --git a/backends.py b/backends.py
index 760bc52..05e4429 100644
--- a/backends.py
+++ b/backends.py
@@ -267,8 +267,13 @@ class Backend():
extra_paths = self.determine_windows_extra_paths(exe)
else:
extra_paths = []
+ cmd_args = []
+ for a in t.cmd_args:
+ 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)
ts = TestSerialisation(t.get_name(), fname, is_cross, exe_wrapper,
- t.is_parallel, t.cmd_args, t.env, t.should_fail, t.valgrind_args,
+ t.is_parallel, cmd_args, t.env, t.should_fail, t.valgrind_args,
t.timeout, extra_paths)
arr.append(ts)
pickle.dump(arr, datafile)
diff --git a/interpreter.py b/interpreter.py
index 76964a6..bc2f6f3 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -1467,7 +1467,7 @@ class Interpreter():
if not isinstance(cmd_args, list):
cmd_args = [cmd_args]
for i in cmd_args:
- if not isinstance(i, str):
+ if not isinstance(i, (str, mesonlib.File)):
raise InterpreterException('Command line arguments must be strings')
envlist = kwargs.get('env', [])
if not isinstance(envlist, list):
diff --git a/test cases/common/48 test args/meson.build b/test cases/common/48 test args/meson.build
index 1243c21..f81450c 100644
--- a/test cases/common/48 test args/meson.build
+++ b/test cases/common/48 test args/meson.build
@@ -5,3 +5,4 @@ e2 = executable('envvars', 'envvars.c')
test('command line arguments', e1, args : ['first', 'second'])
test('environment variables', e2, env : ['first=val1', 'second=val2'])
+test('file arg', find_program('tester.py'), args : files('testfile.txt'))
diff --git a/test cases/common/48 test args/tester.py b/test cases/common/48 test args/tester.py
new file mode 100755
index 0000000..36e510d
--- /dev/null
+++ b/test cases/common/48 test args/tester.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python3
+
+import sys
+
+if open(sys.argv[1]).read() != 'contents\n':
+ sys.exit(1)
diff --git a/test cases/common/48 test args/testfile.txt b/test cases/common/48 test args/testfile.txt
new file mode 100644
index 0000000..12f00e9
--- /dev/null
+++ b/test cases/common/48 test args/testfile.txt
@@ -0,0 +1 @@
+contents