make/tests/scripts/features/vpathplus

91 lines
2.1 KiB
Text
Raw Normal View History

# -*-perl-*-
$description = "Tests the new VPATH+ functionality added in 3.76.";
$details = "";
tests: Run each file in a separate directory 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).
2023-04-02 21:32:09 +00:00
mkdir('work');
$VP = "work$pathsep";
@touchedfiles = ();
$off = -500;
sub touchfiles {
foreach (@_) {
&utouch($off, $_);
$off += 10;
push(@touchedfiles, $_);
}
}
&touchfiles("$VP/foo.d", "$VP/bar.d", "$VP/foo.c", "$VP/bar.c", "foo.b", "bar.d");
# Run the general-case test
run_make_test(qq!VPATH = $VP! . q!
.SUFFIXES: .a .b .c .d
.PHONY: general rename notarget intermediate
%.a:
%.b:
%.c:
%.d:
%.a : %.b ; cat $^ > $@
%.b : %.c ; cat $^ > $@ 2>/dev/null || exit 1
%.c :: %.d ; cat $^ > $@
# General testing info:
general: foo.b
foo.b: foo.c bar.c
# Rename testing info:
rename: $(VPATH)/foo.c foo.d
# Target not made testing info:
notarget: notarget.b
notarget.c: notarget.d ; -@echo "not creating $@ from $^"
# Intermediate files:
intermediate: inter.a
!,
'general', "cat bar.d > bar.c\ncat ${VP}foo.c bar.c > foo.b 2>/dev/null || exit 1\n");
push(@touchedfiles, "bar.c");
# Test rules that don't make the target correctly
&touchfiles("$VP/notarget.c", "notarget.b", "notarget.d");
run_make_test(undef, 'notarget', "not creating notarget.c from notarget.d\ncat notarget.c > notarget.b 2>/dev/null || exit 1\n#MAKE#: *** [#MAKEFILE#:11: notarget.b] Error 1\n", 512);
# Test intermediate file handling (part 1)
&touchfiles("$VP/inter.d");
my $be = pack("L", 1) eq pack("N", 1);
my $intfiles = $be ? "inter.c inter.b" : "inter.b inter.c";
run_make_test(undef, 'intermediate', "cat ${VP}inter.d > inter.c\ncat inter.c > inter.b 2>/dev/null || exit 1\ncat inter.b > inter.a\nrm $intfiles\n");
push(@touchedfiles, "inter.a", "inter.b");
# Test intermediate file handling (part 2)
&utouch(-20, "inter.a");
&utouch(-10, "$VP/inter.b");
&touch("$VP/inter.d");
run_make_test(undef, 'intermediate', "cat ${VP}inter.d > inter.c\ncat inter.c > inter.b 2>/dev/null || exit 1\ncat inter.b > inter.a\nrm inter.c\n");
push(@touchedfiles, "$VP/inter.b", "$VP/inter.d");
unlink @touchedfiles unless $keep;
1;