make/tests/scripts/options/symlinks
Paul Smith cad3ddd165 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.
2022-10-22 22:37:49 -04:00

62 lines
1.9 KiB
Perl

# -*-perl-*-
$description = "Test the -L option.";
$details = "Verify that symlink handling with and without -L works properly.";
# Only run these tests if the system sypports symlinks
exists $FEATURES{'check-symlink'} or return -1;
use File::Spec;
# Set up a symlink sym -> dep
# We'll make both dep and targ older than sym
&utouch(-10, 'dep');
&utouch(-5, 'targ');
$dirnm = (File::Spec->splitdir($cwddir))[-1];
symlink(File::Spec->catfile(File::Spec->updir(), $dirnm, 'dep'), 'sym');
# Without -L, nothing should happen
# With -L, it should update targ
run_make_test('targ: sym ; @echo make $@ from $<', '',
"#MAKE#: 'targ' is up to date.");
run_make_test(undef, '-L', "make targ from sym");
# Now update dep; in all cases targ should be out of date.
&touch('dep');
run_make_test(undef, '', "make targ from sym");
run_make_test(undef, '-L', "make targ from sym");
# Now update targ; in all cases targ should be up to date.
&touch('targ');
run_make_test(undef, '', "#MAKE#: 'targ' is up to date.");
run_make_test(undef, '-L', "#MAKE#: 'targ' is up to date.");
# Add in a new link between sym and dep. Be sure it's newer than targ.
sleep(1);
rename('dep', 'dep1');
symlink('dep1', 'dep');
# Without -L, nothing should happen
# With -L, it should update targ
run_make_test(undef, '', "#MAKE#: 'targ' is up to date.");
run_make_test(undef, '-L', "make targ from sym");
rmfiles('targ', 'dep', 'sym', 'dep1');
# Check handling when symlinks point to non-existent files. Without -L we
# should get an error: with -L we should use the timestamp of the symlink.
symlink("../$dirnm/dep", 'sym');
run_make_test('targ: sym ; @echo make $@ from $<', '',
"#MAKE#: *** No rule to make target 'sym', needed by 'targ'. Stop.", 512);
run_make_test('targ: sym ; @echo make $@ from $<', '-L',
'make targ from sym');
rmfiles('targ', 'sym');
1;