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: add test for option '-X'...



details:   https://anonhg.NetBSD.org/src/rev/2d324c15a273
branches:  trunk
changeset: 365998:2d324c15a273
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun May 08 07:27:50 2022 +0000

description:
tests/make: add test for option '-X', clean up comments

diffstat:

 usr.bin/make/unit-tests/hanoi-include.mk          |  25 +++++++++++-----------
 usr.bin/make/unit-tests/opt-version.mk            |   8 +++---
 usr.bin/make/unit-tests/opt-x-reduce-exported.exp |   4 +++
 usr.bin/make/unit-tests/opt-x-reduce-exported.mk  |  22 +++++++++++++++----
 4 files changed, 38 insertions(+), 21 deletions(-)

diffs (90 lines):

diff -r f044d4e513c6 -r 2d324c15a273 usr.bin/make/unit-tests/hanoi-include.mk
--- a/usr.bin/make/unit-tests/hanoi-include.mk  Sun May 08 06:57:00 2022 +0000
+++ b/usr.bin/make/unit-tests/hanoi-include.mk  Sun May 08 07:27:50 2022 +0000
@@ -1,19 +1,20 @@
-# $NetBSD: hanoi-include.mk,v 1.2 2022/01/08 22:13:43 rillig Exp $
+# $NetBSD: hanoi-include.mk,v 1.3 2022/05/08 07:27:50 rillig Exp $
 #
-# Implements the Towers of Hanoi puzzle, thereby demonstrating a bunch of
-# more or less useful programming techniques:
+# Implements the Towers of Hanoi puzzle, demonstrating a bunch of more or less
+# useful programming techniques:
 #
-# * default assignment using the ?= assignment operator
-# * including the same file recursively (rather unusual)
-# * extracting the current value of a variable using the .for loop
-# * using shell commands for calculations since make is a text processor
-# * using the :: dependency operator for adding commands to a target
-# * on-the-fly variable assignment expressions using the ::= modifier
+#      * default assignment using the ?= assignment operator
+#      * including the same file recursively (rather unusual)
+#      * extracting the current value of a variable using the .for loop
+#      * using shell commands for calculations since make is a text processor
+#      * using the :: dependency operator for adding commands to a target
+#      * on-the-fly variable assignment expressions using the ::= modifier
 #
 # usage:
-#      env N=3 make -f hanoi-include.mk
-# endless loop:
-#      make -f hanoi-include.mk N=3
+#      env N=3 make -r -f hanoi-include.mk
+#
+# endless loop, since command line variables cannot be overridden:
+#      make -r -f hanoi-include.mk N=3
 
 N?=    5                       # Move this number of disks ...
 FROM?= A                       # ... from this stack ...
diff -r f044d4e513c6 -r 2d324c15a273 usr.bin/make/unit-tests/opt-version.mk
--- a/usr.bin/make/unit-tests/opt-version.mk    Sun May 08 06:57:00 2022 +0000
+++ b/usr.bin/make/unit-tests/opt-version.mk    Sun May 08 07:27:50 2022 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: opt-version.mk,v 1.1 2021/12/23 11:05:59 rillig Exp $
+# $NetBSD: opt-version.mk,v 1.2 2022/05/08 07:27:50 rillig Exp $
 #
-# Tests for the command line option '--version', which outputs the version
-# number of make.  NetBSD's make does not have a version number, but the bmake
-# distribution created from it has.
+# Tests for the command line option '--version', which may be expected to
+# output the version number of make.  NetBSD's make does not have a version
+# number, but the bmake distribution created from it has.
 
 # As of 2021-12-23, the output is a single empty line since the '--' does not
 # end the command line options.  Command line parsing then continues as if
diff -r f044d4e513c6 -r 2d324c15a273 usr.bin/make/unit-tests/opt-x-reduce-exported.exp
--- a/usr.bin/make/unit-tests/opt-x-reduce-exported.exp Sun May 08 06:57:00 2022 +0000
+++ b/usr.bin/make/unit-tests/opt-x-reduce-exported.exp Sun May 08 07:27:50 2022 +0000
@@ -1,1 +1,5 @@
+ordinary:
+BEFORE=before
+submake:
+BEFORE=before
 exit status 0
diff -r f044d4e513c6 -r 2d324c15a273 usr.bin/make/unit-tests/opt-x-reduce-exported.mk
--- a/usr.bin/make/unit-tests/opt-x-reduce-exported.mk  Sun May 08 06:57:00 2022 +0000
+++ b/usr.bin/make/unit-tests/opt-x-reduce-exported.mk  Sun May 08 07:27:50 2022 +0000
@@ -1,8 +1,20 @@
-# $NetBSD: opt-x-reduce-exported.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: opt-x-reduce-exported.mk,v 1.3 2022/05/08 07:27:50 rillig Exp $
 #
-# Tests for the -x command line option.
+# Tests for the -X command line option, which prevents variables passed on the
+# command line from being exported to the environment of child commands.
+
+# The variable 'BEFORE' is exported, the variable 'AFTER' isn't.
+.MAKEFLAGS: BEFORE=before -X AFTER=after
+
+all: .PHONY ordinary submake
 
-# TODO: Implementation
+ordinary: .PHONY
+       @echo 'ordinary:'
+       @env | sort | grep -e '^BEFORE' -e '^AFTER'
 
-all:
-       @:;
+submake: .PHONY
+       @echo 'submake:'
+       @${MAKE} -r -f ${MAKEFILE} show-env
+
+show-env: .PHONY
+       @env | sort | grep -e '^BEFORE' -e '^AFTER'



Home | Main Index | Thread Index | Old Index