* Some final cleanups, and release 3.79.
[platform/upstream/make.git] / tests / scripts / options / dash-n
1 #                                                                    -*-perl-*-
2 $description = "Test the -n option.\n";
3
4 $details = "Try various uses of -n and ensure they all give the correct results.\n";
5
6 open(MAKEFILE, "> $makefile");
7
8 # The Contents of the MAKEFILE ...
9
10 print MAKEFILE <<'EOMAKE';
11
12 final: intermediate ; echo >> $@
13 intermediate: orig ; echo >> $@
14
15 EOMAKE
16
17 close(MAKEFILE);
18
19 &touch('orig');
20
21 # TEST 0
22
23 &run_make_with_options($makefile, "", &get_logfile);
24 $answer = "echo >> intermediate\necho >> final\n";
25 &compare_output($answer, &get_logfile(1));
26
27 # TEST 1
28
29 &run_make_with_options($makefile, "-Worig -n", &get_logfile);
30 $answer = "echo >> intermediate\necho >> final\n";
31 &compare_output($answer, &get_logfile(1));
32
33 unlink('orig', 'intermediate', 'final');
34
35 # We consider the actual updated timestamp of targets with all
36 # recursive commands, even with -n.
37
38 $makefile2 = &get_tmpfile;
39
40 open(MAKEFILE, "> $makefile2");
41
42 print MAKEFILE <<'EOF';
43 .SUFFIXES:
44 BAR =     # nothing
45 FOO = +$(BAR)
46 a: b; echo > $@
47 b: c; $(FOO)
48 EOF
49
50 close(MAKEFILE);
51
52 &touch('b');
53 # Sometimes, on my Solaris 2.5.1 box with a NetApp filesystem NFS-mounted,
54 # just touching b first then a isn't good enough: the nsec field in the
55 # stat result shows b is _newer_ than a once every 5 or 6 tries!!!  I've
56 # no idea what this is about, but that's why there's a sleep(1) here...
57 sleep(1);
58 &touch('a');
59 sleep(1);
60 &touch('c');
61
62 # TEST 2
63
64 &run_make_with_options($makefile2, "", &get_logfile);
65 $answer = "$make_name: `a' is up to date.\n";
66 &compare_output($answer, &get_logfile(1));
67
68 # TEST 3
69
70 &run_make_with_options($makefile2, "-n", &get_logfile);
71 $answer = "$make_name: `a' is up to date.\n";
72 &compare_output($answer, &get_logfile(1));
73
74 unlink('a', 'b', 'c');
75
76 1;