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 make(1): add test for the -n option



details:   https://anonhg.NetBSD.org/src/rev/661188aaf568
branches:  trunk
changeset: 942766:661188aaf568
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Aug 19 05:25:26 2020 +0000

description:
make(1): add test for the -n option

diffstat:

 usr.bin/make/unit-tests/Makefile          |   3 +-
 usr.bin/make/unit-tests/opt-no-action.exp |  12 ++++++++++
 usr.bin/make/unit-tests/opt-no-action.mk  |  35 ++++++++++++++++++++++++++----
 3 files changed, 44 insertions(+), 6 deletions(-)

diffs (76 lines):

diff -r 4bddba5fb35e -r 661188aaf568 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Wed Aug 19 05:13:18 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Wed Aug 19 05:25:26 2020 +0000
@@ -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.envfirst=                -e
 FLAGS.export=          # none
 FLAGS.lint=            -dL -k
+FLAGS.opt-no-action=   -n
 FLAGS.opt-query=       -q
 FLAGS.order=           -j1
 FLAGS.recursive=       -dL
diff -r 4bddba5fb35e -r 661188aaf568 usr.bin/make/unit-tests/opt-no-action.exp
--- a/usr.bin/make/unit-tests/opt-no-action.exp Wed Aug 19 05:13:18 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-no-action.exp Wed Aug 19 05:25:26 2020 +0000
@@ -1,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
diff -r 4bddba5fb35e -r 661188aaf568 usr.bin/make/unit-tests/opt-no-action.mk
--- a/usr.bin/make/unit-tests/opt-no-action.mk  Wed Aug 19 05:13:18 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-no-action.mk  Wed Aug 19 05:25:26 2020 +0000
@@ -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.
+
+# 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: main
+all: run-always
 
-# TODO: Implementation
+# 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'
 
-all:
-       @:;
+# 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'



Home | Main Index | Thread Index | Old Index