make/tests/scripts/options/dash-k

117 lines
2.9 KiB
Text
Raw Normal View History

# -*-perl-*-
$description = "Test the make -k (don't stop on error) option.\n";
$details = "\
The makefile created in this test is a simulation of building
a small product. However, the trick to this one is that one
of the dependencies of the main target does not exist.
Without the -k option, make would fail immediately and not
build any part of the target. What we are looking for here,
is that make builds the rest of the dependencies even though
it knows that at the end it will fail to rebuild the main target.";
open(MAKEFILE,"> $makefile");
# The Contents of the MAKEFILE ...
print MAKEFILE <<EOF;
VPATH = $workdir
edit: main.o kbd.o commands.o display.o
\t\@echo cc -o edit main.o kbd.o commands.o display.o
main.o : main.c defs.h
\t\@echo cc -c main.c
kbd.o : kbd.c defs.h command.h
\t\@echo cc -c kbd.c
commands.o : command.c defs.h command.h
\t\@echo cc -c commands.c
display.o : display.c defs.h buffer.h
\t\@echo cc -c display.c
EOF
# END of Contents of MAKEFILE
close(MAKEFILE);
@files_to_touch = ("$workdir${pathsep}main.c","$workdir${pathsep}defs.h",
"$workdir${pathsep}command.h",
"$workdir${pathsep}commands.c","$workdir${pathsep}display.c",
"$workdir${pathsep}buffer.h",
"$workdir${pathsep}command.c");
&touch(@files_to_touch);
if ($vos) {
$error_code = 3307;
}
else {
$error_code = 512;
}
&run_make_with_options($makefile, "-k", &get_logfile, $error_code);
# Create the answer to what should be produced by this Makefile
$answer = "cc -c main.c
$make_name: *** No rule to make target 'kbd.c', needed by 'kbd.o'.
cc -c commands.c
cc -c display.c
$make_name: Target 'edit' not remade because of errors.\n";
# COMPARE RESULTS
&compare_output($answer, &get_logfile(1));
unlink(@files_to_touch) unless $keep;
# TEST 1: Make sure that top-level targets that depend on targets that
# previously failed to build, aren't attempted. Regression for PR/1634.
$makefile2 = &get_tmpfile;
open(MAKEFILE, "> $makefile2");
print MAKEFILE <<'EOF';
.SUFFIXES:
all: exe1 exe2; @echo making $@
exe1 exe2: lib; @echo cp $^ $@
lib: foo.o; @echo cp $^ $@
foo.o: ; exit 1
EOF
close(MAKEFILE);
&run_make_with_options($makefile2, "-k", &get_logfile, $error_code);
$answer = "exit 1
$make_name: *** [$makefile2:9: foo.o] Error 1
$make_name: Target 'all' not remade because of errors.\n";
&compare_output($answer, &get_logfile(1));
# TEST -- make sure we keep the error code if we can't create an included
# makefile.
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-04-17 19:37:57 +00:00
if (defined $ERR_no_such_file) {
run_make_test('all: ; @echo hi
include ifile
ifile: no-such-file; @false
',
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-04-17 19:37:57 +00:00
'-k',
"#MAKEFILE#:2: ifile: $ERR_no_such_file
#MAKE#: *** No rule to make target 'no-such-file', needed by 'ifile'.
#MAKE#: Failed to remake makefile 'ifile'.
hi\n",
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-04-17 19:37:57 +00:00
512);
}
1;