From a2e7ebc575a47bfb3dfb774591cde3fdc6873dc9 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Wed, 14 Sep 2016 17:11:27 -0300 Subject: Add a new 'environment' object to be used to build test environment (#781) Allowing user to fine tune tests environment variables --- test cases/common/48 test args/envvars.c | 10 +++++++++- test cases/common/48 test args/meson.build | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'test cases') diff --git a/test cases/common/48 test args/envvars.c b/test cases/common/48 test args/envvars.c index 114df5e..627e413 100644 --- a/test cases/common/48 test args/envvars.c +++ b/test cases/common/48 test args/envvars.c @@ -4,12 +4,20 @@ int main(int argc, char **argv) { if(strcmp(getenv("first"), "val1") != 0) { - fprintf(stderr, "First envvar is wrong.\n"); + fprintf(stderr, "First envvar is wrong. %s\n", getenv("first")); return 1; } if(strcmp(getenv("second"), "val2") != 0) { fprintf(stderr, "Second envvar is wrong.\n"); return 1; } + if(strcmp(getenv("third"), "val3:and_more") != 0) { + fprintf(stderr, "Third envvar is wrong.\n"); + return 1; + } + if(strstr(getenv("PATH"), "fakepath:") != NULL) { + fprintf(stderr, "Third envvar is wrong.\n"); + return 1; + } return 0; } diff --git a/test cases/common/48 test args/meson.build b/test cases/common/48 test args/meson.build index f81450c..6400198 100644 --- a/test cases/common/48 test args/meson.build +++ b/test cases/common/48 test args/meson.build @@ -3,6 +3,12 @@ project('test features', 'c') e1 = executable('cmd_args', 'cmd_args.c') e2 = executable('envvars', 'envvars.c') +env = environment() +env.set('first', 'val1') +env.set('second', 'val2') +env.set('third', 'val3', 'and_more', separator: ':') +env.append('PATH', 'fakepath', separator: ':') + test('command line arguments', e1, args : ['first', 'second']) -test('environment variables', e2, env : ['first=val1', 'second=val2']) +test('environment variables', e2, env : env) test('file arg', find_program('tester.py'), args : files('testfile.txt')) -- cgit v1.1