.EXPORT_ALL_VARIABLES:
endif
+.RECIPEPREFIX := >
all:
- @echo "FOO=$(FOO) BAR=$(BAR) BAZ=$(BAZ) BOZ=$(BOZ) BITZ=$(BITZ) BOTZ=$(BOTZ)"
- @echo "FOO=$$FOO BAR=$$BAR BAZ=$$BAZ BOZ=$$BOZ BITZ=$$BITZ BOTZ=$$BOTZ"
+> @echo "FOO=$(FOO) BAR=$(BAR) BAZ=$(BAZ) BOZ=$(BOZ) BITZ=$(BITZ) BOTZ=$(BOTZ)"
+> @echo "FOO=$$FOO BAR=$$BAR BAZ=$$BAZ BOZ=$$BOZ BITZ=$$BITZ BOTZ=$$BOTZ"
',
'', "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
FOO= BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n");
# TEST 1: make sure vars inherited from the parent are exported
-$extraENV{FOO} = 1;
+$ENV{FOO} = 1;
&run_make_test(undef, '', "FOO=foo BAR=bar BAZ=baz BOZ=boz BITZ=bitz BOTZ=botz
FOO=foo BAR= BAZ=baz BOZ=boz BITZ=bitz BOTZ=\n");
export $(FOO)
export $(B)ar
+.RECIPEPREFIX := >
all:
- @echo foo=$(foo) bar=$(bar)
- @echo foo=$$foo bar=$$bar
+> @echo foo=$(foo) bar=$(bar)
+> @echo foo=$$foo bar=$$bar
',
"", "foo=f-ok bar=b-ok\nfoo=f-ok bar=b-ok\n");
unexport $(FOO)
unexport $(B)ar
+.RECIPEPREFIX := >
all:
- @echo foo=$(foo) bar=$(bar)
- @echo foo=$$foo bar=$$bar
+> @echo foo=$(foo) bar=$(bar)
+> @echo foo=$$foo bar=$$bar
',
'', "foo=f-ok bar=b-ok\nfoo= bar=\n");
# TEST 8: Test unexporting multiple variables on the same line
-@extraENV{qw(A B C D E F G H I J)} = qw(1 2 3 4 5 6 7 8 9 10);
+@args{qw(A B C D E F G H I J)} = qw(1 2 3 4 5 6 7 8 9 10);
+%ENV = (%ENV, %args);
&run_make_test('
A = a
# Setting parallelism with the environment
# Command line should take precedence over the environment
-$extraENV{MAKEFLAGS} = "-j2 $np";
+$ENV{MAKEFLAGS} = "-j2 $np";
run_make_test(q!
SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -f #MAKEFILE# all
all:;@echo $@: "/$(SHOW)/"
!,
'', "recurse: /-j2 --jobserver-auth=<auth> $np/\nall: /-j2 --jobserver-auth=<auth> $np/\n");
-delete $extraENV{MAKEFLAGS};
# Test override of -jN
-$extraENV{MAKEFLAGS} = "-j9 $np";
+$ENV{MAKEFLAGS} = "-j9 $np";
run_make_test(q!
SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -j3 -f #MAKEFILE# recurse2
all:;@echo $@: "/$(SHOW)/"
!,
"-j2 $np", "recurse: /-j2 --jobserver-auth=<auth> $np/\n#MAKE#[1]: warning: -j3 forced in submake: resetting jobserver mode.\nrecurse2: /-j3 --jobserver-auth=<auth> $np/\nall: /-j3 --jobserver-auth=<auth> $np/\n");
-delete $extraENV{MAKEFLAGS};
# Test override of -jN with -j
run_make_test(q!
# TEST #11: Make sure -jN from MAKEFLAGS is processed even when we re-exec
# See Savannah bug #33873
-$extraENV{MAKEFLAGS} = '-j4';
+$ENV{MAKEFLAGS} = '-j4';
run_make_test(q!
things = thing1 thing2
!,
'', "file thing2start\nwait thing2start\nfile thing1start\nwait thing1start\nfile thing2end\nwait thing2end\nthing1end\n");
-delete $extraENV{MAKEFLAGS};
rmfiles(qw(inc.mk thing1start thing1end thing2start thing2end));
# Ensure intermediate/secondary files are not pruned incorrectly.
# Don't use the general PATH if not found on the target path
-$extraENV{PATH} = "$ENV{PATH}:sd";
+$ENV{PATH} = "$ENV{PATH}:sd";
run_make_test(qq!
all: PATH := ..
close(MAKEFILE);
-$extraENV{EVAR} = '1';
+$ENV{EVAR} = '1';
&run_make_with_options($makefile4, "", &get_logfile);
$answer = "OK\n";
&compare_output($answer,&get_logfile(1));
# 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 :=
"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
'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
override
automatic');
-# Reset an environment variable
-delete $extraENV{MAKETEST};
-
1;
# Don't use the general PATH if not found on the target path
-$extraENV{PATH} = "$ENV{PATH}:sd";
+$ENV{PATH} = "$ENV{PATH}:sd";
run_make_test(qq!
PATH := ..
$details = "";
-$extraENV{GOOGLE} = 'boggle';
+$ENV{GOOGLE} = 'boggle';
-open(MAKEFILE,"> $makefile");
-
-print MAKEFILE <<'EOF';
+run_make_test(q!
GOOGLE = bazzle
all:; @echo "$(GOOGLE)"
-EOF
-
-close(MAKEFILE);
-
-&run_make_with_options($makefile, '-e' ,&get_logfile);
-
-$answer = "boggle\n";
-
-&compare_output($answer,&get_logfile(1));
+!,
+ '-e', "boggle\n");
1;
'', $r);
# Make sure that local settings take precedence
-%extraENV = map { $_ => "xx-$_" } keys %POSIX;
+%ENV = (%ENV, map { $_ => "xx-$_" } keys %POSIX);
$r = join('', map { "$_=xx-$_\n"} sort keys %POSIX);
run_make_test(undef, '', $r);
# 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)
# 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)
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
# 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
# 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";
# 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"
# 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
# in recipes
$perl_name =~ tr,\\,/,;
-# %makeENV is the cleaned-out environment.
+# %makeENV is the cleaned-out environment. Tests must not modify it.
%makeENV = ();
-# %extraENV are any extra environment variables the tests might want to set.
-# These are RESET AFTER EVERY TEST!
-%extraENV = ();
-
sub vms_get_process_logicals {
# Sorry for the long note here, but to keep this test running on
# VMS, it is needed to be understood.
}
}
}
-
- foreach $v (keys %extraENV) {
- $ENV{$v} = $extraENV{$v};
- delete $extraENV{$v};
- }
}
sub toplevel
# This runs a command without any debugging info.
sub _run_command
{
- # We reset this before every invocation. On Windows I think there is only
- # one environment, not one per process, so I think that variables set in
- # test scripts might leak into subsequent tests if this isn't reset--???
- resetENV();
-
my $orig = $SIG{ALRM};
my $code = eval { _run_with_timeout(@_); };
$SIG{ALRM} = $orig;
+ # Reset then environment so that it's clean for the next test.
+ resetENV();
+
if ($@) {
# The eval failed. If it wasn't SIGALRM then die.
$@ eq "timeout\n" or die "Command failed: $@";