Module Name: src Committed By: rillig Date: Tue Jul 28 22:44:45 UTC 2020
Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make/unit-tests: Makefile Added Files: src/usr.bin/make/unit-tests: cmdline.exp cmdline.mk Log Message: make(1): add test for setting .OBJDIR via the command line To generate a diff of this commit: cvs rdiff -u -r1.880 -r1.881 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.74 -r1.75 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/cmdline.exp \ src/usr.bin/make/unit-tests/cmdline.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.880 src/distrib/sets/lists/tests/mi:1.881 --- src/distrib/sets/lists/tests/mi:1.880 Mon Jul 27 20:46:18 2020 +++ src/distrib/sets/lists/tests/mi Tue Jul 28 22:44:44 2020 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.880 2020/07/27 20:46:18 rillig Exp $ +# $NetBSD: mi,v 1.881 2020/07/28 22:44:44 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4524,6 +4524,8 @@ ./usr/tests/usr.bin/make/unit-tests/Makefile tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/archive.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/archive.mk tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/cmdline.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/cmdline.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/comment.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/comment.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/cond-late.exp tests-usr.bin-tests compattestfile,atf Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.74 src/usr.bin/make/unit-tests/Makefile:1.75 --- src/usr.bin/make/unit-tests/Makefile:1.74 Tue Jul 28 18:39:56 2020 +++ src/usr.bin/make/unit-tests/Makefile Tue Jul 28 22:44:44 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.74 2020/07/28 18:39:56 sjg Exp $ +# $NetBSD: Makefile,v 1.75 2020/07/28 22:44:44 rillig Exp $ # # Unit tests for make(1) # @@ -31,6 +31,7 @@ # Each test is in a sub-makefile. # Keep the list sorted. TESTS+= # archive # broken on FreeBSD +TESTS+= cmdline TESTS+= comment TESTS+= cond-late TESTS+= cond-short Added files: Index: src/usr.bin/make/unit-tests/cmdline.exp diff -u /dev/null src/usr.bin/make/unit-tests/cmdline.exp:1.1 --- /dev/null Tue Jul 28 22:44:45 2020 +++ src/usr.bin/make/unit-tests/cmdline.exp Tue Jul 28 22:44:44 2020 @@ -0,0 +1,5 @@ +makeobjdir-direct: +show-objdir: /tmp/6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5 +makeobjdir-indirect: +show-objdir: /tmp/a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45/ +exit status 0 Index: src/usr.bin/make/unit-tests/cmdline.mk diff -u /dev/null src/usr.bin/make/unit-tests/cmdline.mk:1.1 --- /dev/null Tue Jul 28 22:44:45 2020 +++ src/usr.bin/make/unit-tests/cmdline.mk Tue Jul 28 22:44:44 2020 @@ -0,0 +1,37 @@ +# $NetBSD: cmdline.mk,v 1.1 2020/07/28 22:44:44 rillig Exp $ +# +# Tests for command line parsing and related special variables. + +RUN?= @set -eu; +TMPBASE?= /tmp +SUB1= a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45 # just a random UUID +SUB2= 6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5 # just a random UUID +MAKE_CMD= env TMPBASE=${TMPBASE}/${SUB1} ${.MAKE} -f ${MAKEFILE} -r +DIR2= ${TMPBASE}/${SUB2} +DIR12= ${TMPBASE}/${SUB1}/${SUB2} + +all: prepare-dirs +all: makeobjdir-direct makeobjdir-indirect + +prepare-dirs: + ${RUN} rm -rf ${DIR2} ${DIR12} + ${RUN} mkdir -p ${DIR2} ${DIR12} + +# The .OBJDIR can be set via the MAKEOBJDIR command line variable. +# It must be a command line variable; an environment variable would not work. +makeobjdir-direct: + @echo $@: + ${RUN} ${MAKE_CMD} MAKEOBJDIR=${DIR2} show-objdir + +# The .OBJDIR can be set via the MAKEOBJDIR command line variable, +# and that variable could even contain the usual modifiers. +# Since the .OBJDIR=MAKEOBJDIR assignment happens very early, +# the SUB2 variable in the modifier is not defined yet and is therefore empty. +# The SUB1 in the resulting path comes from the environment variable TMPBASE, +# see MAKE_CMD. +makeobjdir-indirect: + @echo $@: + ${RUN} ${MAKE_CMD} MAKEOBJDIR='$${TMPBASE}/$${SUB2}' show-objdir + +show-objdir: + @echo $@: ${.OBJDIR:Q}