mirror of
https://git.savannah.gnu.org/git/make.git
synced 2025-01-13 01:07:36 +00:00
* tests/scripts/options/dash-l: Simplify the test via the helper
* tests/thelp.pl: Add "exist" and "noexist" operators.
This commit is contained in:
parent
74dab224b3
commit
8093e2eee3
2 changed files with 31 additions and 22 deletions
|
@ -20,32 +20,27 @@ also specified on the command line.";
|
||||||
$port_type eq 'W32' and return -1;
|
$port_type eq 'W32' and return -1;
|
||||||
|
|
||||||
open(MAKEFILE,"> $makefile");
|
open(MAKEFILE,"> $makefile");
|
||||||
printf MAKEFILE q,
|
printf MAKEFILE subst_make_string(q!
|
||||||
define test
|
test = #HELPER# noexist test-file file test-file sleep 2 rm test-file
|
||||||
if [ ! -f test-file ]; then \
|
|
||||||
echo >> test-file; sleep 2; %s test-file; \
|
|
||||||
else \
|
|
||||||
echo $@ FAILED; \
|
|
||||||
fi
|
|
||||||
endef
|
|
||||||
|
|
||||||
all : ONE TWO THREE
|
all : ONE TWO THREE
|
||||||
ONE : ; @$(test)
|
ONE : ; @$(test)
|
||||||
TWO : ; @$(test)
|
TWO : ; @$(test)
|
||||||
THREE : ; @$(test)
|
THREE : ; @$(test)
|
||||||
,, $CMD_rmfile;
|
!);
|
||||||
close(MAKEFILE);
|
close(MAKEFILE);
|
||||||
|
my $ans = "noexist test-file\nfile test-file\nsleep 2\nrm test-file\n";
|
||||||
|
|
||||||
$mkoptions = "-l 0.0001";
|
$mkoptions = "-l 0.0001";
|
||||||
$mkoptions .= " -j 4" if ($parallel_jobs);
|
$mkoptions .= " -j 4" if ($parallel_jobs);
|
||||||
|
|
||||||
# We have to wait longer than the default (5s).
|
# We have to wait longer than the default (5s).
|
||||||
&run_make_with_options($makefile, $mkoptions, &get_logfile, 0, 8);
|
&run_make_with_options($makefile, $mkoptions, &get_logfile, 0, 10);
|
||||||
|
|
||||||
$slurp = &read_file_into_string(&get_logfile(1));
|
$slurp = &read_file_into_string(&get_logfile(1));
|
||||||
if ($slurp =~ /cannot enforce load limit/) {
|
if ($slurp =~ /cannot enforce load limit/) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
&compare_output("", &get_logfile(1));
|
&compare_output("$ans$ans$ans", &get_logfile(1));
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -8,17 +8,19 @@
|
||||||
# Each step consists of an operator and argument.
|
# Each step consists of an operator and argument.
|
||||||
#
|
#
|
||||||
# It supports the following operators:
|
# It supports the following operators:
|
||||||
# out <word> : echo <word> to stdout with a newline
|
# out <word> : echo <word> to stdout with a newline
|
||||||
# raw <word> : echo <word> to stdout without adding anything
|
# raw <word> : echo <word> to stdout without adding anything
|
||||||
# env <word> : echo the value of the env.var. <word>, or "<unset>"
|
# env <word> : echo the value of the env.var. <word>, or "<unset>"
|
||||||
# file <word> : echo <word> to stdout AND create the file <word>
|
# file <word> : echo <word> to stdout AND create the file <word>
|
||||||
# dir <word> : echo <word> to stdout AND create the directory <word>
|
# dir <word> : echo <word> to stdout AND create the directory <word>
|
||||||
# rm <word> : echo <word> to stdout AND delete the file/directory <word>
|
# rm <word> : echo <word> to stdout AND delete the file/directory <word>
|
||||||
# wait <word> : wait for a file named <word> to exist
|
# wait <word> : wait for a file named <word> to exist
|
||||||
# tmout <secs> : Change the timeout for waiting. Default is 4 seconds.
|
# exist <word> : echo <word> AND fail if a file named <word> doesn't exist
|
||||||
# sleep <secs> : Sleep for <secs> seconds then echo <secs>
|
# noexist <word> : echo <word> AND fail if a file named <word> exists
|
||||||
# term <pid> : send SIGTERM to PID <pid>
|
# tmout <secs> : Change the timeout for waiting. Default is 4 seconds.
|
||||||
# fail <err> : echo <err> to stdout then exit with error code err
|
# sleep <secs> : Sleep for <secs> seconds then echo <secs>
|
||||||
|
# term <pid> : send SIGTERM to PID <pid>
|
||||||
|
# fail <err> : echo <err> to stdout then exit with error code err
|
||||||
#
|
#
|
||||||
# If given -q only the "out", "raw", and "env" commands generate output.
|
# If given -q only the "out", "raw", and "env" commands generate output.
|
||||||
|
|
||||||
|
@ -60,6 +62,18 @@ sub op {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($op eq 'exist') {
|
||||||
|
-f "$nm" || die "$nm: file should exist: $!\n";
|
||||||
|
print "exist $nm\n" unless $quiet;
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($op eq 'noexist') {
|
||||||
|
-f "$nm" && die "$nm: file exists\n";
|
||||||
|
print "noexist $nm\n" unless $quiet;
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# Show the output before creating the directory
|
# Show the output before creating the directory
|
||||||
if ($op eq 'dir') {
|
if ($op eq 'dir') {
|
||||||
print "dir $nm\n" unless $quiet;
|
print "dir $nm\n" unless $quiet;
|
||||||
|
|
Loading…
Reference in a new issue