Portability changes for the test suite.

* 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.
This commit is contained in:
Paul Smith 2016-12-23 13:33:58 -05:00
parent c6966b3238
commit 45bf0e3a67
15 changed files with 109 additions and 166 deletions

View file

@ -42,6 +42,10 @@ $command_string = '';
$all_tests = 0;
# Shell commands
$CMD_rmfile = 'rm -f';
# rmdir broken in some Perls on VMS.
if ($^O eq 'VMS')
{
@ -56,6 +60,8 @@ if ($^O eq 'VMS')
};
*CORE::GLOBAL::rmdir = \&vms_rmdir;
$CMD_rmfile = 'delete_file -no_ask';
}
require "test_driver.pl";
@ -317,11 +323,9 @@ sub print_help
}
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.

View file

@ -36,7 +36,7 @@ run_make_test("
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');
@ -52,7 +52,7 @@ if (-f $example) {
# TEST #3
# -------
run_make_test(undef, '-n clean', "$delete_command $example\n");
run_make_test(undef, '-n clean', "$CMD_rmfile $example\n");
# TEST #4

View file

@ -161,7 +161,7 @@ bar: baz
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);
@ -188,7 +188,7 @@ inc1:; echo > $@
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');
@ -220,7 +220,7 @@ include 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');
@ -231,7 +231,7 @@ default:; @echo DEFAULT
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');

View file

@ -45,7 +45,7 @@ sub output_sync_clean {
# 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]";

View file

@ -163,16 +163,16 @@ p1.% p2.%: %.orig
# 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));

View file

@ -51,18 +51,6 @@ unlink('4touch');
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
@ -71,7 +59,7 @@ endef
$(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');

View file

@ -25,7 +25,7 @@ print2:
\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
@ -63,7 +63,7 @@ $answer = "example.1 example.3 example._\n"
# 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";

View file

@ -11,19 +11,17 @@ find the makefile and the file to delete in the work directory.";
$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;
@ -35,10 +33,10 @@ if (-f $example) {
# 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
@ -47,11 +45,9 @@ $answer = "$make_name: Entering directory '$wpath'\n"
$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;
@ -63,9 +59,10 @@ if (-f $example) {
# 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;

View file

@ -105,7 +105,7 @@ include ifile
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",

View file

@ -17,29 +17,22 @@ decide that it cannot run more than one job even though -j 4 was
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";

View file

@ -2,39 +2,18 @@
$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;

View file

@ -12,28 +12,22 @@ $details = "This makefile in this test declares the target clean to be a \n"
$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');
$answer = "$delete_command $example clean\n";
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 = "$CMD_rmfile $example clean\n";
&run_make_with_options($makefile,"clean",&get_logfile);
if (-f $example) {
@ -42,13 +36,7 @@ if (-f $example) {
&compare_output($answer,&get_logfile(1));
# Just in case
unlink($example, 'clean');
1;

View file

@ -10,33 +10,22 @@ $details = "This test is the same as the clean test except that it should\n"
$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));
compare_output($answer,&get_logfile(1));
# Just in case
unlink($example);
1;

View file

@ -8,43 +8,24 @@ $description = "The following test creates a makefile to delete a \n"
$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;

View file

@ -55,6 +55,30 @@ $test_timeout = 10 if $^O eq 'VMS';
# 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 = ();