Module Name:    src
Committed By:   rillig
Date:           Mon Sep 21 04:20:35 UTC 2020

Modified Files:
        src/usr.bin/make: test-variants.sh
        src/usr.bin/make/unit-tests: Makefile

Log Message:
make(1): run tests with absolute filenames as well

The tests varname-dot-parsedir and varname-dot-parsefile had been broken
before if they were run with the "-f $PWD/$test.mk" option.  This way of
running the tests is used by FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/test-variants.sh
cvs rdiff -u -r1.144 -r1.145 src/usr.bin/make/unit-tests/Makefile

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/test-variants.sh
diff -u src/usr.bin/make/test-variants.sh:1.3 src/usr.bin/make/test-variants.sh:1.4
--- src/usr.bin/make/test-variants.sh:1.3	Mon Aug 31 18:57:41 2020
+++ src/usr.bin/make/test-variants.sh	Mon Sep 21 04:20:35 2020
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: test-variants.sh,v 1.3 2020/08/31 18:57:41 rillig Exp $
+# $NetBSD: test-variants.sh,v 1.4 2020/09/21 04:20:35 rillig Exp $
 #
 # Build several variants of make and run the tests on them.
 #
@@ -157,6 +157,10 @@ testcase USER_CPPFLAGS="-DNDEBUG"
 
 testcase USE_FORT="yes"
 
+# Ensure that the tests can be specified either as relative filenames or
+# as absolute filenames.
+testcase USE_ABSOLUTE_TESTNAMES="yes"
+
 # This test is the result of reading through the GCC "Warning Options"
 # documentation, noting down everything that sounded interesting.
 #

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.144 src/usr.bin/make/unit-tests/Makefile:1.145
--- src/usr.bin/make/unit-tests/Makefile:1.144	Mon Sep 21 03:45:29 2020
+++ src/usr.bin/make/unit-tests/Makefile	Mon Sep 21 04:20:35 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.144 2020/09/21 03:45:29 rillig Exp $
+# $NetBSD: Makefile,v 1.145 2020/09/21 04:20:35 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -418,7 +418,11 @@ unexport-env.rawout: export.mk
 UNIT_TESTS:=	${.PARSEDIR}
 .PATH: ${UNIT_TESTS}
 
+.if ${USE_ABSOLUTE_TESTNAMES:Uno} == yes
+OUTFILES=	${TESTS:@test@${.CURDIR:tA}/${test}.out@}
+.else
 OUTFILES=	${TESTS:=.out}
+.endif
 
 all: ${OUTFILES}
 
@@ -447,10 +451,10 @@ LANG=		C
 	@${_MKMSG_TEST:Uecho '#      test '} ${.PREFIX}
 	@set -eu; \
 	cd ${.OBJDIR}; \
-	env -i PATH="$$PATH" ${ENV.${.TARGET:R}} \
+	env -i PATH="$$PATH" ${ENV.${.PREFIX:T}} \
 	  ${TEST_MAKE} \
 	    -r -C ${.CURDIR} -f ${.IMPSRC} \
-	    ${FLAGS.${.TARGET:R}:U-k} \
+	    ${FLAGS.${.PREFIX:T}:U-k} \
 	    > ${.TARGET}.tmp 2>&1 \
 	&& status=$$? || status=$$?; \
 	echo $$status > ${.TARGET:R}.status
@@ -468,9 +472,9 @@ _SED_CMDS+=	-e 's,${.CURDIR:S,.,\\.,g}/,
 _SED_CMDS+=	-e 's,${UNIT_TESTS:S,.,\\.,g}/,,g'
 
 .rawout.out:
-	@${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.TARGET:R}} \
+	@${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.PREFIX:T}} \
 	  < ${.IMPSRC} > ${.TARGET}.tmp1
-	@${POSTPROC.${.TARGET:R}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2
+	@${POSTPROC.${.PREFIX:T}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2
 	@rm ${.TARGET}.tmp1
 	@echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp2
 	@mv ${.TARGET}.tmp2 ${.TARGET}

Reply via email to