mirror of
https://github.com/mirror/make.git
synced 2026-09-05 22:25:00 +08:00
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:
@@ -5,7 +5,7 @@ $description = "Test proper behavior of GNUMAKEFLAGS";
|
||||
# Accept flags from GNUMAKEFLAGS as well as MAKEFLAGS
|
||||
# Results always go in MAKEFLAGS
|
||||
|
||||
$extraENV{'GNUMAKEFLAGS'} = '-e -r -R';
|
||||
$ENV{'GNUMAKEFLAGS'} = '-e -r -R';
|
||||
|
||||
run_make_test(q!
|
||||
all: ; @echo $(MAKEFLAGS)
|
||||
@@ -14,7 +14,7 @@ all: ; @echo $(MAKEFLAGS)
|
||||
|
||||
# Long arguments mean everything is prefixed with "-"
|
||||
|
||||
$extraENV{'GNUMAKEFLAGS'} = '--no-print-directory -e -r -R --trace';
|
||||
$ENV{'GNUMAKEFLAGS'} = '--no-print-directory -e -r -R --trace';
|
||||
|
||||
run_make_test(q!
|
||||
all: ; @echo $(MAKEFLAGS)
|
||||
@@ -27,7 +27,7 @@ erR --trace --no-print-directory");
|
||||
|
||||
unlink('x.mk');
|
||||
|
||||
$extraENV{GNUMAKEFLAGS} = '-Itst/bad';
|
||||
$ENV{GNUMAKEFLAGS} = '-Itst/bad';
|
||||
|
||||
run_make_test(q!
|
||||
recurse: ; @echo $@; echo MAKEFLAGS = $$MAKEFLAGS; echo GNUMAKEFLAGS = $$GNUMAKEFLAGS; #MAKEPATH# -f #MAKEFILE# all
|
||||
|
||||
@@ -14,9 +14,8 @@ $mshell = $sh_name;
|
||||
|
||||
# According to POSIX, the value of SHELL in the environment has no impact on
|
||||
# the value in the makefile.
|
||||
# Note %extraENV takes precedence over the default value for the shell.
|
||||
|
||||
$extraENV{SHELL} = '/dev/null';
|
||||
$ENV{SHELL} = '/dev/null';
|
||||
run_make_test('all:;@echo "$(SHELL)"', '', $mshell);
|
||||
|
||||
# According to POSIX, any value of SHELL set in the makefile should _NOT_ be
|
||||
@@ -25,7 +24,7 @@ run_make_test('all:;@echo "$(SHELL)"', '', $mshell);
|
||||
# all when $(SHELL) is perl :-/. So, we just add an extra initial /./ which
|
||||
# works well on UNIX and seems to work OK on at least some non-UNIX systems.
|
||||
|
||||
$extraENV{SHELL} = $mshell;
|
||||
$ENV{SHELL} = $mshell;
|
||||
|
||||
my $altshell = "/./$mshell";
|
||||
my $altshell2 = "/././$mshell";
|
||||
@@ -41,7 +40,7 @@ all:;@echo "$(SHELL) $$SHELL"
|
||||
# As a GNU make extension, if make's SHELL variable is explicitly exported,
|
||||
# then we really _DO_ export it.
|
||||
|
||||
$extraENV{SHELL} = $mshell;
|
||||
$ENV{SHELL} = $mshell;
|
||||
|
||||
run_make_test("export SHELL := $altshell\n".'
|
||||
all:;@echo "$(SHELL) $$SHELL"
|
||||
@@ -51,13 +50,13 @@ all:;@echo "$(SHELL) $$SHELL"
|
||||
# Test out setting of SHELL, both exported and not, as a target-specific
|
||||
# variable.
|
||||
|
||||
$extraENV{SHELL} = $mshell;
|
||||
$ENV{SHELL} = $mshell;
|
||||
|
||||
run_make_test("all: SHELL := $altshell\n".'
|
||||
all:;@echo "$(SHELL) $$SHELL"
|
||||
', '', "$altshell $mshell");
|
||||
|
||||
$extraENV{SHELL} = $mshell;
|
||||
$ENV{SHELL} = $mshell;
|
||||
|
||||
run_make_test("
|
||||
SHELL := $altshell2
|
||||
|
||||
Reference in New Issue
Block a user