mirror of
https://github.com/mirror/make.git
synced 2025-01-24 19:31:20 +08:00
5eff618c8c
Reset the temp directory for every test to a local directory, then after each test see if any new temp files were created and not deleted: if they were then fail the test. Rather than delete the temp files we leave them there and avoid reporting files that were seen before, so the user can investigate them. Rewrite the temp_stdin tests to rely on this built-in behavior rather than implementing the checks directly. * tests/test_driver.pl: Create a $TEMPDIR variable pointing to a temporary directory outside the test temp directory. (toplevel) Before starting any tests create a temp directory and set the POSIX and Windows temp directory environment variables to use it. (compare_output) Check the contents of the temp directory. If any new files have appeared, fail the test. * tests/scripts/features/temp_stdin: Remove check_tempfile() and all users of it, plus setting of temp environment variables.
85 lines
2.5 KiB
Perl
85 lines
2.5 KiB
Perl
# -*-mode: perl-*-
|
|
|
|
$description = "Test handling of temporary file created from stdin.";
|
|
|
|
# These tests rely on the test_driver checking for leftover temporary content
|
|
|
|
create_file('input.mk', "world:=1\n");
|
|
create_file('bye.mk', "moon:=2\n");
|
|
|
|
# sv 62118,62145.
|
|
# Test that makes leaves no temp file when make code is piped to stdin and -v,
|
|
# -h or an invalid option is specified.
|
|
my @opts = ('-v', '-h', '--nosuchopt');
|
|
my @exit_codes = (0, 0, 512);
|
|
for my $i (0 .. $#opts) {
|
|
close(STDIN);
|
|
open(STDIN, "<", 'input.mk') || die "$0: cannot open input.mk for reading: $!";
|
|
run_make_test(q!
|
|
all:; $(info hello world)
|
|
!,
|
|
"$opts[$i] -f-", "/uilt for /", $exit_codes[$i]);
|
|
}
|
|
|
|
# sv 62118,62145.
|
|
# Test that a stdin temp file is removed.
|
|
close(STDIN);
|
|
open(STDIN, "<", 'input.mk') || die "$0: cannot open input.mk for reading: $!";
|
|
run_make_test(q!
|
|
all:; $(info world=$(world))
|
|
!,
|
|
'-f-', "world=1\n#MAKE#: 'all' is up to date.\n");
|
|
|
|
# sv 62118,62145.
|
|
# Test that a stdin temp file is removed, even when make re-execs.
|
|
# Also test that make honors TMPDIR to create the temp file.
|
|
# Ensure touching bye.mk causes re-exec.
|
|
&utouch(-600, 'bye.mk');
|
|
close(STDIN);
|
|
open(STDIN, "<", 'input.mk') || die "$0: cannot open input.mk for reading: $!";
|
|
run_make_test(q!
|
|
include bye.mk
|
|
all:; $(info hello)
|
|
$(MAKE_RESTARTS)bye.mk: force; touch $@
|
|
force:
|
|
!,
|
|
'-R --debug=b -f-', "/Re-executing.+?--temp-stdin=\Q$temppath\E/");
|
|
|
|
if ($port_type eq 'UNIX') {
|
|
# sv 62118,62145.
|
|
# Test that a stdin temp file is removed, when execvp fails to re-exec make.
|
|
# In order to cause execvp to fail, copy the tested make binary to the temp
|
|
# directory and take away the 'x' bit.
|
|
use File::Spec;
|
|
use File::Copy;
|
|
|
|
my $makecopy = File::Spec->catfile($TEMPDIR, "make");
|
|
copy("$mkpath", $makecopy);
|
|
# Set file mode bits, because perl copy won't.
|
|
chmod 0750, $makecopy;
|
|
|
|
my @make_orig = @make_command;
|
|
@make_command = ($makecopy);
|
|
|
|
# Ensure touching bye.mk causes re-exec.
|
|
&utouch(-600, 'bye.mk');
|
|
close(STDIN);
|
|
open(STDIN, "<", 'input.mk') || die "$0: cannot open input.mk for reading: $!";
|
|
run_make_test("
|
|
include bye.mk
|
|
all:; \$(info hello)
|
|
\$(MAKE_RESTARTS)bye.mk: force; touch \$@ && chmod -x $makecopy
|
|
force:
|
|
",
|
|
"-f-", "touch bye.mk && chmod -x $makecopy\nmake: $makecopy: $ERR_nonexe_file\n", 32512);
|
|
|
|
@make_command = @make_orig;
|
|
unlink($makecopy);
|
|
}
|
|
|
|
close(STDIN);
|
|
unlink('input.mk', 'bye.mk');
|
|
|
|
# This tells the test driver that the perl test script executed properly.
|
|
1;
|