summaryrefslogtreecommitdiff
path: root/tests/scripts/features/double_colon
blob: b94fc57c2ee92c756f806fcaa1cb9de7952c4b1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#                                                                    -*-perl-*-
$description = "Test handling of double-colon rules.";

$details = "\
We test these features:

  - Multiple commands for the same (double-colon) target
  - Different prerequisites for targets: only out-of-date
    ones are rebuilt.
  - Double-colon targets that aren't the goal target.

Then we do the same thing for parallel builds: double-colon
targets should always be built serially.";

# The Contents of the MAKEFILE ...

open(MAKEFILE,"> $makefile");

print MAKEFILE <<'EOF';

all: baz

foo:: f1.h ; @echo foo FIRST
foo:: f2.h ; @echo foo SECOND

bar:: ; @echo aaa; sleep 1; echo aaa done
bar:: ; @echo bbb

baz:: ; @echo aaa
baz:: ; @echo bbb

biz:: ; @echo aaa
biz:: two ; @echo bbb

two: ; @echo two

f1.h f2.h: ; @echo $@

EOF

close(MAKEFILE);

# TEST 0: A simple double-colon rule that isn't the goal target.

&run_make_with_options($makefile, "all", &get_logfile, 0);
$answer = "aaa\nbbb\n";
&compare_output($answer, &get_logfile(1));

# TEST 1: As above, in parallel

&run_make_with_options($makefile, "-j10 all", &get_logfile, 0);
$answer = "aaa\nbbb\n";
&compare_output($answer, &get_logfile(1));

# TEST 2: A simple double-colon rule that is the goal target

&run_make_with_options($makefile, "bar", &get_logfile, 0);
$answer = "aaa\naaa done\nbbb\n";
&compare_output($answer, &get_logfile(1));

# TEST 3: As above, in parallel

&run_make_with_options($makefile, "-j10 bar", &get_logfile, 0);
$answer = "aaa\naaa done\nbbb\n";
&compare_output($answer, &get_logfile(1));

# TEST 4: Each double-colon rule is supposed to be run individually

&touch('f2.h');
&touch('foo');

&run_make_with_options($makefile, "foo", &get_logfile, 0);
$answer = "f1.h\nfoo FIRST\n";
&compare_output($answer, &get_logfile(1));

# TEST 5: Again, in parallel.

&run_make_with_options($makefile, "-j10 foo", &get_logfile, 0);
$answer = "f1.h\nfoo FIRST\n";
&compare_output($answer, &get_logfile(1));

# TEST 6: Each double-colon rule is supposed to be run individually

&touch('f1.h');
unlink('f2.h');
&touch('foo');

&run_make_with_options($makefile, "foo", &get_logfile, 0);
$answer = "f2.h\nfoo SECOND\n";
&compare_output($answer, &get_logfile(1));

# TEST 7: Again, in parallel.

&run_make_with_options($makefile, "-j10 foo", &get_logfile, 0);
$answer = "f2.h\nfoo SECOND\n";
&compare_output($answer, &get_logfile(1));

# TEST 8: I don't grok why this is different than the above, but it is...

&run_make_with_options($makefile, "-j10 biz", &get_logfile, 0);
$answer = "aaa\ntwo\nbbb\n";
&compare_output($answer, &get_logfile(1));

unlink('foo','f1.h','f2.h');

1;