]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Enhance tests to work on different systems
authorPaul Smith <psmith@gnu.org>
Sat, 22 Oct 2022 19:35:16 +0000 (15:35 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 23 Oct 2022 02:37:49 +0000 (22:37 -0400)
The GNU platform testers reported a number of test errors on
different systems; try to address them.

* tests/thelp.pl: A number of tests timed out with a 4-second
timeout.  Increase the default timeout to 10 seconds.
* tests/run_make_tests.pl: Executing directories on cygwin behaves
differently in Perl than make so skip these tests there.
* tests/scripts/options/symlinks: Check for the symlink feature
in make, rather than whether the system supports them.
* tests/scripts/features/implicit_search: On some systems "false"
exits with a different exit code.  Use the helper instead.
* tests/scripts/features/loadapi: Ditto.
* tests/scripts/features/output-sync: Sleep before make -f bar in
the first test as well as the second one.
* tests/scripts/features/exec: Skip on cygwin, which seems to
be "UNIX" but where scripts don't run normally.
* tests/scripts/misc/fopen-fail: Skip on cygwin, where make
eventually exits with exit code 0 and no error messages.

tests/run_make_tests.pl
tests/scripts/features/errors
tests/scripts/features/exec
tests/scripts/features/implicit_search
tests/scripts/features/loadapi
tests/scripts/features/output-sync
tests/scripts/misc/fopen-fail
tests/scripts/options/symlinks
tests/thelp.pl

index 61ec60399b4008e29c02b78d5aff38af4918b0c4..feb1f5d7c7838d8bff2755f57a9064a8fc3ba1cb 100644 (file)
@@ -148,11 +148,16 @@ $ERR_command_not_found = undef;
       $ERR_nonexe_file = "$!";
   }
 
