Blame tests/scripts/options/dash-k

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