Debian Codegraph @

tests/scripts/features/suffixrules

raw
1 # -*-perl-*-
2
3 $description = "Test suffix rules.";
4
5 $details = "";
6
7 # TEST #0: Clear all suffixes
8
9 touch('foo.c');
10
11 run_make_test(q!
12 .SUFFIXES:
13 all: foo.o ; @echo $@ $<
14 !,
15 '', "#MAKE#: *** No rule to make target 'foo.o', needed by 'all'. Stop.\n", 512);
16
17 unlink('foo.c');
18
19 # Test #1: Add a simple suffix rule
20
21 touch('foo.baz');
22
23 run_make_test(q!
24 .SUFFIXES: .biz .baz
25
26 .baz.biz: ; @echo make $@
27 !,
28 'foo.biz', "make foo.biz\n");
29
30 unlink('foo.baz');
31
32 # Test #2: Make sure the defaults still work
33
34 touch('foo.c');
35
36 run_make_test(undef, 'foo.o COMPILE.c=@echo OUTPUT_OPTION=', "foo.c\n");
37
38 unlink('foo.c');
39
40 # Test #3: Replacing all suffixes
41
42 touch('foo.baz');
43
44 run_make_test(q!
45 .SUFFIXES:
46 .SUFFIXES: .biz .baz
47
48 .baz.biz: ; @echo make $@
49 !,
50 'foo.biz', "make foo.biz\n");
51
52 unlink('foo.baz');
53
54 # SV 40657: Test #4: "Suffix rules" with deps are normal rules
55
56 my $prewarn = 'warning: ignoring prerequisites on suffix rule definition';
57
58 touch('foo.bar');
59
60 run_make_test(q!
61 .SUFFIXES:
62 .SUFFIXES: .biz .baz
63
64 $X.POSIX:
65
66 .baz.biz: foo.bar ; @echo make $@ from $<
67 !,
68 'X=1 .baz.biz', "#MAKEFILE#:7: $prewarn\nmake .baz.biz from foo.bar\n");
69
70 # SV 40657: Test #5: In POSIX mode we don't get a warning
71
72 run_make_test(undef, 'X= .baz.biz', "make .baz.biz from foo.bar\n");
73
74 unlink('foo.bar');
75
76 # SV 40657: Test #6: In POSIX mode, no pattern rules should be created
77
78 utouch(-20, 'foo.baz');
79
80 run_make_test(undef,
81 'X= foo.biz', "#MAKE#: *** No rule to make target 'foo.biz'. Stop.\n", 512);
82
83 # SV 40657: Test #7: In Non-POSIX mode, a pattern rule is created
84
85 run_make_test(undef,
86 'X=1 foo.biz', "#MAKEFILE#:7: $prewarn\nmake foo.biz from foo.baz\n");
87
88 # SV 40657: Test #8: ... but any prerequisites are ignored
89
90 utouch(-10, 'foo.biz');
91 touch('foo.bar');
92
93 run_make_test(undef,
94 'X=1 foo.biz', "#MAKEFILE#:7: $prewarn\n#MAKE#: 'foo.biz' is up to date.\n");
95
96 unlink('foo.baz', 'foo.biz', 'foo.bar');
97
98 # Complete
99 1;