* tests/test_driver.pl: Save error strings for later comparison.
* tests/run_make_tests.pl: Create portable commands for later use.
* tests/*: Use these new variables.
$all_tests = 0;
+# Shell commands
+
+$CMD_rmfile = 'rm -f';
+
# rmdir broken in some Perls on VMS.
if ($^O eq 'VMS')
{
};
*CORE::GLOBAL::rmdir = \&vms_rmdir;
+
+ $CMD_rmfile = 'delete_file -no_ask';
}
require "test_driver.pl";
}
sub get_this_pwd {
- $delete_command = 'rm -f';
if ($has_POSIX) {
$__pwd = POSIX::getcwd();
} elsif ($vos) {
- $delete_command = "delete_file -no_ask";
$__pwd = `++(current_dir)`;
} else {
# No idea... just try using pwd as a last resort.
all:
\techo This makefile did not clean the dir... good
clean:
-\t\@$delete_command $example\n",
+\t\@$CMD_rmfile $example\n",
'', 'echo This makefile did not clean the dir... good
This makefile did not clean the dir... good');
# TEST #3
# -------
-run_make_test(undef, '-n clean', "$delete_command $example\n");
+run_make_test(undef, '-n clean', "$CMD_rmfile $example\n");
# TEST #4
baz: end
',
'',
-"#MAKEFILE#:2: bar: No such file or directory
+"#MAKEFILE#:2: bar: $ERR_no_such_file
#MAKE#: *** No rule to make target 'end', needed by 'baz'. Stop.\n",
512);
include inc1
include inc2
!,
- '', "#MAKEFILE#:7: inc2: No such file or directory\n#MAKE#: *** No rule to make target 'inc2'. Stop.\n", 512);
+ '', "#MAKEFILE#:7: inc2: $ERR_no_such_file\n#MAKE#: *** No rule to make target 'inc2'. Stop.\n", 512);
rmfiles('inc1');
inc1: foo; echo > $@
foo:; exit 1
!,
- '', "exit 1\n#MAKEFILE#:3: inc1: No such file or directory\n#MAKE#: *** [#MAKEFILE#:5: foo] Error 1\n", 512);
+ '', "exit 1\n#MAKEFILE#:3: inc1: $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:5: foo] Error 1\n", 512);
rmfiles('inc1');
include inc1
inc1: foo; echo > $@
!,
- '', "#MAKEFILE#:3: inc1: No such file or directory\n#MAKE#: *** No rule to make target 'foo', needed by 'inc1'. Stop.\n", 512);
+ '', "#MAKEFILE#:3: inc1: $ERR_no_such_file\n#MAKE#: *** No rule to make target 'foo', needed by 'inc1'. Stop.\n", 512);
rmfiles('inc1');
# reliable. If things are too fast, then sometimes a different job will steal
# the output sync lock and the output is mis-ordered from what we expect.
sub output_sync_wait {
- return "while [ ! -f ../mksync.$_[0] ]; do :; done; rm -f ../mksync.$_[0].wait; $sleep_command 1";
+ return "while [ ! -f ../mksync.$_[0] ]; do :; done; $CMD_rmfile ../mksync.$_[0].wait; $sleep_command 1";
}
sub output_sync_set {
return "date > ../mksync.$_[0]";
# TEST 6: Make sure that non-target files are still eligible to be created
# as part of implicit rule chaining. Savannah bug #17752.
-run_make_test(q!
+run_make_test(sprintf(q!
BIN = xyz
COPY = $(BIN).cp
SRC = $(BIN).c
allbroken: $(COPY) $(BIN) ; @echo ok
$(SRC): ; @echo 'main(){}' > $@
-%.cp: % ; @cp $< $@
-% : %.c ; @cp $< $@
-clean: ; @rm -rf $(SRC) $(COPY) $(BIN)
-!,
+%%.cp: %% ; @cp $< $@
+%% : %%.c ; @cp $< $@
+clean: ; @%s $(SRC) $(COPY) $(BIN)
+!, $CMD_rmfile),
'', "ok\n");
unlink(qw(xyz xyz.cp xyz.c));
touch('file.out');
chmod(0444, 'file.out');
-# Find the error that will be printed
-# This seems complicated, but we need the message from the C locale
-my $loc = undef;
-if ($has_POSIX) {
- $loc = POSIX::setlocale(POSIX::LC_MESSAGES);
- POSIX::setlocale(POSIX::LC_MESSAGES, 'C');
-}
-my $e;
-open(my $F, '>', 'file.out') and die "Opened read-only file!\n";
-$e = "$!";
-$loc and POSIX::setlocale(POSIX::LC_MESSAGES, $loc);
-
run_make_test(q!
define A
a
$(file > file.out,$(A))
x:;@cat file.out
!,
- '', "#MAKEFILE#:6: *** open: file.out: $e. Stop.",
+ '', "#MAKEFILE#:6: *** open: file.out: $ERR_read_only_file. Stop.",
512);
unlink('file.out');
\t\@echo \$(sort \$(wildcard example.[a-z0-9]))
\t\@echo \$(sort \$(wildcard example.[!A-Za-z_\\!]))
clean:
-\t$delete_command \$(sort \$(wildcard example.*))
+\t$CMD_rmfile \$(sort \$(wildcard example.*))
EOM
# END of Contents of MAKEFILE
# TEST #3
# -------
-$answer = "$delete_command example.1 example.3 example._ example.for example.two";
+$answer = "$CMD_rmfile example.1 example.3 example._ example.for example.two";
if ($vos)
{
$answer .= " \n";
$example = $workdir . $pathsep . "EXAMPLE";
open(MAKEFILE,"> $makefile");
-print MAKEFILE <<EOF;
+print MAKEFILE qq!
all: ; \@echo This makefile did not clean the dir ... good
-clean: ; $delete_command EXAMPLE\$(ext)
-EOF
+clean: ; $CMD_rmfile EXAMPLE\$(ext)
+!;
close(MAKEFILE);
# TEST #1
# -------
-&touch($example);
+touch($example);
-&run_make_with_options("${testname}.mk",
- "-C $workdir clean",
- &get_logfile);
+run_make_with_options("${testname}.mk", "-C $workdir clean", &get_logfile);
chdir $workdir;
$wpath = &get_this_pwd;
# Create the answer to what should be produced by this Makefile
$answer = "$make_name: Entering directory '$wpath'\n"
- . "$delete_command EXAMPLE\n"
+ . "$CMD_rmfile EXAMPLE\n"
. "$make_name: Leaving directory '$wpath'\n";
-&compare_output($answer,&get_logfile(1));
+compare_output($answer,&get_logfile(1));
# TEST #2
$example .= "slash";
-&touch($example);
+touch($example);
-&run_make_with_options("${testname}.mk",
- "-C $workdir/ clean ext=slash",
- &get_logfile);
+run_make_with_options("${testname}.mk", "-C $workdir/ clean ext=slash", &get_logfile);
chdir $workdir;
$wpath = &get_this_pwd;
# Create the answer to what should be produced by this Makefile
$answer = "$make_name: Entering directory '$wpath'\n"
- . "$delete_command EXAMPLEslash\n"
+ . "$CMD_rmfile EXAMPLEslash\n"
. "$make_name: Leaving directory '$wpath'\n";
&compare_output($answer,&get_logfile(1));
+unlink($example);
1;
ifile: no-such-file; @false
',
'-k',
- "#MAKEFILE#:2: ifile: No such file or directory
+ "#MAKEFILE#:2: ifile: $ERR_no_such_file
#MAKE#: *** No rule to make target 'no-such-file', needed by 'ifile'.
#MAKE#: Failed to remake makefile 'ifile'.
hi\n",
also specified on the command line.";
open(MAKEFILE,"> $makefile");
-
-# The Contents of the MAKEFILE ...
-
-print MAKEFILE <<'EOF';
+print MAKEFILE qq,
SHELL = /bin/sh
define test
-if [ ! -f test-file ]; then \
- echo >> test-file; sleep 2; rm -f test-file; \
-else \
- echo $@ FAILED; \
+if [ ! -f test-file ]; then \\
+ echo >> test-file; sleep 2; $CMD_rmfile test-file; \\
+else \\
+ echo \$\@ FAILED; \\
fi
endef
all : ONE TWO THREE
-ONE : ; @$(test)
-TWO : ; @$(test)
-THREE : ; @$(test)
-EOF
-
-
-# END of Contents of MAKEFILE
-
+ONE : ; \@\$(test)
+TWO : ; \@\$(test)
+THREE : ; \@\$(test)
+,;
close(MAKEFILE);
$mkoptions = "-l 0.0001";
$description = "The following tests rules without Commands or Dependencies.";
-$details = "If the rule ...\n";
-
-open(MAKEFILE,"> $makefile");
-
-# The Contents of the MAKEFILE ...
-
-print MAKEFILE ".IGNORE :\n";
-print MAKEFILE "clean: FORCE\n";
-print MAKEFILE "\t$delete_command clean\n";
-print MAKEFILE "FORCE:\n";
-
-# END of Contents of MAKEFILE
-
-close(MAKEFILE);
-
-
# Create a file named "clean". This is the same name as the target clean
# and tricks the target into thinking that it is up to date. (Unless you
# use the .PHONY target.
-&touch("clean");
+touch('clean');
-$answer = "$delete_command clean\n";
-&run_make_with_options($makefile,"clean",&get_logfile);
+run_make_test(qq!
+.IGNORE :
+clean: FORCE ; $CMD_rmfile clean
+FORCE:
+!,
+ '', "$CMD_rmfile clean");
-&compare_output($answer,&get_logfile(1));
+rmfiles('clean');
1;
-
-
-
-
-
-
-
-
-
$example = "EXAMPLE_FILE";
-open(MAKEFILE,"> $makefile");
-
-# The Contents of the MAKEFILE ...
-
-print MAKEFILE ".PHONY : clean \n";
-print MAKEFILE "all: \n";
-print MAKEFILE "\t\@echo This makefile did not clean the dir ... good\n";
-print MAKEFILE "clean: \n";
-print MAKEFILE "\t$delete_command $example clean\n";
-
-# END of Contents of MAKEFILE
-
-close(MAKEFILE);
-
-&touch($example);
+touch($example);
# Create a file named "clean". This is the same name as the target clean
# and tricks the target into thinking that it is up to date. (Unless you
# use the .PHONY target.
-&touch("clean");
+touch('clean');
+
+open(MAKEFILE, "> $makefile");
+print MAKEFILE qq!
+.PHONY : clean
+all: ; \@echo This makefile did not clean the dir ... good
+clean: ; $CMD_rmfile $example clean
+!;
+close(MAKEFILE);
-$answer = "$delete_command $example clean\n";
+$answer = "$CMD_rmfile $example clean\n";
&run_make_with_options($makefile,"clean",&get_logfile);
if (-f $example) {
&compare_output($answer,&get_logfile(1));
-1;
-
-
-
-
-
-
-
-
+# Just in case
+unlink($example, 'clean');
+1;
$example = "EXAMPLE_FILE";
open(MAKEFILE,"> $makefile");
-
-# The Contents of the MAKEFILE ...
-
-print MAKEFILE ".SILENT : clean\n";
-print MAKEFILE "clean: \n";
-print MAKEFILE "\t$delete_command EXAMPLE_FILE\n";
-
-# END of Contents of MAKEFILE
-
+print MAKEFILE qq!
+.SILENT : clean
+clean: ; $CMD_rmfile $example
+!;
close(MAKEFILE);
-&touch($example);
+touch($example);
-$answer = "";
-&run_make_with_options($makefile,"clean",&get_logfile,0);
+$answer = '';
+run_make_with_options($makefile,"clean",&get_logfile,0);
if (-f $example) {
$test_passed = 0;
}
-&compare_output($answer,&get_logfile(1));
-
-1;
-
-
-
-
-
-
-
+compare_output($answer,&get_logfile(1));
+# Just in case
+unlink($example);
+1;
$example = "EXAMPLE_FILE";
open(MAKEFILE,"> $makefile");
-
-# The Contents of the MAKEFILE ...
-
-print MAKEFILE "all: \n";
-print MAKEFILE "\t\@echo This makefile did not clean the dir... good\n";
-print MAKEFILE "clean: \n";
-print MAKEFILE "\t$delete_command EXAMPLE_FILE\n";
-
-# END of Contents of MAKEFILE
-
+print MAKEFILE qq!
+all: ; \@echo This makefile did not clean the dir... good
+clean: ; $CMD_rmfile $example
+!;
close(MAKEFILE);
-&touch($example);
+touch($example);
+run_make_with_options($makefile,"",&get_logfile,0);
-
-&run_make_with_options($makefile,"",&get_logfile,0);
-
-# Create the answer to what should be produced by this Makefile
$answer = "This makefile did not clean the dir... good\n";
+compare_output($answer,&get_logfile(1)) || error("abort");
-&compare_output($answer,&get_logfile(1)) || &error ("abort");
-
-$answer = "$delete_command $example\n";
-&run_make_with_options($makefile,"clean",&get_logfile,0);
+$answer = "$CMD_rmfile $example\n";
+run_make_with_options($makefile,"clean",&get_logfile,0);
if (-f $example) {
$test_passed = 0;
}
-&compare_output($answer,&get_logfile(1)) || &error ("abort");
+compare_output($answer,&get_logfile(1)) || error("abort");
1;
-
-
-
-
-
-
-
-
-
# Path to Perl
$perl_name = $^X;
+# Find the strings that will be generated for various error codes.
+# We want them from the C locale regardless of our current locale.
+
+my $loc = undef;
+if ($has_POSIX) {
+ $loc = POSIX::setlocale(POSIX::LC_MESSAGES);
+ POSIX::setlocale(POSIX::LC_MESSAGES, 'C');
+}
+
+open(my $F, '<', 'file.none') and die "Opened non-existent file!\n";
+$ERR_no_such_file = "$!";
+
+touch('file.out');
+chmod(0444, 'file.out');
+open(my $F, '>', 'file.out') and die "Opened read-only file!\n";
+$ERR_read_only_file = "$!";
+
+chmod(0000, 'file.out');
+open(my $F, '<', 'file.out') and die "Opened unreadable file!\n";
+$ERR_unreadable_file = "$!";
+
+unlink('file.out');
+$loc and POSIX::setlocale(POSIX::LC_MESSAGES, $loc);
+
# %makeENV is the cleaned-out environment.
%makeENV = ();