1 | # -*-perl-*-
|
---|
2 |
|
---|
3 | $description = "Test the make -k (don't stop on error) option.\n";
|
---|
4 |
|
---|
5 | $details = "\
|
---|
6 | The makefile created in this test is a simulation of building
|
---|
7 | a small product. However, the trick to this one is that one
|
---|
8 | of the dependencies of the main target does not exist.
|
---|
9 | Without the -k option, make would fail immediately and not
|
---|
10 | build any part of the target. What we are looking for here,
|
---|
11 | is that make builds the rest of the dependencies even though
|
---|
12 | it knows that at the end it will fail to rebuild the main target.";
|
---|
13 |
|
---|
14 | open(MAKEFILE,"> $makefile");
|
---|
15 |
|
---|
16 | # The Contents of the MAKEFILE ...
|
---|
17 |
|
---|
18 | print MAKEFILE <<EOF;
|
---|
19 | VPATH = $workdir
|
---|
20 | edit: main.o kbd.o commands.o display.o
|
---|
21 | \t\@echo cc -o edit main.o kbd.o commands.o display.o
|
---|
22 |
|
---|
23 | main.o : main.c defs.h
|
---|
24 | \t\@echo cc -c main.c
|
---|
25 |
|
---|
26 | kbd.o : kbd.c defs.h command.h
|
---|
27 | \t\@echo cc -c kbd.c
|
---|
28 |
|
---|
29 | commands.o : command.c defs.h command.h
|
---|
30 | \t\@echo cc -c commands.c
|
---|
31 |
|
---|
32 | display.o : display.c defs.h buffer.h
|
---|
33 | \t\@echo cc -c display.c
|
---|
34 | EOF
|
---|
35 |
|
---|
36 | # END of Contents of MAKEFILE
|
---|
37 |
|
---|
38 | close(MAKEFILE);
|
---|
39 |
|
---|
40 |
|
---|
41 | @files_to_touch = ("$workdir${pathsep}main.c","$workdir${pathsep}defs.h",
|
---|
42 | "$workdir${pathsep}command.h",
|
---|
43 | "$workdir${pathsep}commands.c","$workdir${pathsep}display.c",
|
---|
44 | "$workdir${pathsep}buffer.h",
|
---|
45 | "$workdir${pathsep}command.c");
|
---|
46 |
|
---|
47 | &touch(@files_to_touch);
|
---|
48 |
|
---|
49 | if ($vos) {
|
---|
50 | $error_code = 3307;
|
---|
51 | }
|
---|
52 | else {
|
---|
53 | $error_code = 512;
|
---|
54 | }
|
---|
55 |
|
---|
56 | &run_make_with_options($makefile, "-k", &get_logfile, $error_code);
|
---|
57 |
|
---|
58 | # Create the answer to what should be produced by this Makefile
|
---|
59 | $answer = "cc -c main.c
|
---|
60 | $make_name: *** No rule to make target `kbd.c', needed by `kbd.o'.
|
---|
61 | cc -c commands.c
|
---|
62 | cc -c display.c
|
---|
63 | $make_name: Target `edit' not remade because of errors.\n";
|
---|
64 |
|
---|
65 | # COMPARE RESULTS
|
---|
66 |
|
---|
67 | &compare_output($answer, &get_logfile(1));
|
---|
68 |
|
---|
69 | unlink(@files_to_touch) unless $keep;
|
---|
70 |
|
---|
71 |
|
---|
72 | # TEST 1: Make sure that top-level targets that depend on targets that
|
---|
73 | # previously failed to build, aren't attempted. Regression for PR/1634.
|
---|
74 |
|
---|
75 | $makefile2 = &get_tmpfile;
|
---|
76 |
|
---|
77 | open(MAKEFILE, "> $makefile2");
|
---|
78 | print MAKEFILE <<'EOF';
|
---|
79 | .SUFFIXES:
|
---|
80 |
|
---|
81 | all: exe1 exe2; @echo making $@
|
---|
82 |
|
---|
83 | exe1 exe2: lib; @echo cp $^ $@
|
---|
84 |
|
---|
85 | lib: foo.o; @echo cp $^ $@
|
---|
86 |
|
---|
87 | foo.o: ; exit 1
|
---|
88 | EOF
|
---|
89 |
|
---|
90 | close(MAKEFILE);
|
---|
91 |
|
---|
92 | &run_make_with_options($makefile2, "-k", &get_logfile, $error_code);
|
---|
93 |
|
---|
94 | $answer = "exit 1
|
---|
95 | $make_name: *** [foo.o] Error 1
|
---|
96 | $make_name: Target `all' not remade because of errors.\n";
|
---|
97 |
|
---|
98 | &compare_output($answer, &get_logfile(1));
|
---|
99 |
|
---|
100 | # TEST -- make sure we keep the error code if we can't create an included
|
---|
101 | # makefile.
|
---|
102 |
|
---|
103 | run_make_test('all: ; @echo hi
|
---|
104 | include ifile
|
---|
105 | ifile: no-such-file; @false
|
---|
106 | ',
|
---|
107 | '-k',
|
---|
108 | "#MAKEFILE#:2: ifile: No such file or directory
|
---|
109 | #MAKE#: *** No rule to make target `no-such-file', needed by `ifile'.
|
---|
110 | #MAKE#: Failed to remake makefile `ifile'.
|
---|
111 | hi\n",
|
---|
112 | 512);
|
---|
113 |
|
---|
114 | 1;
|
---|