Tue Dec 14 00:38:32 2021 UTC ()
tests/make: test traditional include directive


(rillig)
diff -r1.6 -r1.7 src/usr.bin/make/unit-tests/directive-include.exp
diff -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-include.mk

cvs diff -r1.6 -r1.7 src/usr.bin/make/unit-tests/directive-include.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/directive-include.exp 2021/12/03 22:48:07 1.6
+++ src/usr.bin/make/unit-tests/directive-include.exp 2021/12/14 00:38:32 1.7
@@ -1,11 +1,14 @@ @@ -1,11 +1,14 @@
1CondParser_Eval: ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null" 1CondParser_Eval: ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null"
2lhs = "directive-include.mk null", rhs = "directive-include.mk null", op = != 2lhs = "directive-include.mk null", rhs = "directive-include.mk null", op = !=
3CondParser_Eval: ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null" 3CondParser_Eval: ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null"
4lhs = "directive-include.mk null", rhs = "directive-include.mk null", op = != 4lhs = "directive-include.mk null", rhs = "directive-include.mk null", op = !=
5make: "directive-include.mk" line 25: Could not find nonexistent.mk 5make: "directive-include.mk" line 25: Could not find nonexistent.mk
6make: "directive-include.mk" line 47: Could not find " 6make: "directive-include.mk" line 47: Could not find "
7make: "directive-include.mk" line 52: Unknown modifier "Z" 7make: "directive-include.mk" line 52: Unknown modifier "Z"
8make: "directive-include.mk" line 52: Could not find nonexistent.mk 8make: "directive-include.mk" line 52: Could not find nonexistent.mk
 9make: "directive-include.mk" line 57: Cannot open /nonexistent
 10make: "directive-include.mk" line 62: Invalid line type
 11make: "directive-include.mk" line 65: Could not find
9make: Fatal errors encountered -- cannot continue 12make: Fatal errors encountered -- cannot continue
10make: stopped in unit-tests 13make: stopped in unit-tests
11exit status 1 14exit status 1

cvs diff -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-include.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/directive-include.mk 2021/12/03 22:48:07 1.7
+++ src/usr.bin/make/unit-tests/directive-include.mk 2021/12/14 00:38:32 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: directive-include.mk,v 1.7 2021/12/03 22:48:07 rillig Exp $ 1# $NetBSD: directive-include.mk,v 1.8 2021/12/14 00:38:32 rillig Exp $
2# 2#
3# Tests for the .include directive, which includes another file. 3# Tests for the .include directive, which includes another file.
4 4
5# TODO: Implementation 5# TODO: Implementation
6 6
7.MAKEFLAGS: -dc 7.MAKEFLAGS: -dc
8 8
9# All included files are recorded in the variable .MAKE.MAKEFILES. 9# All included files are recorded in the variable .MAKE.MAKEFILES.
10# In this test, only the basenames of the files are compared since 10# In this test, only the basenames of the files are compared since
11# the directories can differ. 11# the directories can differ.
12.include "/dev/null" 12.include "/dev/null"
13.if ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null" 13.if ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null"
14. error 14. error
@@ -41,14 +41,27 @@ DEV= null @@ -41,14 +41,27 @@ DEV= null
41# '.include' directives are typically kept as simple as possible. 41# '.include' directives are typically kept as simple as possible.
42# 42#
43# If the whole line were expanded before parsing, the filename to be included 43# If the whole line were expanded before parsing, the filename to be included
44# would be empty, and the closing '"' would be in the trailing part of the 44# would be empty, and the closing '"' would be in the trailing part of the
45# line, which is ignored as of 2021-12-03. 45# line, which is ignored as of 2021-12-03.
46DQUOT= " 46DQUOT= "
47.include "${DQUOT}" 47.include "${DQUOT}"
48 48
49# When the expression in a filename cannot be evaluated, the failing 49# When the expression in a filename cannot be evaluated, the failing
50# expression is skipped and the file is included nevertheless. 50# expression is skipped and the file is included nevertheless.
51# FIXME: Add proper error handling, no file must be included here. 51# FIXME: Add proper error handling, no file must be included here.
52.include "nonexistent${:U123:Z}.mk" 52.include "nonexistent${:U123:Z}.mk"
53 53
 54# The traditional include directive is seldom used.
 55include /dev/null # comment
 56# expect+1: Cannot open /nonexistent
 57include /nonexistent # comment
 58sinclude /nonexistent # comment
 59include ${:U/dev/null} # comment
 60include /dev/null /dev/null
 61# expect+1: Invalid line type
 62include
 63# XXX: trailing whitespace in diagnostic, missing quotes around filename
 64# expect+1: Could not find
 65include ${:U}
 66
54all: 67all: