summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2022-10-22 15:35:16 -0400
committerPaul Smith <psmith@gnu.org>2022-10-22 22:37:49 -0400
commitcad3ddd165645fa7a8b1e9cf4ec996de89b4d5da (patch)
treeebaa5e098a233c80b4c3c470fa4b75f6ea8afeda /tests
parent54214176b124487d32c3ee02104135b0329579a1 (diff)
downloadmake-git-cad3ddd165645fa7a8b1e9cf4ec996de89b4d5da.tar.gz
Enhance tests to work on different systems
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/run_make_tests.pl13
-rw-r--r--tests/scripts/features/errors2
-rw-r--r--tests/scripts/features/exec3
-rw-r--r--tests/scripts/features/implicit_search16
-rw-r--r--tests/scripts/features/loadapi6
-rw-r--r--tests/scripts/features/output-sync8
-rw-r--r--tests/scripts/misc/fopen-fail4
-rw-r--r--tests/scripts/options/symlinks9
-rwxr-xr-xtests/thelp.pl2
9 files changed, 35 insertions, 28 deletions
diff --git a/tests/run_make_tests.pl b/tests/run_make_tests.pl
index 61ec6039..feb1f5d7 100644
--- a/tests/run_make_tests.pl
+++ b/tests/run_make_tests.pl
@@ -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');
diff --git a/tests/scripts/features/errors b/tests/scripts/features/errors
index f395032c..2cdaf31d 100644
--- a/tests/scripts/features/errors
+++ b/tests/scripts/features/errors
@@ -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 := .
diff --git a/tests/scripts/features/exec b/tests/scripts/features/exec
index 54ab1447..29cba02a 100644
--- a/tests/scripts/features/exec
+++ b/tests/scripts/features/exec
@@ -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");
diff --git a/tests/scripts/features/implicit_search b/tests/scripts/features/implicit_search
index da9b65b5..564dc5bb 100644
--- a/tests/scripts/features/implicit_search
+++ b/tests/scripts/features/implicit_search
@@ -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);
}
}
diff --git a/tests/scripts/features/loadapi b/tests/scripts/features/loadapi
index 640ac745..a72f1f1b 100644
--- a/tests/scripts/features/loadapi
+++ b/tests/scripts/features/loadapi
@@ -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");
diff --git a/tests/scripts/features/output-sync b/tests/scripts/features/output-sync
index b175b820..13a54ca0 100644
--- a/tests/scripts/features/output-sync
+++ b/tests/scripts/features/output-sync
@@ -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
diff --git a/tests/scripts/misc/fopen-fail b/tests/scripts/misc/fopen-fail
index 2ec9810b..18e0b7d0 100644
--- a/tests/scripts/misc/fopen-fail
+++ b/tests/scripts/misc/fopen-fail
@@ -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.
diff --git a/tests/scripts/options/symlinks b/tests/scripts/options/symlinks
index bf8a8927..83dc84fb 100644
--- a/tests/scripts/options/symlinks
+++ b/tests/scripts/options/symlinks
@@ -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;
diff --git a/tests/thelp.pl b/tests/thelp.pl
index ed8c819e..993339cb 100755
--- a/tests/thelp.pl
+++ b/tests/thelp.pl
@@ -24,7 +24,7 @@
$| = 1;
my $quiet = 0;
-my $timeout = 4;
+my $timeout = 10;
sub op {
my ($op, $nm) = @_;