diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2017-09-12 00:57:29 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-12 00:57:29 +0300 |
commit | e1fc17ef2a532d539678b9a9378bca59eda38a91 (patch) | |
tree | 6cd294d82898dd942419e82b46cdcee9760914a5 | |
parent | b3c70f495b736ff4ebe4c5097df2a5da0ea1ab80 (diff) | |
parent | 4a9c31025c685edc70ea1eb906ef5bdeb8b7b973 (diff) | |
download | meson-e1fc17ef2a532d539678b9a9378bca59eda38a91.zip meson-e1fc17ef2a532d539678b9a9378bca59eda38a91.tar.gz meson-e1fc17ef2a532d539678b9a9378bca59eda38a91.tar.bz2 |
Merge pull request #2288 from centricular/fix-test-regression
Fix regression in test definitions
-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 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..419277e --- /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, 8); + if (size < 0) { + fprintf(stderr, "Failed to read: %s\n", strerror(errno)); + return 1; + } + if (strncmp(data, "contents", 8) != 0) { + fprintf(stderr, "Contents don't match, got %s\n", data); + return 1; + } + return 0; +} |