Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests tests/make: demonstrate wrong exit s...



details:   https://anonhg.NetBSD.org/src/rev/269ba4447480
branches:  trunk
changeset: 369446:269ba4447480
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Aug 17 20:05:41 2022 +0000

description:
tests/make: demonstrate wrong exit status for '-q' (since 1994)

Reported by Jeroen Ruigrok van der Werven via private mail.

diffstat:

 usr.bin/make/unit-tests/opt-query.exp |  24 +++++++++++-
 usr.bin/make/unit-tests/opt-query.mk  |  71 ++++++++++++++++++++++++++++++++--
 2 files changed, 89 insertions(+), 6 deletions(-)

diffs (121 lines):

diff -r ca79e79ba034 -r 269ba4447480 usr.bin/make/unit-tests/opt-query.exp
--- a/usr.bin/make/unit-tests/opt-query.exp     Wed Aug 17 20:03:05 2022 +0000
+++ b/usr.bin/make/unit-tests/opt-query.exp     Wed Aug 17 20:05:41 2022 +0000
@@ -1,2 +1,24 @@
+Making commands:
 command during parsing
-exit status 1
+commands: query status 1
+
+Making opt-query-file.out-of-date in compat mode:
+opt-query-file.out-of-date in compat mode: query status 1
+
+Making opt-query-file.up-to-date in compat mode:
+`opt-query-file.up-to-date' is up to date.
+opt-query-file.up-to-date in compat mode: query status 1
+
+Making phony in compat mode:
+phony in compat mode: query status 1
+
+Making opt-query-file.out-of-date in jobs mode:
+opt-query-file.out-of-date in jobs mode: query status 1
+
+Making opt-query-file.up-to-date in jobs mode:
+opt-query-file.up-to-date in jobs mode: query status 1
+
+Making phony in jobs mode:
+phony in jobs mode: query status 1
+
+exit status 0
diff -r ca79e79ba034 -r 269ba4447480 usr.bin/make/unit-tests/opt-query.mk
--- a/usr.bin/make/unit-tests/opt-query.mk      Wed Aug 17 20:03:05 2022 +0000
+++ b/usr.bin/make/unit-tests/opt-query.mk      Wed Aug 17 20:05:41 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: opt-query.mk,v 1.4 2020/11/09 20:50:56 rillig Exp $
+# $NetBSD: opt-query.mk,v 1.5 2022/08/17 20:05:41 rillig Exp $
 #
 # Tests for the -q command line option.
 #
@@ -6,7 +6,59 @@
 # None of the commands in the targets are run, not even those that are
 # prefixed with '+'.
 
-.MAKEFLAGS: -q
+# This test consists of several parts:
+#
+#      main            Delegates to the actual tests.
+#
+#      commands        Ensures that none of the targets is made.
+#
+#      variants        Ensures that the up-to-date status is correctly
+#                      reported in both compat and jobs mode, and for several
+#                      kinds of make targets.
+PART?= main
+
+.if ${PART} == "main"
+
+all: .PHONY variants cleanup
+
+_!=    touch -f opt-query-file.up-to-date
+
+variants: .PHONY
+.  for target in commands
+       @echo 'Making ${target}':
+       @${MAKE} -r -f ${MAKEFILE} -q ${mode:Mjobs:%=-j1} ${target} PART=commands \
+       && echo "${target}: query status $$?" \
+       || echo "${target}: query status $$?"
+       @echo
+.  endfor
+.  for mode in compat jobs
+.    for target in opt-query-file.out-of-date opt-query-file.up-to-date phony
+       @echo 'Making ${target} in ${mode} mode':
+       @${MAKE} -r -f ${MAKEFILE} -q ${mode:Mjobs:%=-j1} ${target} PART=variants \
+       && echo "${target} in ${mode} mode: query status $$?" \
+       || echo "${target} in ${mode} mode: query status $$?"
+       @echo
+.    endfor
+.  endfor
+
+# expect: opt-query-file.out-of-date in compat mode: query status 1
+
+# FIXME: must be 0, not 1.
+# expect: opt-query-file.up-to-date in compat mode: query status 1
+
+# expect: phony in compat mode: query status 1
+
+# expect: opt-query-file.out-of-date in jobs mode: query status 1
+
+# FIXME: must be 0, not 1.
+# expect: opt-query-file.up-to-date in jobs mode: query status 1
+
+# expect: phony in jobs mode: query status 1
+
+cleanup: .PHONY
+       @rm -f opt-query-file.up-to-date
+
+.elif ${PART} == "commands"
 
 # This command cannot be prevented from being run since it is used at parse
 # time, and any later variable assignments may depend on its result.
@@ -18,9 +70,18 @@
        @+echo '$@: run always'
 
 # None of these commands are run.
-all:
+commands:
        @echo '$@: hidden command'
        @+echo '$@: run always'
+# The exit status 1 is because the "commands" target has to be made, that is,
+# it is not up-to-date.
 
-# The exit status 1 is because the "all" target has to be made, that is,
-# it is not up-to-date.
+.elif ${PART} == "variants"
+
+opt-query-file.out-of-date: ${MAKE}
+opt-query-file.up-to-date: ${MAKE}
+phony: .PHONY
+
+.else
+.  error Invalid part '${PART}'
+.endif



Home | Main Index | Thread Index | Old Index