-  $_ = `./. 2>&1`;
-  if ($? == 0) {
-      print "Executed directory!  Skipping related tests.\n";
+  if ($^O =~ /cygwin/i) {
+      # For some reason the execute here gives a different answer than make's
+      print "Skipping directory execution on $^O\n";
   } else {
-      $ERR_exe_dir = "$!";
+      $_ = `./. 2>&1`;
+      if ($? == 0) {
+          print "Executed directory!  Skipping related tests.\n";
+      } else {
+          $ERR_exe_dir = "$!";
+      }
   }
 
   chmod(0000, 'file.out');
index f395032c6c934cc746b671205dfade698d57f646..2cdaf31ded7958f62f2a57358bdb550a76147184 100644 (file)
@@ -99,7 +99,7 @@ if ($ERR_nonexe_file) {
 # Try failing by "running" a directory
 
 if ($ERR_exe_dir) {
-    mkdir('sd', 0775);
+    mkdir('sd', 0775) or print "mkdir: sd: $!\n";
 
     run_make_test(q!
 PATH := .
index 54ab144712364127ca857990b300e2503bb556c5..29cba02a7a8c9953621f91b29064c81aa9a1fdac 100644 (file)
@@ -13,6 +13,7 @@ my $details = "The various shells that this test uses are the default"
 
 # Only bother with this on UNIX systems
 $port_type eq 'UNIX' or return -1;
+$^O =~ /cygwin/ and return -1;
 
 my $usersh = $origENV{SHELL};
 my $answer = 'hello, world';
@@ -36,7 +37,7 @@ for my $shbang (@shbangs) {
         close(CMD);
         chmod 0700, $cmd;
 
-        run_make_test("# $shbang\n# $shell" . q!
+        run_make_test("# shbang=$shbang\n# shell=$shell" . q!
 all:; @$(CMD)
 !, "$shell CMD=$cmd", "$answer\n");
 
index da9b65b5ca7273d1ab2368667d075f9507f3d620..564dc5bb6a48204f495f3835d3c521b61063a903 100644 (file)
@@ -55,8 +55,8 @@ run_make_test("
 all: hello$s
 %$s:$r %.c; \$(info hello.c)
 %$s:$r %.f; \$(info hello.f)
-hello.c:; false
-", '-r', "false\n#MAKE#: *** [#MAKEFILE#:5: hello.c] Error 1\n", 512);
+hello.c:; @#HELPER# fail 1
+", '-r', "fail 1\n#MAKE#: *** [#MAKEFILE#:5: hello.c] Error 1\n", 512);
 
 # Test that make finds the intended implicit rule based on existence of a
 # prerequisite in the filesystem, even when the prerequisite of another
@@ -115,9 +115,9 @@ run_make_test("
 all: hello$s
 %$s:$r %.c; \$(info \$<)
 %$s:$r %.f; \$(info \$<)
-.DEFAULT:; \$(info \$\@) false
+.DEFAULT:; \@\$(info \$\@) #HELPER# fail 1
 unrelated: hello.c
-", '-r', "hello.c\nfalse\n#MAKE#: *** [#MAKEFILE#:5: hello.c] Error 1\n", 512);
+", '-r', "hello.c\nfail 1\n#MAKE#: *** [#MAKEFILE#:5: hello.c] Error 1\n", 512);
 
 # hello.f is missing.
 # No rule is found, because hello.c is not mentioned explicitly.
@@ -125,8 +125,8 @@ run_make_test("
 all: hello$s
 %$s:$r %.c; \$(info \$<)
 %$s:$r %.f; \$(info \$<)
-.DEFAULT:; \@\$(info \$\@) false
-", '-r', "hello$s\n#MAKE#: *** [#MAKEFILE#:5: hello$s] Error 1\n", 512);
+.DEFAULT:; \@\$(info \$\@) #HELPER# fail 1
+", '-r', "hello$s\nfail 1\n#MAKE#: *** [#MAKEFILE#:5: hello$s] Error 1\n", 512);
 
 }
 }
@@ -202,7 +202,7 @@ for my $r (@rules) {
 
 my $result = "#MAKE#: *** No rule to make target 'hello.tsk', needed by 'all'.  Stop.\n";
 if ($s or $r) {
-    $result = "false\n#MAKE#: *** [#MAKEFILE#:6: hello.c] Error 1\n";
+    $result = "fail 1\n#MAKE#: *** [#MAKEFILE#:6: hello.c] Error 1\n";
 }
 
 run_make_test("
@@ -210,7 +210,7 @@ all: hello.tsk
 %.tsk: %$s; \$(info hello.tsk)
 %$s:$r %.c; \$(info hello.c)
 %$s:$r %.f; \$(info hello.f)
-hello.c:; false
+hello.c:; @#HELPER# fail 1
 ", '-r', $result, 512);
 }
 }
index 640ac745c896a49c69cbfae998b8504629351578..a72f1f1bb7431dedb5b514c05021ac2bfbd0c0dc 100644 (file)
@@ -190,10 +190,10 @@ run_make_test("
 load testapi.so
 $extra_loads
 all:; \$(info \$(test-expand hello))
-testapi.so: force; false
+testapi.so: force; @#HELPER# fail 1
 force:;
 .PHONY: force
-", '', "testapi_gmk_setup\nfalse\n#MAKE#: *** [#MAKEFILE#:$n: testapi.so] Error 1\n", 512);
+", '', "testapi_gmk_setup\nfail 1\n#MAKE#: *** [#MAKEFILE#:$n: testapi.so] Error 1\n", 512);
 
 # sv 63045.
 # Same as above, but testapi_gmk_setup returned -1.
@@ -203,7 +203,7 @@ run_make_test("
 load testapi.so
 $extra_loads
 all:; \$(info \$(test-expand hello))
-testapi.so: force; false
+testapi.so: force; @#HELPER# fail 1
 force:;
 .PHONY: force
 ", '', "testapi_gmk_setup\nhello\n#MAKE#: 'all' is up to date.\n");
index b175b82015a90e772aa4ff17c780e607f26115d5..13a54ca08a6631fff7dc0be9c0d1c4dc072103a2 100644 (file)
@@ -116,20 +116,24 @@ EOF
 close(MAKEFILE);
 
 # Test per-make synchronization.
+# Note we have to sleep again here after starting the foo makefile before
+# starting the bar makefile, otherwise the "entering/leaving" messages for the
+# submakes might be ordered differently than we expect.
+
 unlink(@syncfiles);
 run_make_test(qq!
 all: make-foo make-bar
 
 make-foo: ; \$(MAKE) -C foo
 
-make-bar: ; \$(MAKE) -C bar!,
+make-bar: ; #HELPER# -q sleep 1 ; \$(MAKE) -C bar!,
               '-j -Orecurse',
 "#MAKEPATH# -C foo
 #MAKE#[1]: Entering directory '#PWD#/foo'
 foo: start
 foo: end
 #MAKE#[1]: Leaving directory '#PWD#/foo'
-#MAKEPATH# -C bar
+#HELPER# -q sleep 1 ; #MAKEPATH# -C bar
 #MAKE#[1]: Entering directory '#PWD#/bar'
 bar: start
 bar: end
index 2ec9810b8f4bd747491cec6b4bca42058c021076..18e0b7d07fae2c72bf774b7da5960501f0b767a2 100644 (file)
@@ -2,6 +2,10 @@
 
 $description = "Make sure make exits with an error if fopen fails.";
 
+# For some reason on Cygwin, make exits with no error message after
+# it recurses for a while.
+$^O =~ /cygwin/ and return -1;
+
 # Recurse infinitely until we run out of open files, and ensure we
 # fail with a non-zero exit code.  Don't bother to test the output
 # since it's hard to know what it will be, exactly.
index bf8a89279d187ba5dcb5463c8672b116d8ae8c26..83dc84fb924a3e5b8eb325dff1cd992b736f925d 100644 (file)
@@ -6,14 +6,7 @@ $details = "Verify that symlink handling with and without -L works properly.";
 
 # Only run these tests if the system sypports symlinks
 
-# Apparently the Windows port of Perl reports that it does support symlinks
-# (in that the symlink() function doesn't fail) but it really doesn't, so
-# check for it explicitly.
-
-if ($port_type eq 'W32' || !( eval { symlink("",""); 1 })) {
-  # This test is N/A
-  return -1;
-}
+exists $FEATURES{'check-symlink'} or return -1;
 
 use File::Spec;
 
index ed8c819efa8dbe55910372b6d94ad7c18500ee6f..993339cbf169f65b9d3337b4d547249ee4c1715c 100755 (executable)
@@ -24,7 +24,7 @@
 $| = 1;
 
 my $quiet = 0;
-my $timeout = 4;
+my $timeout = 10;
 
 sub op {
     my ($op, $nm) = @_;