Fix regression in test definitions
Caused by #2236. Also add a test for this.
This commit is contained in:
parent
21e2315afd
commit
aff981a6b0
|
@ -2335,6 +2335,7 @@ class Interpreter(InterpreterBase):
|
||||||
else:
|
else:
|
||||||
if not isinstance(envlist, list):
|
if not isinstance(envlist, list):
|
||||||
envlist = [envlist]
|
envlist = [envlist]
|
||||||
|
# Convert from array to environment object
|
||||||
env = EnvironmentVariablesHolder()
|
env = EnvironmentVariablesHolder()
|
||||||
for e in envlist:
|
for e in envlist:
|
||||||
if '=' not in e:
|
if '=' not in e:
|
||||||
|
@ -2344,7 +2345,7 @@ class Interpreter(InterpreterBase):
|
||||||
val = val.strip()
|
val = val.strip()
|
||||||
if ' ' in k:
|
if ' ' in k:
|
||||||
raise InterpreterException('Env var key must not have spaces in it.')
|
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
|
env = env.held_object
|
||||||
return env
|
return env
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
shutil.copyfile(sys.argv[1], sys.argv[2])
|
|
@ -18,4 +18,18 @@ env2.set('first', 'something-else')
|
||||||
test('command line arguments', e1, args : ['first', 'second'])
|
test('command line arguments', e1, args : ['first', 'second'])
|
||||||
test('environment variables', e2, env : env)
|
test('environment variables', e2, env : env)
|
||||||
test('environment variables 2', e3, env : env2)
|
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)
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue