mirror of
https://git.savannah.gnu.org/git/make.git
synced 2025-01-12 16:45:35 +00:00
971b02d58e
Avoid cross-contamination between test files by creating a new working directory for each file, and setting it as the current directory before starting the tests in that file. Rename the test output as tNNN.{base,log,diff,mk} where NNN is a test number starting with 001 for the first test. It is slightly more annoying to find diff files since you can't use autocomplete directly but it is simpler to match things. Detect the source directory as the location of the test_driver.pl script, so remove the separate -srcdir option. * Makefile.am: Remove hacks to create symlinks when building out-of-tree, and remove -srcdir option from run_make_tests. * tests/test_driver.pl: Locate $srcpath based on __FILE__, then compute $toppath as its parent. Set $scriptpath under $srcpath and $workpath under the current directory. Toss $*_filename and modify get_logfile() etc. to use the suffix directly. Add a chdir() around the invocation of the test. * tests/run_make_tests.pl: Throw out the -srcdir option and use $srcpath set in test_driver.pl. The #WORK# helper is no longer useful so remove it. Set #PWD# to the current working dir. Always search the local directory and $srcpath for config-flags.pm. Use $srcpath for finding the thelp.pl script. * tests/scripts/features/vpath: Don't put things in work/ as it is no longer a subdirectory. * tests/scripts/features/vpathgpath: Ditto. * tests/scripts/features/vpathplus: Ditto. * tests/scripts/misc/general1: Ditto. * tests/scripts/misc/general2: Ditto. * tests/scripts/options/dash-k: Ditto. * tests/scripts/options/symlinks: Use $testpath as the working directory. * tests/scripts/variables/GNUMAKEFLAGS: Use the test helper to display env var values (grepping for GNUMAKEFLAGS finds extra things now that it is our current working directory).
63 lines
2 KiB
Perl
63 lines
2 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');
|
|
|
|
my $dirnm = (File::Spec->splitdir($testpath))[-1];
|
|
my $dep = File::Spec->catfile(File::Spec->updir(), $dirnm, 'dep');
|
|
symlink($dep, 'sym') or die "Cannot create symlink sym -> $dep\n";
|
|
|
|
# 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;
|