f236d5172490c3d405287b6b6583c93f12244bba
[platform/upstream/make.git] / tests / scripts / features / errors
1 #                                                                    -*-perl-*-
2
3 $description = "Test ignored failures in recipe command lines";
4
5 run_make_test(qq!
6 one:
7 \t-exit 1
8 \texit 0
9 two:
10 \texit 1
11 \texit 0
12 !,
13               "one", "exit 1\n#MAKE#: [#MAKEFILE#:3: one] Error 1 (ignored)\nexit 0\n");
14
15 # TEST #1
16 # -------
17
18 run_make_test(undef, " -i two",
19               "exit 1\n#MAKE#: [#MAKEFILE#:6: two] Error 1 (ignored)\nexit 0\n");
20
21 # TEST #2
22 # -------
23
24 # Test that error line offset works
25
26 run_make_test(qq!
27 all:
28 \t\@echo hi
29 \t\@echo there
30 \t\@exit 1
31 !,
32               '', "hi\nthere\n#MAKE#: *** [#MAKEFILE#:5: all] Error 1", 512);
33
34 # TEST #3
35 # -------
36
37 # Try failing due to unknown command
38 my $unk = './foobarbazbozblat';
39 unlink($unk);
40
41 my $err = $ERR_no_such_file;
42
43 run_make_test(qq!
44 one: ; -$unk xx yy
45 !,
46               'one', "$unk xx yy\n#MAKE#: $unk: $err\n#MAKE#: [#MAKEFILE#:2: one] Error 127 (ignored)\n");
47
48 # TEST #4
49 # -------
50
51 run_make_test(qq!
52 two: ; $unk aa bb
53 !, 'two -i',
54               "$unk aa bb\n#MAKE#: $unk: $err\n#MAKE#: [#MAKEFILE#:2: two] Error 127 (ignored)\n");
55
56 # TEST #5
57 # -------
58
59 run_make_test(undef, 'two',
60               "$unk aa bb\n#MAKE#: $unk: $err\n#MAKE#: *** [#MAKEFILE#:2: two] Error 127\n", 512);
61
62 # SV #56918 : Test the unknown command as the second recipe line
63
64 run_make_test(qq!
65 three:
66 \t\@echo one
67 \t$unk qq rr
68 !, 'three',
69               "one\n$unk qq rr\n#MAKE#: $unk: $err\n#MAKE#: *** [#MAKEFILE#:4: three] Error 127\n", 512);
70
71 # Try failing due to non-executable file
72
73 if ($ERR_nonexe_file) {
74     my $noexe = './barfooblatboz';
75     touch($noexe);
76
77     run_make_test(qq!
78     one: ; -$noexe xx yy
79     two: ; $noexe aa bb
80     !,
81                   'one', "$noexe xx yy\n#MAKE#: $noexe: $ERR_nonexe_file\n#MAKE#: [#MAKEFILE#:2: one] Error 127 (ignored)\n");
82
83     unlink($noexe);
84 }
85
86 # Try failing by "running" a directory
87
88 if ($ERR_exe_dir) {
89     mkdir('sd', 0775);
90
91     run_make_test(q!
92 PATH := .
93 all: ; sd
94 !,
95               '', "sd\n#MAKE#: sd: $ERR_exe_dir\n#MAKE#: *** [#MAKEFILE#:3: all] Error 127", 512);
96
97     run_make_test(q!
98 all: ; ./sd
99 !,
100               '', "./sd\n#MAKE#: ./sd: $ERR_exe_dir\n#MAKE#: *** [#MAKEFILE#:2: all] Error 127", 512);
101
102     rmdir('sd');
103 }
104
105 1;