Sat Aug 29 16:13:27 2020 UTC ()
make(1): explain the shuffled messages in the test output


(rillig)
diff -r1.3 -r1.4 src/usr.bin/make/unit-tests/depsrc-ignore.mk

cvs diff -r1.3 -r1.4 src/usr.bin/make/unit-tests/depsrc-ignore.mk (expand / switch to unified diff)

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