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 the special "....



details:   https://anonhg.NetBSD.org/src/rev/ebb6f43776d7
branches:  trunk
changeset: 975133:ebb6f43776d7
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 22 11:27:02 2020 +0000

description:
make(1): add test for the special "..." in shell commands

diffstat:

 distrib/sets/lists/tests/mi         |   4 +++-
 usr.bin/make/unit-tests/Makefile    |   3 ++-
 usr.bin/make/unit-tests/sh-dots.exp |  15 +++++++++++++++
 usr.bin/make/unit-tests/sh-dots.mk  |  37 +++++++++++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+), 2 deletions(-)

diffs (95 lines):

diff -r b2f8157b6ad1 -r ebb6f43776d7 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sat Aug 22 11:01:10 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Sat Aug 22 11:27:02 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.897 2020/08/22 08:29:13 rillig Exp $
+# $NetBSD: mi,v 1.898 2020/08/22 11:27:02 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4839,6 +4839,8 @@
 ./usr/tests/usr.bin/make/unit-tests/qequals.mk tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/recursive.exp      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/recursive.mk       tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/sh-dots.exp        tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/sh-dots.mk tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/sh-jobs-error.exp  tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/sh-jobs-error.mk   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/sh-jobs.exp        tests-usr.bin-tests     compattestfile,atf
diff -r b2f8157b6ad1 -r ebb6f43776d7 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Sat Aug 22 11:01:10 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Sat Aug 22 11:27:02 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.105 2020/08/22 08:29:13 rillig Exp $
+# $NetBSD: Makefile,v 1.106 2020/08/22 11:27:02 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -187,6 +187,7 @@
 TESTS+=                qequals
 TESTS+=                recursive
 TESTS+=                sh
+TESTS+=                sh-dots
 TESTS+=                sh-jobs
 TESTS+=                sh-jobs-error
 TESTS+=                sh-leading-at
diff -r b2f8157b6ad1 -r ebb6f43776d7 usr.bin/make/unit-tests/sh-dots.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/sh-dots.exp       Sat Aug 22 11:27:02 2020 +0000
@@ -0,0 +1,15 @@
+first first
+hidden hidden
+make: exec(...) failed (No such file or directory)
+hidden delayed hidden
+repeated repeated
+commented commented
+*** Error code 1 (ignored)
+...    # Run the below commands later
+...: not found
+commented delayed commented
+first delayed first
+repeated delayed repeated
+repeated delayed twice repeated
+*** Error code 127 (ignored)
+exit status 0
diff -r b2f8157b6ad1 -r ebb6f43776d7 usr.bin/make/unit-tests/sh-dots.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/sh-dots.mk        Sat Aug 22 11:27:02 2020 +0000
@@ -0,0 +1,37 @@
+# $NetBSD: sh-dots.mk,v 1.1 2020/08/22 11:27:02 rillig Exp $
+#
+# Tests for the special shell command line "...", which does not run the
+# commands below it but appends them to the list of commands that are run
+# at the end.
+
+all: first hidden repeated commented
+
+# The ${.TARGET} correctly expands to the target name, even though the
+# commands are run separately from the main commands.
+first:
+       @echo first ${.TARGET}
+       ...
+       @echo first delayed ${.TARGET}
+
+# The dots cannot be prefixed by the usual @-+ characters.
+# They must be written exactly as dots.
+hidden: .IGNORE
+       @echo hidden ${.TARGET}
+       @...
+       @echo hidden delayed ${.TARGET}
+
+# Since the shell command lines don't recognize '#' as comment character,
+# the "..." is not interpreted specially here.
+commented: .IGNORE
+       @echo commented ${.TARGET}
+       ...     # Run the below commands later
+       @echo commented delayed ${.TARGET}
+
+# The "..." can appear more than once, even though that doesn't make sense.
+# The second "..." is a no-op.
+repeated: .IGNORE
+       @echo repeated ${.TARGET}
+       ...
+       @echo repeated delayed ${.TARGET}
+       ...
+       @echo repeated delayed twice ${.TARGET}



Home | Main Index | Thread Index | Old Index