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 make(1): add test for the -m option,...



details:   https://anonhg.NetBSD.org/src/rev/5d446d99a4ca
branches:  trunk
changeset: 975591:5d446d99a4ca
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Sep 01 20:14:34 2020 +0000

description:
make(1): add test for the -m option, the special .../ path

diffstat:

 usr.bin/make/unit-tests/opt-m-include-dir.exp |   1 +
 usr.bin/make/unit-tests/opt-m-include-dir.mk  |  72 ++++++++++++++++++++------
 2 files changed, 55 insertions(+), 18 deletions(-)

diffs (89 lines):

diff -r 01eff8d240e0 -r 5d446d99a4ca usr.bin/make/unit-tests/opt-m-include-dir.exp
--- a/usr.bin/make/unit-tests/opt-m-include-dir.exp     Tue Sep 01 19:17:58 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-m-include-dir.exp     Tue Sep 01 20:14:34 2020 +0000
@@ -1,1 +1,2 @@
+ok
 exit status 0
diff -r 01eff8d240e0 -r 5d446d99a4ca usr.bin/make/unit-tests/opt-m-include-dir.mk
--- a/usr.bin/make/unit-tests/opt-m-include-dir.mk      Tue Sep 01 19:17:58 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-m-include-dir.mk      Tue Sep 01 20:14:34 2020 +0000
@@ -1,25 +1,61 @@
-# $NetBSD: opt-m-include-dir.mk,v 1.3 2020/09/01 19:17:58 rillig Exp $
+# $NetBSD: opt-m-include-dir.mk,v 1.4 2020/09/01 20:14:34 rillig Exp $
+#
+# Tests for the -m command line option, which adds a directory to the
+# search path for the .include <...> directive.
+#
+# The .../canary.mk special argument starts searching in the current
+# directory and walks towards the file system root, until it finds a
+# directory that contains a file called canary.mk.
+#
+# To set up this scenario, the file step2.mk is created deep in a hierarchy
+# of subdirectories.  Another file called opt-m-step3.mk is created a few
+# steps up in the directory hierarchy, serving as the canary file.
 #
-# Tests for the -m command line option.
+# Next to the canary file, there is opt-m-step3.mk.  This file is found
+# by mentioning its simple name in an .include directive.  It defines the
+# target "step2" that is needed by "step2.mk".
+
+.if ${.PARSEFILE:T} == "opt-m-include-dir.mk"
+
+# Set up the other files needed for this test.
+
+TEST_DIR:=     ${.PARSEFILE:R}.tmp/sub/sub/sub/workdir
+CANARY_FILE:=  ${.PARSEFILE:R}.tmp/sub/opt-m-canary.mk
+ACTUAL_FILE:=  ${.PARSEFILE:R}.tmp/sub/opt-m-step3.mk
+
+_!=    mkdir -p ${TEST_DIR}
+_!=    > ${CANARY_FILE}
+_!=    cp ${MAKEFILE} ${TEST_DIR}/step2.mk
+_!=    cp ${MAKEFILE} ${ACTUAL_FILE}
 
-.MAKEFLAGS: -m .../buf.c
+step1:
+       @${.MAKE} -C ${TEST_DIR} -f step2.mk step2
+
+.END:
+       @rm -rf ${MAKEFILE:R}.tmp
+
+.elif ${.PARSEFILE:T} == "step2.mk"
+
+# This is the file deep in the directory hierarchy.  It sets up the
+# search path for the .include <...> directive and then includes a
+# single file from that search path.
+
+# This option adds .tmp/sub to the search path for .include <...>.
+.MAKEFLAGS: -m .../opt-m-canary.mk
+
+# This option does not add any directory to the search path since the
+# canary file does not exist.
 .MAKEFLAGS: -m .../does-not-exist
-.MAKEFLAGS: -m .../${.PARSEFILE:T}
+
+.include <opt-m-step3.mk>
+
+.elif ${.PARSEFILE:T} == "opt-m-step3.mk"
 
-# Whether or not buf.c exists depends on whether the source code of make
-# is available.  When running the tests in src/usr.bin/make, it succeeds,
-# and when running the tests in src/tests/usr.bin/make, it fails.
+# This file is included by step2.mk.
 
-# This file should never exist.
-.if exists(does-not-exist)
+step2:
+       @echo ok
+
+.else
 .  error
 .endif
-
-# This test assumes that this test is run in the same directory as the
-# test file.
-.if !exists(${.PARSEFILE})
-.  error
-.endif
-
-all:
-       @:;



Home | Main Index | Thread Index | Old Index