Module Name: src
Committed By: rillig
Date: Wed Aug 19 05:25:26 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: Makefile opt-no-action.exp
opt-no-action.mk
Log Message:
make(1): add test for the -n option
To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-no-action.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-no-action.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.101 src/usr.bin/make/unit-tests/Makefile:1.102
--- src/usr.bin/make/unit-tests/Makefile:1.101 Wed Aug 19 05:13:18 2020
+++ src/usr.bin/make/unit-tests/Makefile Wed Aug 19 05:25:26 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.101 2020/08/19 05:13:18 rillig Exp $
+# $NetBSD: Makefile,v 1.102 2020/08/19 05:25:26 rillig Exp $
#
# Unit tests for make(1)
#
@@ -310,6 +310,7 @@ FLAGS.doterror= # none
FLAGS.envfirst= -e
FLAGS.export= # none
FLAGS.lint= -dL -k
+FLAGS.opt-no-action= -n
FLAGS.opt-query= -q
FLAGS.order= -j1
FLAGS.recursive= -dL
Index: src/usr.bin/make/unit-tests/opt-no-action.exp
diff -u src/usr.bin/make/unit-tests/opt-no-action.exp:1.1 src/usr.bin/make/unit-tests/opt-no-action.exp:1.2
--- src/usr.bin/make/unit-tests/opt-no-action.exp:1.1 Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/opt-no-action.exp Wed Aug 19 05:25:26 2020
@@ -1 +1,13 @@
+command during parsing
+echo '.BEGIN: hidden command'
+echo '.BEGIN: run always'
+.BEGIN: run always
+echo 'main: hidden command'
+echo 'main: run always'
+main: run always
+run-always: hidden command
+run-always: run always
+echo '.END: hidden command'
+echo '.END: run always'
+.END: run always
exit status 0
Index: src/usr.bin/make/unit-tests/opt-no-action.mk
diff -u src/usr.bin/make/unit-tests/opt-no-action.mk:1.2 src/usr.bin/make/unit-tests/opt-no-action.mk:1.3
--- src/usr.bin/make/unit-tests/opt-no-action.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/opt-no-action.mk Wed Aug 19 05:25:26 2020
@@ -1,8 +1,33 @@
-# $NetBSD: opt-no-action.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: opt-no-action.mk,v 1.3 2020/08/19 05:25:26 rillig Exp $
#
-# Tests for the -n command line option.
+# Tests for the -n command line option, which runs almost no commands.
+# It just outputs them, to be inspected by human readers.
+# Only commands that are in a .MAKE target or prefixed by '+' are run.
-# TODO: Implementation
+# 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.
+!= echo 'command during parsing' 1>&2; echo
-all:
- @:;
+all: main
+all: run-always
+
+# Both of these commands are printed, but only the '+' command is run.
+.BEGIN:
+ @echo '$@: hidden command'
+ @+echo '$@: run always'
+
+# Both of these commands are printed, but only the '+' command is run.
+main:
+ @echo '$@: hidden command'
+ @+echo '$@: run always'
+
+# None of these commands is printed, but both are run, because this target
+# depends on the special source ".MAKE".
+run-always: .MAKE
+ @echo '$@: hidden command'
+ @+echo '$@: run always'
+
+# Both of these commands are printed, but only the '+' command is run.
+.END:
+ @echo '$@: hidden command'
+ @+echo '$@: run always'