depsrc-ignore.mk revision 1.5 1 1.5 rillig # $NetBSD: depsrc-ignore.mk,v 1.5 2020/11/15 20:20:58 rillig Exp $
2 1.1 rillig #
3 1.3 rillig # Tests for the special source .IGNORE in dependency declarations,
4 1.3 rillig # which ignores any command failures for that target.
5 1.3 rillig #
6 1.5 rillig # Even though 'ignore-errors' fails, 'all' is still made. Since 'all' is
7 1.5 rillig # not marked with .IGNORE, it stops at the first failing command.
8 1.3 rillig #
9 1.4 rillig # XXX: The ordering of the messages in the output is confusing.
10 1.3 rillig # The "ignored" comes much too late to be related to the "false
11 1.4 rillig # ignore-errors". This is due to stdout being buffered.
12 1.4 rillig #
13 1.4 rillig # The "continuing" message comes from the -k option. If there had been
14 1.4 rillig # other targets independent of "all", these would be built as well.
15 1.4 rillig #
16 1.4 rillig # Enabling the debugging option -de changes the order in which the messages
17 1.4 rillig # appear. Now the "ignored" message is issued in the correct position.
18 1.4 rillig # The explanation for the output reordering is that the output is buffered.
19 1.4 rillig # As the manual page says, in debugging mode stdout is line buffered.
20 1.4 rillig # In these tests the output is redirected to a file, therefore stdout is
21 1.4 rillig # fully buffered.
22 1.4 rillig #
23 1.4 rillig # This is what actually happens, as of 2020-08-29. To verify it, set the
24 1.4 rillig # following breakpoints in CompatRunCommand:
25 1.4 rillig #
26 1.5 rillig # * the "!silent" line, to see all commands
27 1.5 rillig # * the "fflush" line, to see stdout being flushed
28 1.4 rillig # * the "status = WEXITSTATUS" line
29 1.4 rillig # * the "(continuing)" line
30 1.4 rillig # * the "(ignored)" line
31 1.4 rillig #
32 1.4 rillig # The breakpoints are visited in the following order:
33 1.4 rillig #
34 1.4 rillig # "ignore-errors begin"
35 1.4 rillig # Goes directly to STDOUT_FILENO since it is run in a child process.
36 1.4 rillig # "false ignore-errors"
37 1.4 rillig # Goes to the stdout buffer (CompatRunCommand, keyword "!silent") and
38 1.4 rillig # the immediate call to fflush(stdout) copies it to STDOUT_FILENO.
39 1.4 rillig # "*** Error code 1 (ignored)"
40 1.4 rillig # Goes to the stdout buffer but is not flushed (CompatRunCommand, near
41 1.4 rillig # the end).
42 1.4 rillig # "ignore-errors end"
43 1.4 rillig # Goes directly to STDOUT_FILENO.
44 1.4 rillig # "all begin"
45 1.4 rillig # Goes directly to STDOUT_FILENO.
46 1.4 rillig # "false all"
47 1.4 rillig # Goes to the stdout buffer, where the "*** Error code 1 (ignored)" is
48 1.4 rillig # still waiting to be flushed. These two lines are flushed now.
49 1.4 rillig # "*** Error code 1 (continuing)"
50 1.4 rillig # Goes to the stdout buffer.
51 1.4 rillig # "Stop."
52 1.4 rillig # Goes to the stdout buffer.
53 1.4 rillig # exit(1)
54 1.4 rillig # Flushes the stdout buffer to STDOUT_FILENO.
55 1.3 rillig
56 1.3 rillig all: ignore-errors
57 1.1 rillig
58 1.3 rillig ignore-errors: .IGNORE
59 1.3 rillig @echo $@ begin
60 1.3 rillig false $@
61 1.3 rillig @echo $@ end
62 1.1 rillig
63 1.1 rillig all:
64 1.3 rillig @echo $@ begin
65 1.3 rillig false $@
66 1.3 rillig @echo $@ end
67