mirror of
https://github.com/mirror/make.git
synced 2025-01-10 20:30:20 +08:00
414af96a50
Go through both run_make_tests.pl and test_driver.pl and slightly modernize the Perl and clean up indentation etc. Fix a number of warnings in the test scripts detected by running with -w. * tests/test_driver.pl: Move make error string detection out of the base test driver. (run_all_tests): Ensure that we always look for tests in the cwd. * tests/run_make_tests.pl: Use File::Spec for path manipulations. Correctly use setlocale() when detecting error strings. Get configuration from the config-flags.pm file not config.status. * tests/scripts/features/archives: Use new $cwddir variable. * tests/scripts/features/reinvoke: Add missing semicolon. * tests/scripts/features/vpath2: Avoid non-existent variable. * tests/scripts/functions/foreach: Escape variables. * tests/scripts/misc/bs-nl: Remove non-existing \v escape sequence. * tests/scripts/misc/general4: Use handy create_file(). * tests/scripts/options/dash-C: Use Cwd/$cwddir. * tests/scripts/options/dash-I: Use subst_make_string() and #PWD#. * tests/scripts/options/symlinks: Use File::Spec. * tests/scripts/targets/DEFAULT: Use create_file and run_make_test. * tests/scripts/variables/CURDIR: Use run_make_test. * tests/scripts/variables/automatic: Remove extraneous "\". * tests/scripts/vms/library: Remove extra "my" and extraneous "\".
68 lines
2.1 KiB
Perl
68 lines
2.1 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
|
|
|
|
# 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;
|
|
}
|
|
|
|
# Set up a symlink sym -> dep
|
|
# We'll make both dep and targ older than sym
|
|
&utouch(-10, 'dep');
|
|
&utouch(-5, 'targ');
|
|
|
|
$dirnm = (splitdir($cwddir))[-1];
|
|
symlink(catfile(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;
|