Module Name: src Committed By: rillig Date: Sun May 8 07:27:50 UTC 2022
Modified Files: src/usr.bin/make/unit-tests: hanoi-include.mk opt-version.mk opt-x-reduce-exported.exp opt-x-reduce-exported.mk Log Message: tests/make: add test for option '-X', clean up comments To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/hanoi-include.mk \ src/usr.bin/make/unit-tests/opt-x-reduce-exported.mk cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-version.mk \ src/usr.bin/make/unit-tests/opt-x-reduce-exported.exp 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/hanoi-include.mk diff -u src/usr.bin/make/unit-tests/hanoi-include.mk:1.2 src/usr.bin/make/unit-tests/hanoi-include.mk:1.3 --- src/usr.bin/make/unit-tests/hanoi-include.mk:1.2 Sat Jan 8 22:13:43 2022 +++ src/usr.bin/make/unit-tests/hanoi-include.mk Sun May 8 07:27:50 2022 @@ -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 ... Index: src/usr.bin/make/unit-tests/opt-x-reduce-exported.mk diff -u src/usr.bin/make/unit-tests/opt-x-reduce-exported.mk:1.2 src/usr.bin/make/unit-tests/opt-x-reduce-exported.mk:1.3 --- src/usr.bin/make/unit-tests/opt-x-reduce-exported.mk:1.2 Sun Aug 16 14:25:16 2020 +++ src/usr.bin/make/unit-tests/opt-x-reduce-exported.mk Sun May 8 07:27:50 2022 @@ -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. -# TODO: Implementation +# The variable 'BEFORE' is exported, the variable 'AFTER' isn't. +.MAKEFLAGS: BEFORE=before -X AFTER=after -all: - @:; +all: .PHONY ordinary submake + +ordinary: .PHONY + @echo 'ordinary:' + @env | sort | grep -e '^BEFORE' -e '^AFTER' + +submake: .PHONY + @echo 'submake:' + @${MAKE} -r -f ${MAKEFILE} show-env + +show-env: .PHONY + @env | sort | grep -e '^BEFORE' -e '^AFTER' Index: src/usr.bin/make/unit-tests/opt-version.mk diff -u src/usr.bin/make/unit-tests/opt-version.mk:1.1 src/usr.bin/make/unit-tests/opt-version.mk:1.2 --- src/usr.bin/make/unit-tests/opt-version.mk:1.1 Thu Dec 23 11:05:59 2021 +++ src/usr.bin/make/unit-tests/opt-version.mk Sun May 8 07:27:50 2022 @@ -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 Index: src/usr.bin/make/unit-tests/opt-x-reduce-exported.exp diff -u src/usr.bin/make/unit-tests/opt-x-reduce-exported.exp:1.1 src/usr.bin/make/unit-tests/opt-x-reduce-exported.exp:1.2 --- src/usr.bin/make/unit-tests/opt-x-reduce-exported.exp:1.1 Sun Aug 16 12:07:51 2020 +++ src/usr.bin/make/unit-tests/opt-x-reduce-exported.exp Sun May 8 07:27:50 2022 @@ -1 +1,5 @@ +ordinary: +BEFORE=before +submake: +BEFORE=before exit status 0