diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-09-07 16:05:45 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-09-12 03:26:34 +0530 |
commit | f85d4bb14c6e42ebf839fb79219ac87332f9160c (patch) | |
tree | 4039a320fb2cd1056a6d9f18ed0031fcaf919ed1 | |
parent | 66a5b0c566d7aaffd3d25848537c0f712db9083d (diff) | |
download | meson-f85d4bb14c6e42ebf839fb79219ac87332f9160c.zip meson-f85d4bb14c6e42ebf839fb79219ac87332f9160c.tar.gz meson-f85d4bb14c6e42ebf839fb79219ac87332f9160c.tar.bz2 |
Fix regression in test definitions
Caused by #2236. Also add a test for this.
-rw-r--r-- | mesonbuild/interpreter.py | 3 | ||||
-rw-r--r-- | test cases/common/48 test args/copyfile.py | 6 | ||||
-rw-r--r-- | test cases/common/48 test args/meson.build | 16 | ||||
-rw-r--r-- | test cases/common/48 test args/tester.c | 34 |
4 files changed, 57 insertions, 2 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index c449cc6..733d989 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2283,6 +2283,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: @@ -2292,7 +2293,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; +} |