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