1 1.1 christos # -*-perl-*- 2 1.1 christos $description = "Test the -n option.\n"; 3 1.1 christos 4 1.1 christos $details = "Try various uses of -n and ensure they all give the correct results.\n"; 5 1.1 christos 6 1.1 christos open(MAKEFILE, "> $makefile"); 7 1.1 christos 8 1.1 christos # The Contents of the MAKEFILE ... 9 1.1 christos 10 1.1 christos print MAKEFILE <<'EOMAKE'; 11 1.1 christos 12 1.1 christos final: intermediate ; echo >> $@ 13 1.1 christos intermediate: orig ; echo >> $@ 14 1.1 christos 15 1.1 christos EOMAKE 16 1.1 christos 17 1.1 christos close(MAKEFILE); 18 1.1 christos 19 1.1 christos &touch('orig'); 20 1.1 christos 21 1.1 christos # TEST 0 22 1.1 christos 23 1.1 christos &run_make_with_options($makefile, "", &get_logfile); 24 1.1 christos $answer = "echo >> intermediate\necho >> final\n"; 25 1.1 christos &compare_output($answer, &get_logfile(1)); 26 1.1 christos 27 1.1 christos # TEST 1 28 1.1 christos 29 1.1 christos &run_make_with_options($makefile, "-Worig -n", &get_logfile); 30 1.1 christos $answer = "echo >> intermediate\necho >> final\n"; 31 1.1 christos &compare_output($answer, &get_logfile(1)); 32 1.1 christos 33 1.1 christos unlink('orig', 'intermediate', 'final'); 34 1.1 christos 35 1.1 christos # We consider the actual updated timestamp of targets with all 36 1.1 christos # recursive commands, even with -n. 37 1.1 christos 38 1.1 christos $makefile2 = &get_tmpfile; 39 1.1 christos 40 1.1 christos open(MAKEFILE, "> $makefile2"); 41 1.1 christos 42 1.1 christos print MAKEFILE <<'EOF'; 43 1.1 christos .SUFFIXES: 44 1.1 christos BAR = # nothing 45 1.1 christos FOO = +$(BAR) 46 1.1 christos a: b; echo > $@ 47 1.1 christos b: c; $(FOO) 48 1.1 christos EOF 49 1.1 christos 50 1.1 christos close(MAKEFILE); 51 1.1 christos 52 1.1 christos &utouch(-20, 'b'); 53 1.1 christos &utouch(-10, 'a'); 54 1.1 christos &touch('c'); 55 1.1 christos 56 1.1 christos # TEST 2 57 1.1 christos 58 1.1 christos &run_make_with_options($makefile2, "", &get_logfile); 59 1.1 christos $answer = "$make_name: `a' is up to date.\n"; 60 1.1 christos &compare_output($answer, &get_logfile(1)); 61 1.1 christos 62 1.1 christos # TEST 3 63 1.1 christos 64 1.1 christos &run_make_with_options($makefile2, "-n", &get_logfile); 65 1.1 christos $answer = "$make_name: `a' is up to date.\n"; 66 1.1 christos &compare_output($answer, &get_logfile(1)); 67 1.1 christos 68 1.1 christos unlink('a', 'b', 'c'); 69 1.1 christos 70 1.1 christos 1; 71