Module Name: src
Committed By: rillig
Date: Mon Jul 27 20:46:18 UTC 2020
Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: directives.exp directives.mk
Log Message:
make(1): add tests for parsing directives like .if and .info
To generate a diff of this commit:
cvs rdiff -u -r1.879 -r1.880 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.69 -r1.70 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/directives.exp \
src/usr.bin/make/unit-tests/directives.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.879 src/distrib/sets/lists/tests/mi:1.880
--- src/distrib/sets/lists/tests/mi:1.879 Mon Jul 27 18:51:03 2020
+++ src/distrib/sets/lists/tests/mi Mon Jul 27 20:46:18 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.879 2020/07/27 18:51:03 rillig Exp $
+# $NetBSD: mi,v 1.880 2020/07/27 20:46:18 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -4534,6 +4534,8 @@
./usr/tests/usr.bin/make/unit-tests/cond1.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/cond2.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/cond2.mk tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/directives.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/directives.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/dollar.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/dollar.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/doterror.exp tests-usr.bin-tests compattestfile,atf
Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.69 src/usr.bin/make/unit-tests/Makefile:1.70
--- src/usr.bin/make/unit-tests/Makefile:1.69 Mon Jul 27 19:45:56 2020
+++ src/usr.bin/make/unit-tests/Makefile Mon Jul 27 20:46:17 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.69 2020/07/27 19:45:56 rillig Exp $
+# $NetBSD: Makefile,v 1.70 2020/07/27 20:46:17 rillig Exp $
#
# Unit tests for make(1)
#
@@ -36,6 +36,7 @@ TESTS+= cond-late
TESTS+= cond-short
TESTS+= cond1
TESTS+= cond2
+TESTS+= directives
TESTS+= dollar
TESTS+= doterror
TESTS+= dotwait
Added files:
Index: src/usr.bin/make/unit-tests/directives.exp
diff -u /dev/null src/usr.bin/make/unit-tests/directives.exp:1.1
--- /dev/null Mon Jul 27 20:46:18 2020
+++ src/usr.bin/make/unit-tests/directives.exp Mon Jul 27 20:46:17 2020
@@ -0,0 +1,30 @@
+make: "directives.mk" line 10: begin .export tests
+make: "directives.mk" line 11: Unknown directive
+make: "directives.mk" line 20: begin .export-env tests
+make: "directives.mk" line 30: begin .export-literal tests
+make: "directives.mk" line 40: begin .info tests
+make: "directives.mk" line 41: Unknown directive
+make: "directives.mk" line 42: Unknown directive
+make: "directives.mk" line 43: message
+make: "directives.mk" line 44: indented message
+make: "directives.mk" line 45: Unknown directive
+make: "directives.mk" line 46: message
+make: "directives.mk" line 50: begin .undef tests
+make: "directives.mk" line 51: Unknown directive
+make: "directives.mk" line 60: begin .unexport tests
+make: "directives.mk" line 61: Unknown directive
+make: "directives.mk" line 70: begin .unexport-env tests
+make: "directives.mk" line 80: begin .warning tests
+make: "directives.mk" line 81: Unknown directive
+make: "directives.mk" line 82: Unknown directive
+make: "directives.mk" line 83: Unknown directive
+make: "directives.mk" line 84: warning: message
+make: "directives.mk" line 85: Unknown directive
+make: "directives.mk" line 86: warning: messages
+make: "directives.mk" line 90: begin .elif misspellings tests, part 1
+make: "directives.mk" line 100: begin .elif misspellings tests, part 2
+make: "directives.mk" line 110: begin .elif misspellings tests, part 3
+make: "directives.mk" line 120: end of the tests
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/directives.mk
diff -u /dev/null src/usr.bin/make/unit-tests/directives.mk:1.1
--- /dev/null Mon Jul 27 20:46:18 2020
+++ src/usr.bin/make/unit-tests/directives.mk Mon Jul 27 20:46:17 2020
@@ -0,0 +1,123 @@
+# $NetBSD: directives.mk,v 1.1 2020/07/27 20:46:17 rillig Exp $
+#
+# Tests for parsing directives, in the same order as in the manual page.
+#
+# Each test group has 10 lines, to keep the expected file stable.
+#
+# no tests for .error since it exits immediately, see ParseMessage.
+
+
+.info begin .export tests
+.expor # misspelled
+.export # oops: missing argument
+.export VARNAME
+.exporting works # oops: misspelled
+
+
+
+
+
+.info begin .export-env tests
+.export-en # oops: misspelled
+.export-env
+.export-environment # oops: misspelled
+
+
+
+
+
+
+.info begin .export-literal tests
+.export-litera # oops: misspelled
+.export-literal # oops: missing argument
+.export-literal VARNAME
+.export-literally # oops: misspelled
+
+
+
+
+
+.info begin .info tests
+.inf # misspelled
+.info # oops: message should be "missing parameter"
+.info message
+.info indented message
+.information
+.information message # oops: misspelled
+
+
+
+.info begin .undef tests
+.unde # misspelled
+.undef # oops: missing argument
+.undefined # oops: misspelled
+.undef VARNAME
+
+
+
+
+
+.info begin .unexport tests
+.unexpor # misspelled
+.unexport # oops: missing argument
+.unexport VARNAME # ok
+.unexporting works # oops: misspelled
+
+
+
+
+
+.info begin .unexport-env tests
+.unexport-en # misspelled
+.unexport-env # ok
+.unexport-environment # oops: misspelled
+
+
+
+
+
+
+.info begin .warning tests
+.warn # misspelled
+.warnin # misspelled
+.warning # oops: should be "missing argument"
+.warning message # ok
+.warnings # misspelled
+.warnings messages # oops
+
+
+
+.info begin .elif misspellings tests, part 1
+.if 1
+.elif 1 # ok
+.elsif 1 # oops: misspelled
+.elseif 1 # oops: misspelled
+.endif
+
+
+
+
+.info begin .elif misspellings tests, part 2
+.if 0
+.elif 0 # ok
+.elsif 0 # oops: misspelled
+.elseif 0 # oops: misspelled
+.endif
+
+
+
+
+.info begin .elif misspellings tests, part 3
+.if 0
+.elsif 0 # oops: misspelled
+.endif
+.if 0
+.elseif 0 # oops: misspelled
+.endif
+
+
+
+.info end of the tests
+
+all:
+ @: