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 parse errors i...



details:   https://anonhg.NetBSD.org/src/rev/1f28b8172101
branches:  trunk
changeset: 956622:1f28b8172101
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Nov 02 20:43:27 2020 +0000

description:
make(1): add test for parse errors in commands in lint mode (-dL)

The difference to non-lint mode is that the exit status is now 2 instead
of 0.

diffstat:

 distrib/sets/lists/tests/mi                 |   4 ++-
 usr.bin/make/unit-tests/Makefile            |   3 +-
 usr.bin/make/unit-tests/cmd-errors-lint.exp |   8 +++++++
 usr.bin/make/unit-tests/cmd-errors-lint.mk  |  32 +++++++++++++++++++++++++++++
 4 files changed, 45 insertions(+), 2 deletions(-)

diffs (83 lines):

diff -r c0b86e5ee88b -r 1f28b8172101 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Mon Nov 02 20:40:10 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Mon Nov 02 20:43:27 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.958 2020/11/02 20:20:42 rillig Exp $
+# $NetBSD: mi,v 1.959 2020/11/02 20:43:27 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4813,6 +4813,8 @@
 ./usr/tests/usr.bin/make/unit-tests/archive-suffix.mk                          tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/archive.exp                                        tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/archive.mk                                 tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/cmd-errors-lint.exp                                tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/cmd-errors-lint.mk                         tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cmd-errors.exp                             tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cmd-errors.mk                              tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cmd-interrupt.exp                          tests-usr.bin-tests     compattestfile,atf
diff -r c0b86e5ee88b -r 1f28b8172101 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Mon Nov 02 20:40:10 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Mon Nov 02 20:43:27 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.184 2020/11/02 20:40:10 rillig Exp $
+# $NetBSD: Makefile,v 1.185 2020/11/02 20:43:27 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -38,6 +38,7 @@
 TESTS+=                archive
 TESTS+=                archive-suffix
 TESTS+=                cmd-errors
+TESTS+=                cmd-errors-lint
 TESTS+=                cmd-interrupt
 TESTS+=                cmdline
 TESTS+=                comment
diff -r c0b86e5ee88b -r 1f28b8172101 usr.bin/make/unit-tests/cmd-errors-lint.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/cmd-errors-lint.exp       Mon Nov 02 20:43:27 2020 +0000
@@ -0,0 +1,8 @@
+: undefined 
+make: Unclosed variable "UNCLOSED"
+: unclosed-variable 
+: unclosed-modifier 
+make: Unknown modifier 'Z'
+: unknown-modifier 
+: end
+exit status 2
diff -r c0b86e5ee88b -r 1f28b8172101 usr.bin/make/unit-tests/cmd-errors-lint.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/cmd-errors-lint.mk        Mon Nov 02 20:43:27 2020 +0000
@@ -0,0 +1,32 @@
+# $NetBSD: cmd-errors-lint.mk,v 1.1 2020/11/02 20:43:27 rillig Exp $
+#
+# Demonstrate how errors in variable expansions affect whether the commands
+# are actually executed.
+
+.MAKEFLAGS: -dL
+
+all: undefined unclosed-variable unclosed-modifier unknown-modifier end
+
+# Undefined variables are not an error.  They expand to empty strings.
+undefined:
+       : $@ ${UNDEFINED}
+
+# XXX: As of 2020-11-01, this obvious syntax error is not detected.
+# XXX: As of 2020-11-01, this command is executed even though it contains
+# parse errors.
+unclosed-variable:
+       : $@ ${UNCLOSED
+
+# XXX: As of 2020-11-01, this obvious syntax error is not detected.
+# XXX: As of 2020-11-01, this command is executed even though it contains
+# parse errors.
+unclosed-modifier:
+       : $@ ${UNCLOSED:
+
+# XXX: As of 2020-11-01, this command is executed even though it contains
+# parse errors.
+unknown-modifier:
+       : $@ ${UNKNOWN:Z}
+
+end:
+       : $@



Home | Main Index | Thread Index | Old Index