tests: Simplify customization of %ENV

Rather than having an %extraENV that is added to the default %ENV
and resetting %ENV _before_ each test, allow the test setup to
modify %ENV directly as needed then reset %ENV _after_ each test.

* tests/test_driver.pl: Remove unused %extraENV.
(resetENV): Don't add in %extraENV.
(_run_command): Reset after we run the command rather than before.
* tests/scripts/features/export: Convert %extraENV to %ENV
* tests/scripts/features/jobserver: Ditto
* tests/scripts/features/parallelism: Ditto
* tests/scripts/features/targetvars: Ditto
* tests/scripts/functions/eval: Ditto
* tests/scripts/functions/foreach: Ditto
* tests/scripts/functions/origin: Ditto
* tests/scripts/misc/general4: Ditto
* tests/scripts/options/dash-e: Ditto
* tests/scripts/targets/POSIX: Ditto
* tests/scripts/variables/GNUMAKEFLAGS: Ditto
* tests/scripts/variables/SHELL: Ditto
This commit is contained in:
Paul Smith
2020-04-01 01:58:33 -04:00
parent 289108cc9b
commit f79bde1a6d
13 changed files with 49 additions and 73 deletions

View File

@@ -127,7 +127,7 @@ EOF
close(MAKEFILE);
$extraENV{EVAR} = '1';
$ENV{EVAR} = '1';
&run_make_with_options($makefile4, "", &get_logfile);
$answer = "OK\n";
&compare_output($answer,&get_logfile(1));

View File

@@ -14,7 +14,7 @@ types of foreach loops are tested\n";
# TEST 0
# Set an environment variable that we can test in the makefile.
$extraENV{FOOFOO} = 'foo foo';
$ENV{FOOFOO} = 'foo foo';
run_make_test("space = ' '".'
null :=
@@ -31,8 +31,6 @@ for2: ; @echo $(fe)',
"undefined file default file environment default file command line override automatic automatic
foo.o bletch.o null.o @.o garf.o .o .o undefined.o file.o default.o file.o environment.o default.o file.o command.o line.o override.o automatic.o automatic.o");
delete $extraENV{FOOFOO};
# TEST 1: Test that foreach variables take precedence over global
# variables in a global scope (like inside an eval). Tests bug #11913

View File

@@ -16,26 +16,27 @@ defined per the following list:
'automatic' Automatic variable\n";
# Set an environment variable
$extraENV{MAKETEST} = 1;
$ENV{MAKETEST} = 1;
run_make_test('
foo := bletch garf
auto_var = undefined CC MAKETEST MAKE foo CFLAGS WHITE @
av = $(foreach var, $(auto_var), $(origin $(var)) )
override WHITE := BLACK
.RECIPEPREFIX = >
all: auto
@echo $(origin undefined)
@echo $(origin CC)
@echo $(origin MAKETEST)
@echo $(origin MAKE)
@echo $(origin foo)
@echo $(origin CFLAGS)
@echo $(origin WHITE)
@echo $(origin @)
> @echo $(origin undefined)
> @echo $(origin CC)
> @echo $(origin MAKETEST)
> @echo $(origin MAKE)
> @echo $(origin foo)
> @echo $(origin CFLAGS)
> @echo $(origin WHITE)
> @echo $(origin @)
auto :
@echo $(av)',
'-e WHITE=WHITE CFLAGS=',
'undefined default environment default file command line override automatic
> @echo $(av)',
'-e WHITE=WHITE CFLAGS=',
'undefined default environment default file command line override automatic
undefined
default
environment
@@ -45,7 +46,4 @@ command line
override
automatic');
# Reset an environment variable
delete $extraENV{MAKETEST};
1;