Tue Sep 1 20:14:34 2020 UTC ()
make(1): add test for the -m option, the special .../ path


(rillig)
diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-m-include-dir.exp
diff -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-m-include-dir.mk

cvs diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-m-include-dir.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/opt-m-include-dir.exp 2020/08/16 12:07:51 1.1
+++ src/usr.bin/make/unit-tests/opt-m-include-dir.exp 2020/09/01 20:14:34 1.2

cvs diff -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-m-include-dir.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/opt-m-include-dir.mk 2020/09/01 19:17:58 1.3
+++ src/usr.bin/make/unit-tests/opt-m-include-dir.mk 2020/09/01 20:14:34 1.4
@@ -1,25 +1,61 @@ @@ -1,25 +1,61 @@
1# $NetBSD: opt-m-include-dir.mk,v 1.3 2020/09/01 19:17:58 rillig Exp $ 1# $NetBSD: opt-m-include-dir.mk,v 1.4 2020/09/01 20:14:34 rillig Exp $
2# 2#
3# Tests for the -m command line option. 3# Tests for the -m command line option, which adds a directory to the
 4# search path for the .include <...> directive.
 5#
 6# The .../canary.mk special argument starts searching in the current
 7# directory and walks towards the file system root, until it finds a
 8# directory that contains a file called canary.mk.
 9#
 10# To set up this scenario, the file step2.mk is created deep in a hierarchy
 11# of subdirectories. Another file called opt-m-step3.mk is created a few
 12# steps up in the directory hierarchy, serving as the canary file.
 13#
 14# Next to the canary file, there is opt-m-step3.mk. This file is found
 15# by mentioning its simple name in an .include directive. It defines the
 16# target "step2" that is needed by "step2.mk".
 17
 18.if ${.PARSEFILE:T} == "opt-m-include-dir.mk"
 19
 20# Set up the other files needed for this test.
 21
 22TEST_DIR:= ${.PARSEFILE:R}.tmp/sub/sub/sub/workdir
 23CANARY_FILE:= ${.PARSEFILE:R}.tmp/sub/opt-m-canary.mk
 24ACTUAL_FILE:= ${.PARSEFILE:R}.tmp/sub/opt-m-step3.mk
 25
 26_!= mkdir -p ${TEST_DIR}
 27_!= > ${CANARY_FILE}
 28_!= cp ${MAKEFILE} ${TEST_DIR}/step2.mk
 29_!= cp ${MAKEFILE} ${ACTUAL_FILE}
 30
 31step1:
 32 @${.MAKE} -C ${TEST_DIR} -f step2.mk step2
 33
 34.END:
 35 @rm -rf ${MAKEFILE:R}.tmp
4 36
5.MAKEFLAGS: -m .../buf.c 37.elif ${.PARSEFILE:T} == "step2.mk"
 38
 39# This is the file deep in the directory hierarchy. It sets up the
 40# search path for the .include <...> directive and then includes a
 41# single file from that search path.
 42
 43# This option adds .tmp/sub to the search path for .include <...>.
 44.MAKEFLAGS: -m .../opt-m-canary.mk
 45
 46# This option does not add any directory to the search path since the
 47# canary file does not exist.
6.MAKEFLAGS: -m .../does-not-exist 48.MAKEFLAGS: -m .../does-not-exist
7.MAKEFLAGS: -m .../${.PARSEFILE:T} 
8 49
9# Whether or not buf.c exists depends on whether the source code of make 50.include <opt-m-step3.mk>
10# is available. When running the tests in src/usr.bin/make, it succeeds, 
11# and when running the tests in src/tests/usr.bin/make, it fails. 
12 51
13# This file should never exist. 52.elif ${.PARSEFILE:T} == "opt-m-step3.mk"
14.if exists(does-not-exist) 53
15. error 54# This file is included by step2.mk.
16.endif 
17 55
18# This test assumes that this test is run in the same directory as the 56step2:
19# test file. 57 @echo ok
20.if !exists(${.PARSEFILE}) 58
 59.else
21. error 60. error
22.endif 61.endif
23 
24all: 
25 @:;