mirror of
https://github.com/mirror/make.git
synced 2024-12-27 13:20:34 +08:00
Avoid using false(1) in regression tests
The POSIX standard only requires false(1) to return a "non-zero" exit code; almost all systems return 1 but some (Solaris!!!) return 255 or possibly even other values. Use our helper "fail" instead. * tests/thelp.pl: Have the "fail" command obey -q. * tests/scripts/features/parallelism: Helper -q no longer prints fail. * tests/scripts/targets/POSIX: Replace false with #HELPER# -q fail 1. * tests/scripts/variables/MAKEFLAGS: Ditto. * tests/scripts/variables/SHELL: Ditto.
This commit is contained in:
parent
937e9aa32d
commit
29f453739f
@ -100,12 +100,12 @@ fail.2: ; @#HELPER# -q sleep 2 out $@ wait fail.1 file fail.2 fail 1
|
||||
fail.3: ; @#HELPER# -q sleep 3 out $@ wait fail.2 file fail.3 fail 1
|
||||
|
||||
ok: ; @#HELPER# -q sleep 4 wait fail.3 out OK!,
|
||||
'-rR -j5', "fail.1\nfail 1
|
||||
'-rR -j5', "fail.1
|
||||
#MAKE#: *** [#MAKEFILE#:5: fail.1] Error 1
|
||||
#MAKE#: *** Waiting for unfinished jobs....
|
||||
fail.2\nfail 1
|
||||
fail.2
|
||||
#MAKE#: *** [#MAKEFILE#:6: fail.2] Error 1
|
||||
fail.3\nfail 1
|
||||
fail.3
|
||||
#MAKE#: *** [#MAKEFILE#:7: fail.3] Error 1
|
||||
OK",
|
||||
512);
|
||||
|
@ -6,30 +6,22 @@ $details = "";
|
||||
|
||||
|
||||
# Ensure turning on .POSIX enables the -e flag for the shell
|
||||
# We can't assume the exit value of "false" because on different systems it's
|
||||
# different.
|
||||
|
||||
my $script = 'false; true';
|
||||
my $flags = '-ec';
|
||||
my $out = `$sh_name $flags '$script' 2>&1`;
|
||||
my $err = $? >> 8;
|
||||
run_make_test(qq!
|
||||
.POSIX:
|
||||
all: ; \@$script
|
||||
all: ; \@#HELPER# -q fail 1; true
|
||||
!,
|
||||
'', "#MAKE#: *** [#MAKEFILE#:3: all] Error $err\n", 512);
|
||||
'', "#MAKE#: *** [#MAKEFILE#:3: all] Error 1\n", 512);
|
||||
|
||||
# User settings must override .POSIX
|
||||
# In the standard .POSIX must be the first thing in the makefile
|
||||
# but we relax that rule in GNU make.
|
||||
$flags = '-xc';
|
||||
$out = `$sh_name $flags '$script' 2>&1`;
|
||||
run_make_test(qq!
|
||||
.SHELLFLAGS = $flags
|
||||
.SHELLFLAGS = -xc
|
||||
.POSIX:
|
||||
all: ; \@$script
|
||||
all: ; \@#HELPER# -q fail 1; true
|
||||
!,
|
||||
'', $out);
|
||||
'', "+ #HELPER# -q fail 1\n+ true\n");
|
||||
|
||||
# Test the default value of various POSIX-specific variables
|
||||
my %POSIX = (AR => 'ar', ARFLAGS => '-rv',
|
||||
|
@ -539,12 +539,12 @@ $(info $(MAKEFLAGS))
|
||||
all: one two
|
||||
one:
|
||||
$(info $(MAKEFLAGS))
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
two:; $(info $@)
|
||||
!, '',
|
||||
"S
|
||||
S
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
#MAKE#: *** [#MAKEFILE#:6: one] Error 1", 512);
|
||||
|
||||
# -S in env, -k on the command line.
|
||||
@ -554,12 +554,12 @@ $(info $(MAKEFLAGS))
|
||||
all: one two
|
||||
one:
|
||||
$(info $(MAKEFLAGS))
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
two:; $(info $@)
|
||||
!, '-k',
|
||||
"k
|
||||
k
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
#MAKE#: *** [#MAKEFILE#:6: one] Error 1
|
||||
two
|
||||
#MAKE#: Target 'all' not remade because of errors.", 512);
|
||||
@ -571,12 +571,12 @@ $(info $(MAKEFLAGS))
|
||||
all: one two
|
||||
one:
|
||||
$(info $(MAKEFLAGS))
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
two:; $(info $@)
|
||||
!, '',
|
||||
"k
|
||||
k
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
#MAKE#: *** [#MAKEFILE#:6: one] Error 1
|
||||
two
|
||||
#MAKE#: Target 'all' not remade because of errors.", 512);
|
||||
@ -588,12 +588,12 @@ $(info $(MAKEFLAGS))
|
||||
all: one two
|
||||
one:
|
||||
$(info $(MAKEFLAGS))
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
two:; $(info $@)
|
||||
!, '-S',
|
||||
"S
|
||||
S
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
#MAKE#: *** [#MAKEFILE#:6: one] Error 1", 512);
|
||||
|
||||
delete $ENV{'MAKEFLAGS'};
|
||||
@ -606,12 +606,12 @@ MAKEFLAGS${fl}-k
|
||||
all: one two
|
||||
one:
|
||||
\$(info \$(MAKEFLAGS))
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
two:; \$(info \$@)
|
||||
", '',
|
||||
"k
|
||||
k
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
#MAKE#: *** [#MAKEFILE#:7: one] Error 1
|
||||
two
|
||||
#MAKE#: Target 'all' not remade because of errors.", 512);
|
||||
@ -626,12 +626,12 @@ MAKEFLAGS${fl}-k
|
||||
all: one two
|
||||
one:
|
||||
\$(info \$(MAKEFLAGS))
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
two:; \$(info \$@)
|
||||
", '-S',
|
||||
"S
|
||||
S
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
#MAKE#: *** [#MAKEFILE#:7: one] Error 1", 512);
|
||||
}
|
||||
|
||||
@ -645,12 +645,12 @@ MAKEFLAGS${fl}-k
|
||||
all: one two
|
||||
one:
|
||||
\$(info \$(MAKEFLAGS))
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
two:; \$(info \$@)
|
||||
", '',
|
||||
"S
|
||||
S
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
#MAKE#: *** [#MAKEFILE#:7: one] Error 1", 512);
|
||||
}
|
||||
|
||||
@ -665,12 +665,12 @@ MAKEFLAGS${fl}-S
|
||||
all: one two
|
||||
one:
|
||||
\$(info \$(MAKEFLAGS))
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
two:; \$(info \$@)
|
||||
", '',
|
||||
"S
|
||||
S
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
#MAKE#: *** [#MAKEFILE#:7: one] Error 1", 512);
|
||||
}
|
||||
|
||||
@ -682,12 +682,12 @@ MAKEFLAGS${fl}-S
|
||||
all: one two
|
||||
one:
|
||||
\$(info \$(MAKEFLAGS))
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
two:; \$(info \$@)
|
||||
", '-k',
|
||||
"k
|
||||
k
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
#MAKE#: *** [#MAKEFILE#:7: one] Error 1
|
||||
two
|
||||
#MAKE#: Target 'all' not remade because of errors.", 512);
|
||||
@ -703,12 +703,12 @@ MAKEFLAGS${fl}-S
|
||||
all: one two
|
||||
one:
|
||||
\$(info \$(MAKEFLAGS))
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
two:; \$(info \$@)
|
||||
", '',
|
||||
"k
|
||||
k
|
||||
false
|
||||
#HELPER# -q fail 1
|
||||
#MAKE#: *** [#MAKEFILE#:7: one] Error 1
|
||||
two
|
||||
#MAKE#: Target 'all' not remade because of errors.", 512);
|
||||
|
@ -94,17 +94,10 @@ all: ; \@$script
|
||||
'', $out);
|
||||
}
|
||||
|
||||
# We can't just use "false" because on different systems it provides a
|
||||
# different exit code--once again Solaris: false exits with 255 not 1
|
||||
$script = 'true; false; true';
|
||||
$flags = '-xec';
|
||||
$out = `$sh_name $flags '$script' 2>&1`;
|
||||
my $err = $? >> 8;
|
||||
|
||||
run_make_test(qq!
|
||||
.SHELLFLAGS = $flags
|
||||
all: ; \@$script
|
||||
.SHELLFLAGS = -xec
|
||||
all: ; \@true; #HELPER# -q fail 1; true
|
||||
!,
|
||||
'', "$out#MAKE#: *** [#MAKEFILE#:3: all] Error $err\n", 512);
|
||||
'', "+ true\n+ #HELPER# -q fail 1\n#MAKE#: *** [#MAKEFILE#:3: all] Error 1\n", 512);
|
||||
|
||||
1;
|
||||
|
@ -103,7 +103,7 @@ sub op {
|
||||
}
|
||||
|
||||
if ($op eq 'fail') {
|
||||
print "fail $nm\n";
|
||||
print "fail $nm\n" unless $quiet;
|
||||
exit($nm);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user