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