]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Portability changes for the test suite.
authorPaul Smith <psmith@gnu.org>
Fri, 23 Dec 2016 18:33:58 +0000 (13:33 -0500)
committerPaul Smith <psmith@gnu.org>
Mon, 26 Dec 2016 14:01:59 +0000 (09:01 -0500)
* 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.

15 files changed:
tests/run_make_tests.pl
tests/scripts/features/echoing
tests/scripts/features/include
tests/scripts/features/output-sync
tests/scripts/features/patternrules
tests/scripts/functions/file
tests/scripts/functions/wildcard
tests/scripts/options/dash-C
tests/scripts/options/dash-k
tests/scripts/options/dash-l
tests/scripts/targets/FORCE
tests/scripts/targets/PHONY
tests/scripts/targets/SILENT
tests/scripts/targets/clean
tests/test_driver.pl

index 916f3467309bf50bd0a8def8db7d13754b94b2c2..a74417ac579eeb4881277a663af3f8c1bd144282 100644 (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.
index 40debf5a9096d3acde461ddabc689d729882182e..a666a26307366b42f916ac98c2fe9fcc29e8002d 100644 (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
index 4b8bd7ed4ccc02593130db6d26bd04449cddb685..a21455dd66386f030a24a776dfa9b0bfab8c8d46 100644 (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');
 
index 7237e65bfd6ef76defae29ec5664333061a2fcb1..9fb3adec28f993b841aff1783dc1cae311838d68 100644 (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]";
index c7ae7cffc474e4a1991d8c7b9ec8390eecdb2e4a..8f7ccc408f08b571cfccad456c48b36046a29e29 100644 (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));
index 904db790404b702b23e7003288e297bec3bdf5e5..c3f0b565dea02b5cccfc0f805b845c72a9314cfb 100644 (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');
index bcd84ad793a3ff40c7924422a455b95bea94a8b0..f91d9adb8c948d6cc77bda8bdc7c7960679c2f7e 100644 (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";
index 42d0a8baeb43bdcd20cf3357b41d518502c079b5..47aee53a3d75fa8e687f9c325a20efec9c843409 100644 (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;
index 85dd0b0a3b6fe94c45acae28b1b4b4f873efc68d..86c7c7879f72277ef45a9ac28ac2d380d5363aec 100644 (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",
index 0b0f196f9c926a4e204dc9588b12f2aebe05299b..a36b7ae1d42faae9f2b72bb01ed5c9989b0e2b9c 100644 (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";
index eb8f2517bcbf267101361ca4dc078ad9b56bd2a1..297bb38b4012f843cbda42c5846c56e5d8c2abd8 100644 (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;
-
-
-
-
-
-
-
-
-
index c8e2110fef6d9d43097d92f3a7670cc36075f085..d49e3f83890322f5968237b2cfca9b9976e86ab5 100644 (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');
+
+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) {
@@ -42,13 +36,7 @@ if (-f $example) {
 
 &compare_output($answer,&get_logfile(1));
 
-1;
-
-
-
-
-
-
-
-
+# Just in case
+unlink($example, 'clean');
 
+1;
index 4bb0a0f42e5308aeebac432ee8a1875134c43118..521930e8ba04f3f29a94df4fa939da128dc41c68 100644 (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));
-
-1;
-
-
-
-
-
-
-
+compare_output($answer,&get_logfile(1));
 
+# Just in case
+unlink($example);
 
+1;
index b32c976702ba902f7bd1223a5af418bfa782ba94..e67458e90f0c645a555908fd09f4872f6abb7695 100644 (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;
-
-
-
-
-
-
-
-
-
index e6cd9f9e68d712c20a5b11b6e5cb150ba78c0af7..cb0a1b21de2061b4edd8c257f92e107cb094c0b9 100644 (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 = ();