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 tests for .else and .fo...
details: https://anonhg.NetBSD.org/src/rev/e8319a7297fd
branches: trunk
changeset: 937983:e8319a7297fd
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Aug 29 18:50:25 2020 +0000
description:
make(1): add tests for .else and .for + .endif
diffstat:
distrib/sets/lists/tests/mi | 4 +-
usr.bin/make/unit-tests/Makefile | 3 +-
usr.bin/make/unit-tests/directive-else.exp | 9 ++++-
usr.bin/make/unit-tests/directive-else.mk | 28 +++++++++++++-
usr.bin/make/unit-tests/directive-for-generating-endif.exp | 7 +++
usr.bin/make/unit-tests/directive-for-generating-endif.mk | 25 ++++++++++++
6 files changed, 71 insertions(+), 5 deletions(-)
diffs (126 lines):
diff -r 6138542e41e4 -r e8319a7297fd distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sat Aug 29 17:41:14 2020 +0000
+++ b/distrib/sets/lists/tests/mi Sat Aug 29 18:50:25 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.913 2020/08/29 14:47:26 rillig Exp $
+# $NetBSD: mi,v 1.914 2020/08/29 18:50:25 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -4730,6 +4730,8 @@
./usr/tests/usr.bin/make/unit-tests/directive-export-literal.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/directive-export.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/directive-export.mk tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/directive-for-generating-endif.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/directive-for-generating-endif.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/directive-if.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/directive-if.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/directive-ifdef.exp tests-usr.bin-tests compattestfile,atf
diff -r 6138542e41e4 -r e8319a7297fd usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Sat Aug 29 17:41:14 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile Sat Aug 29 18:50:25 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.126 2020/08/29 14:47:26 rillig Exp $
+# $NetBSD: Makefile,v 1.127 2020/08/29 18:50:25 rillig Exp $
#
# Unit tests for make(1)
#
@@ -132,6 +132,7 @@
TESTS+= directive-export
TESTS+= directive-export-env
TESTS+= directive-export-literal
+TESTS+= directive-for-generating-endif
TESTS+= directive-if
TESTS+= directive-ifdef
TESTS+= directive-ifmake
diff -r 6138542e41e4 -r e8319a7297fd usr.bin/make/unit-tests/directive-else.exp
--- a/usr.bin/make/unit-tests/directive-else.exp Sat Aug 29 17:41:14 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-else.exp Sat Aug 29 18:50:25 2020 +0000
@@ -1,1 +1,8 @@
-exit status 0
+make: "directive-else.mk" line 10: ok
+make: "directive-else.mk" line 14: ok
+make: "directive-else.mk" line 20: if-less else
+make: "directive-else.mk" line 26: ok
+make: "directive-else.mk" line 27: warning: extra else
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r 6138542e41e4 -r e8319a7297fd usr.bin/make/unit-tests/directive-else.mk
--- a/usr.bin/make/unit-tests/directive-else.mk Sat Aug 29 17:41:14 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-else.mk Sat Aug 29 18:50:25 2020 +0000
@@ -1,8 +1,32 @@
-# $NetBSD: directive-else.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: directive-else.mk,v 1.3 2020/08/29 18:50:25 rillig Exp $
#
# Tests for the .else directive.
-# TODO: Implementation
+# The .else directive does not take any arguments.
+# As of 2020-08-29, make doesn't warn about this.
+.if 0
+.warning must not be reached
+.else 123
+.info ok
+.endif
+
+.if 1
+.info ok
+.else 123
+.warning must not be reached
+.endif
+
+# An .else without a corresponding .if is an error.
+.else
+
+# Accidental extra .else directives are detected too.
+.if 0
+.warning must not be reached
+.else
+.info ok
+.else
+.info After an extra .else, everything is skipped.
+.endif
all:
@:;
diff -r 6138542e41e4 -r e8319a7297fd usr.bin/make/unit-tests/directive-for-generating-endif.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/directive-for-generating-endif.exp Sat Aug 29 18:50:25 2020 +0000
@@ -0,0 +1,7 @@
+make: "directive-for-generating-endif.mk" line 21: if-less endif
+make: "directive-for-generating-endif.mk" line 21: if-less endif
+make: "directive-for-generating-endif.mk" line 21: if-less endif
+make: "directive-for-generating-endif.mk" line 0: 3 open conditionals
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r 6138542e41e4 -r e8319a7297fd usr.bin/make/unit-tests/directive-for-generating-endif.mk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/directive-for-generating-endif.mk Sat Aug 29 18:50:25 2020 +0000
@@ -0,0 +1,25 @@
+# $NetBSD: directive-for-generating-endif.mk,v 1.1 2020/08/29 18:50:25 rillig Exp $
+#
+# Test whether a .for loop can be used to generate multiple .endif
+# directives to close nested .if directives. Depending on the exact
+# implementation, this might have been possible.
+#
+# If it were possible, the 3 .if directives would perfectly match the
+# 3 .endif directives generated by the .for loop.
+#
+# After the "included file" from the .for loop, the 3 .if directives
+# are still open.
+#
+# See For_Run and ParseReadLine. Each .for loop is treated like a separately
+# included file, and in each included file the .if/.endif directives must be
+# balanced.
+
+.if 1
+. if 2
+. if 3
+.for i in 3 2 1
+.endif
+.endfor
+
+all:
+ @:;
Home |
Main Index |
Thread Index |
Old Index