make/tests/scripts/features/vpathplus
Paul Smith fda00f88d3 Add test suite support to Windows
* main.c (main): Sanitize program name detection on Windows.
* makeint.h: 'program' is a const string on all platforms now.
* tests/run_make_tests.bat: Windows bat file to invoke tests
* tests/test_driver.pl: Obtain system-specific error messages.
(get_osname): Compute the $port_type here.  Add more $osname checks
for different Windows Perl ports.
(_run_command): Rewrite the timeout capability to work properly
with Windows.  Don't use Perl fork/exec; instead use system(1,...)
which allows a more reliable/proper kill operation.
Also, allow options to be given as a list instead of a string, to
allow more complex quoting of command-line arguments.
* tests/run_make_tests.pl (run_make_with_options): Allow options
to be provided as a list in addition to a simple string.
(set_more_defaults): Write sample makefiles and run make on them
instead of trying to run echo and invoking make with -f-, to avoid
relying on shell and echo to get basic configuration values.  Also
create a $sh_name variable instead of hard-coding /bin/sh.
* tests/scripts/features/archives: Skip on Windows.
* tests/scripts/features/escape: Use list method for passing options.
* tests/scripts/features/include: Use system-specific error messages.
* tests/scripts/features/output-sync: "Command not found" errors
generate very different / odd output on Windows.  This needs to be
addressed but for now disable these tests on Windows.
* tests/scripts/functions/abspath: Disable on Windows.
* tests/scripts/functions/file: Use system-specific error messages.
* tests/scripts/functions/shell: "Command not found" errors generate
very different / odd output on Windows.  This needs to be addressed
but for now disable these tests on Windows.
* tests/scripts/misc/close_stdout: Disable on Windows.
* tests/scripts/options/dash-k: Use system-specific error messages.
* tests/scripts/options/dash-l: Disable on Windows.
* tests/scripts/options/eval: Use list method for passing options.
* tests/scripts/options/general: Skip some non-portable tests.
* tests/scripts/targets/ONESHELL: Skip some non-portable tests.
* tests/scripts/targets/POSIX: Skip some non-portable tests.
* tests/scripts/variables/MAKEFILES: Skip some non-portable tests.
* tests/scripts/variables/SHELL: Use a makefile not -f- for testing.
2017-06-04 18:37:20 -04:00

129 lines
2.5 KiB
Perl

# -*-perl-*-
$description = "Tests the new VPATH+ functionality added in 3.76.";
$details = "";
$VP = "$workdir$pathsep";
open(MAKEFILE,"> $makefile");
# The Contents of the MAKEFILE ...
print MAKEFILE "VPATH = $VP\n";
print MAKEFILE <<'EOMAKE';
.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
EOMAKE
close(MAKEFILE);
@touchedfiles = ();
$off = -500;
sub touchfiles {
foreach (@_) {
&utouch($off, $_);
$off += 10;
push(@touchedfiles, $_);
}
}
# Run the general-case test
&touchfiles("$VP/foo.d", "$VP/bar.d", "$VP/foo.c", "$VP/bar.c", "foo.b", "bar.d");
&run_make_with_options($makefile,"general",&get_logfile);
push(@touchedfiles, "bar.c");
$answer = "cat bar.d > bar.c
cat ${VP}foo.c bar.c > foo.b 2>/dev/null || exit 1
";
&compare_output($answer,&get_logfile(1));
# Test rules that don't make the target correctly
&touchfiles("$VP/notarget.c", "notarget.b", "notarget.d");
&run_make_with_options($makefile,"notarget",&get_logfile,512);
$answer = "not creating notarget.c from notarget.d
cat notarget.c > notarget.b 2>/dev/null || exit 1
$make_name: *** [$makefile:13: notarget.b] Error 1
";
&compare_output($answer,&get_logfile(1));
# Test intermediate file handling (part 1)
&touchfiles("$VP/inter.d");
&run_make_with_options($makefile,"intermediate",&get_logfile);
push(@touchedfiles, "inter.a", "inter.b");
$answer = "cat ${VP}inter.d > inter.c
cat inter.c > inter.b 2>/dev/null || exit 1
cat inter.b > inter.a
rm inter.b inter.c
";
&compare_output($answer,&get_logfile(1));
# Test intermediate file handling (part 2)
&utouch(-20, "inter.a");
&utouch(-10, "$VP/inter.b");
&touch("$VP/inter.d");
push(@touchedfiles, "$VP/inter.b", "$VP/inter.d");
&run_make_with_options($makefile,"intermediate",&get_logfile);
$answer = "cat ${VP}inter.d > inter.c
cat inter.c > inter.b 2>/dev/null || exit 1
cat inter.b > inter.a
rm inter.c
";
&compare_output($answer,&get_logfile(1));
unlink @touchedfiles unless $keep;
1;
### Local Variables:
### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
### End: