Debian Codegraph @

tests/scripts/features/errors

raw
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 # Windows error look completely different :-/
35
36 sub errors_getinfo
37 {
38 my ($cmd, $args, $err) = @_;
39 if ($port_type eq 'W32') {
40 return (2, "process_begin: CreateProcess(NULL, $cmd$args, ...) failed.\nmake (e=2): The system cannot find the file specified.");
41 }
42
43 if (!$err) { $err = $ERR_no_such_file; }
44 return (127, "#MAKE#: $cmd: $err");
45 }
46
47 # TEST #3
48 # -------
49
50 # Try failing due to unknown command
51 my $unk = './foobarbazbozblat';
52 unlink($unk);
53
54 my ($ernum, $erstr) = errors_getinfo($unk, " xx yy");
55 run_make_test(qq!
56 one: ; -$unk xx yy
57 !, 'one',
58 "$unk xx yy\n$erstr\n#MAKE#: [#MAKEFILE#:2: one] Error $ernum (ignored)\n");
59
60 # TEST #4
61 # -------
62
63 ($ernum, $erstr) = errors_getinfo($unk, " aa bb");
64 run_make_test(qq!
65 two: ; $unk aa bb
66 !, 'two -i',
67 "$unk aa bb\n$erstr\n#MAKE#: [#MAKEFILE#:2: two] Error $ernum (ignored)\n");
68
69 # TEST #5
70 # -------
71
72 run_make_test(undef, 'two',
73 "$unk aa bb\n$erstr\n#MAKE#: *** [#MAKEFILE#:2: two] Error $ernum\n", 512);
74
75 # SV #56918 : Test the unknown command as the second recipe line
76
77 ($ernum, $erstr) = errors_getinfo($unk, " qq rr");
78 run_make_test(qq!
79 three:
80 \t\@echo one
81 \t$unk qq rr
82 !, 'three',
83 "one\n$unk qq rr\n$erstr\n#MAKE#: *** [#MAKEFILE#:4: three] Error $ernum\n", 512);
84
85 # Try failing due to non-executable file
86
87 if ($ERR_nonexe_file) {
88 my $noexe = './barfooblatboz';
89 touch($noexe);
90
91 run_make_test(qq!
92 one: ; -$noexe xx yy
93 two: ; $noexe aa bb
94 !,
95 'one', "$noexe xx yy\n#MAKE#: $noexe: $ERR_nonexe_file\n#MAKE#: [#MAKEFILE#:2: one] Error 127 (ignored)\n");
96
97 unlink($noexe);
98 }
99
100 # Try failing by "running" a directory
101
102 if ($ERR_exe_dir) {
103 mkdir('sd', 0775) or print "mkdir: sd: $!\n";
104
105 ($ernum, $erstr) = errors_getinfo('sd', '', $ERR_exe_dir);
106
107 run_make_test(q!
108 PATH := .
109 all: ; sd
110 !,
111 '', "sd\n$erstr\n#MAKE#: *** [#MAKEFILE#:3: all] Error $ernum", 512);
112
113 if ($port_type eq 'W32') {
114 $ernum = 5;
115 $erstr = "process_begin: CreateProcess(NULL, ./sd, ...) failed.\nmake (e=5): Access is denied.";
116 } else {
117 $ernum = 127;
118 $erstr = "#MAKE#: ./sd: $ERR_exe_dir";
119 }
120
121 run_make_test(q!
122 all: ; ./sd
123 !,
124 '', "./sd\n$erstr\n#MAKE#: *** [#MAKEFILE#:2: all] Error $ernum", 512);
125
126 rmdir('sd');
127 }
128
129 1;