Module Name: src
Committed By: rillig
Date: Sun Sep 13 09:20:23 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: directive-dinclude.exp
directive-dinclude.mk directive-hyphen-include.exp
directive-hyphen-include.mk directive-include-fatal.exp
directive-include-fatal.mk directive-include.exp
directive-include.mk directive-sinclude.exp directive-sinclude.mk
Log Message:
make(1): add tests for the various .include directives
To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/directive-dinclude.exp \
src/usr.bin/make/unit-tests/directive-dinclude.mk \
src/usr.bin/make/unit-tests/directive-hyphen-include.exp \
src/usr.bin/make/unit-tests/directive-hyphen-include.mk \
src/usr.bin/make/unit-tests/directive-include-fatal.exp \
src/usr.bin/make/unit-tests/directive-include-fatal.mk \
src/usr.bin/make/unit-tests/directive-include.exp \
src/usr.bin/make/unit-tests/directive-include.mk \
src/usr.bin/make/unit-tests/directive-sinclude.exp \
src/usr.bin/make/unit-tests/directive-sinclude.mk
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/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.139 src/usr.bin/make/unit-tests/Makefile:1.140
--- src/usr.bin/make/unit-tests/Makefile:1.139 Sun Sep 13 09:17:47 2020
+++ src/usr.bin/make/unit-tests/Makefile Sun Sep 13 09:20:23 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.139 2020/09/13 09:17:47 rillig Exp $
+# $NetBSD: Makefile,v 1.140 2020/09/13 09:20:23 rillig Exp $
#
# Unit tests for make(1)
#
@@ -121,6 +121,7 @@ TESTS+= deptgt-suffixes
TESTS+= dir
TESTS+= dir-expand-path
TESTS+= directive
+TESTS+= directive-dinclude
TESTS+= directive-elif
TESTS+= directive-elifdef
TESTS+= directive-elifmake
@@ -134,12 +135,16 @@ TESTS+= directive-export-env
TESTS+= directive-export-literal
TESTS+= directive-for
TESTS+= directive-for-generating-endif
+TESTS+= directive-hyphen-include
TESTS+= directive-if
TESTS+= directive-ifdef
TESTS+= directive-ifmake
TESTS+= directive-ifndef
TESTS+= directive-ifnmake
+TESTS+= directive-include
+TESTS+= directive-include-fatal
TESTS+= directive-info
+TESTS+= directive-sinclude
TESTS+= directive-undef
TESTS+= directive-unexport
TESTS+= directive-unexport-env
Added files:
Index: src/usr.bin/make/unit-tests/directive-dinclude.exp
diff -u /dev/null src/usr.bin/make/unit-tests/directive-dinclude.exp:1.1
--- /dev/null Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-dinclude.exp Sun Sep 13 09:20:23 2020
@@ -0,0 +1 @@
+exit status 0
Index: src/usr.bin/make/unit-tests/directive-dinclude.mk
diff -u /dev/null src/usr.bin/make/unit-tests/directive-dinclude.mk:1.1
--- /dev/null Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-dinclude.mk Sun Sep 13 09:20:23 2020
@@ -0,0 +1,9 @@
+# $NetBSD: directive-dinclude.mk,v 1.1 2020/09/13 09:20:23 rillig Exp $
+#
+# Tests for the .dinclude directive, which includes another file,
+# typically named .depend.
+
+# TODO: Implementation
+
+all:
+ @:;
Index: src/usr.bin/make/unit-tests/directive-hyphen-include.exp
diff -u /dev/null src/usr.bin/make/unit-tests/directive-hyphen-include.exp:1.1
--- /dev/null Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-hyphen-include.exp Sun Sep 13 09:20:23 2020
@@ -0,0 +1 @@
+exit status 0
Index: src/usr.bin/make/unit-tests/directive-hyphen-include.mk
diff -u /dev/null src/usr.bin/make/unit-tests/directive-hyphen-include.mk:1.1
--- /dev/null Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-hyphen-include.mk Sun Sep 13 09:20:23 2020
@@ -0,0 +1,9 @@
+# $NetBSD: directive-hyphen-include.mk,v 1.1 2020/09/13 09:20:23 rillig Exp $
+#
+# Tests for the .-include directive, which includes another file,
+# silently skipping it if it cannot be opened.
+
+# TODO: Implementation
+
+all:
+ @:;
Index: src/usr.bin/make/unit-tests/directive-include-fatal.exp
diff -u /dev/null src/usr.bin/make/unit-tests/directive-include-fatal.exp:1.1
--- /dev/null Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-include-fatal.exp Sun Sep 13 09:20:23 2020
@@ -0,0 +1,4 @@
+make: "directive-include-fatal.mk" line 10: Malformed conditional (${UNDEF})
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/directive-include-fatal.mk
diff -u /dev/null src/usr.bin/make/unit-tests/directive-include-fatal.mk:1.1
--- /dev/null Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-include-fatal.mk Sun Sep 13 09:20:23 2020
@@ -0,0 +1,21 @@
+# $NetBSD: directive-include-fatal.mk,v 1.1 2020/09/13 09:20:23 rillig Exp $
+#
+# Test for the .include directive combined with fatal errors.
+#
+# At 2020-09-13, the code in Parse_File that sets "fatals = 0" looked
+# suspicious, as if it were possible to suppress fatal errors by including
+# another file. It was a false alarm though, since Parse_File only handles
+# the top-level makefiles from the command line. Any included files are
+# handled by Parse_include_file instead, and that function does not reset
+# the "fatals" counter.
+
+# Using an undefined variable in a condition generates a fatal error.
+.if ${UNDEF}
+.endif
+
+# Including another file does not reset the global variable "fatals".
+# The exit status will be 1.
+.include "/dev/null"
+
+all:
+ @:;
Index: src/usr.bin/make/unit-tests/directive-include.exp
diff -u /dev/null src/usr.bin/make/unit-tests/directive-include.exp:1.1
--- /dev/null Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-include.exp Sun Sep 13 09:20:23 2020
@@ -0,0 +1 @@
+exit status 0
Index: src/usr.bin/make/unit-tests/directive-include.mk
diff -u /dev/null src/usr.bin/make/unit-tests/directive-include.mk:1.1
--- /dev/null Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-include.mk Sun Sep 13 09:20:23 2020
@@ -0,0 +1,8 @@
+# $NetBSD: directive-include.mk,v 1.1 2020/09/13 09:20:23 rillig Exp $
+#
+# Tests for the .include directive, which includes another file.
+
+# TODO: Implementation
+
+all:
+ @:;
Index: src/usr.bin/make/unit-tests/directive-sinclude.exp
diff -u /dev/null src/usr.bin/make/unit-tests/directive-sinclude.exp:1.1
--- /dev/null Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-sinclude.exp Sun Sep 13 09:20:23 2020
@@ -0,0 +1 @@
+exit status 0
Index: src/usr.bin/make/unit-tests/directive-sinclude.mk
diff -u /dev/null src/usr.bin/make/unit-tests/directive-sinclude.mk:1.1
--- /dev/null Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-sinclude.mk Sun Sep 13 09:20:23 2020
@@ -0,0 +1,9 @@
+# $NetBSD: directive-sinclude.mk,v 1.1 2020/09/13 09:20:23 rillig Exp $
+#
+# Tests for the .sinclude directive, which includes another file,
+# silently skipping it if it cannot be opened.
+
+# TODO: Implementation
+
+all:
+ @:;