aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2017-09-07 16:05:45 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2017-09-10 17:41:37 +0530
commitaff981a6b0362eeb4b51f9c6cd424f4233953976 (patch)
treed93e11c204da3c167aa151235680c476d0bb050f
parent21e2315afd90e844963ca1c982ba70a4e001efaf (diff)
downloadmeson-aff981a6b0362eeb4b51f9c6cd424f4233953976.zip
meson-aff981a6b0362eeb4b51f9c6cd424f4233953976.tar.gz
meson-aff981a6b0362eeb4b51f9c6cd424f4233953976.tar.bz2
Fix regression in test definitions
Caused by #2236. Also add a test for this.
-rw-r--r--mesonbuild/interpreter.py3
-rw-r--r--test cases/common/48 test args/copyfile.py6
-rw-r--r--test cases/common/48 test args/meson.build16
-rw-r--r--test cases/common/48 test args/tester.c34
4 files changed, 57 insertions, 2 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 23f5907..2bcf198 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2335,6 +2335,7 @@ class Interpreter(InterpreterBase):
else:
if not isinstance(envlist, list):
envlist = [envlist]
+ # Convert from array to environment object
env = EnvironmentVariablesHolder()
for e in envlist:
if '=' not in e:
@@ -2344,7 +2345,7 @@ class Interpreter(InterpreterBase):
val = val.strip()
if ' ' in k:
raise InterpreterException('Env var key must not have spaces in it.')
- env.add_var(env.held_object.set, [k, val], kwargs)
+ env.set_method([k, val], {})
env = env.held_object
return env
diff --git a/test cases/common/48 test args/copyfile.py b/test cases/common/48 test args/copyfile.py
new file mode 100644
index 0000000..ff42ac3
--- /dev/null
+++ b/test cases/common/48 test args/copyfile.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python3
+
+import sys
+import shutil
+
+shutil.copyfile(sys.argv[1], sys.argv[2])
diff --git a/test cases/common/48 test args/meson.build b/test cases/common/48 test args/meson.build
index f599bf7..81d3491 100644
--- a/test cases/common/48 test args/meson.build
+++ b/test cases/common/48 test args/meson.build
@@ -18,4 +18,18 @@ env2.set('first', 'something-else')
test('command line arguments', e1, args : ['first', 'second'])
test('environment variables', e2, env : env)
test('environment variables 2', e3, env : env2)
-test('file arg', find_program('tester.py'), args : files('testfile.txt'))
+
+# https://github.com/mesonbuild/meson/issues/2211#issuecomment-327741571
+env_array = ['MESONTESTING=picklerror']
+testfile = files('testfile.txt')
+testerpy = find_program('tester.py')
+test('file arg', testerpy, args : testfile, env : env_array)
+
+copy = find_program('copyfile.py')
+tester = executable('tester', 'tester.c')
+testfilect = custom_target('testfile',
+ input : testfile,
+ output : 'outfile.txt',
+ build_by_default : true,
+ command : [copy, '@INPUT@', '@OUTPUT@'])
+test('custom target arg', tester, args : testfilect, env : env_array)
diff --git a/test cases/common/48 test args/tester.c b/test cases/common/48 test args/tester.c
new file mode 100644
index 0000000..28aa0db
--- /dev/null
+++ b/test cases/common/48 test args/tester.c
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#ifndef _MSC_VER
+#include <unistd.h>
+#endif
+
+int main(int argc, char **argv) {
+ char data[10];
+ int fd, size;
+
+ if (argc != 2) {
+ fprintf(stderr, "Incorrect number of arguments, got %i\n", argc);
+ return 1;
+ }
+ fd = open(argv[1], O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "First argument is wrong.\n");
+ return 1;
+ }
+
+ size = read(fd, data, 10);
+ if (size < 0) {
+ fprintf(stderr, "Failed to read: %s\n", strerror(errno));
+ return 1;
+ }
+ if (strcmp(data, "contents\n") != 0) {
+ fprintf(stderr, "Contents don't match, got %s\n", data);
+ return 1;
+ }
+ return 0;
+}