Module Name: src
Committed By: rillig
Date: Sun Aug 9 16:32:29 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: use-inference.exp use-inference.mk
Log Message:
make(1): add test for .USE combined with inference rule without commands
Discovered by christos.
To generate a diff of this commit:
cvs rdiff -u -r1.887 -r1.888 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/use-inference.exp \
src/usr.bin/make/unit-tests/use-inference.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.887 src/distrib/sets/lists/tests/mi:1.888
--- src/distrib/sets/lists/tests/mi:1.887 Sun Aug 9 12:59:16 2020
+++ src/distrib/sets/lists/tests/mi Sun Aug 9 16:32:28 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.887 2020/08/09 12:59:16 rillig Exp $
+# $NetBSD: mi,v 1.888 2020/08/09 16:32:28 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -4616,6 +4616,8 @@
./usr/tests/usr.bin/make/unit-tests/unexport-env.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/unexport.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/unexport.mk tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/use-inference.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/use-inference.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varcmd.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varcmd.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/vardebug.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.90 src/usr.bin/make/unit-tests/Makefile:1.91
--- src/usr.bin/make/unit-tests/Makefile:1.90 Sun Aug 9 12:59:16 2020
+++ src/usr.bin/make/unit-tests/Makefile Sun Aug 9 16:32:28 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.90 2020/08/09 12:59:16 rillig Exp $
+# $NetBSD: Makefile,v 1.91 2020/08/09 16:32:28 rillig Exp $
#
# Unit tests for make(1)
#
@@ -79,6 +79,7 @@ TESTS+= sysv
TESTS+= ternary
TESTS+= unexport
TESTS+= unexport-env
+TESTS+= use-inference
TESTS+= varcmd
TESTS+= vardebug
TESTS+= varfind
Added files:
Index: src/usr.bin/make/unit-tests/use-inference.exp
diff -u /dev/null src/usr.bin/make/unit-tests/use-inference.exp:1.1
--- /dev/null Sun Aug 9 16:32:29 2020
+++ src/usr.bin/make/unit-tests/use-inference.exp Sun Aug 9 16:32:28 2020
@@ -0,0 +1,4 @@
+Building use-inference.from from nothing
+make: don't know how to make use-inference.to (continuing)
+`all' not remade because of errors.
+exit status 0
Index: src/usr.bin/make/unit-tests/use-inference.mk
diff -u /dev/null src/usr.bin/make/unit-tests/use-inference.mk:1.1
--- /dev/null Sun Aug 9 16:32:29 2020
+++ src/usr.bin/make/unit-tests/use-inference.mk Sun Aug 9 16:32:28 2020
@@ -0,0 +1,35 @@
+# $NetBSD: use-inference.mk,v 1.1 2020/08/09 16:32:28 rillig Exp $
+#
+# Demonstrate that .USE rules do not have an effect on inference rules.
+# At least not in the special case where the inference rule does not
+# have any associated commands.
+
+.SUFFIXES:
+.SUFFIXES: .from .to
+
+all: use-inference.to
+
+verbose: .USE
+ @echo 'Verbosely making $@ out of $>'
+
+.from.to: verbose
+# Since this inference rule does not have any associated commands, it
+# is ignored.
+#
+# @echo 'Building $@ from $<'
+
+use-inference.from: # assume it exists
+ @echo 'Building $@ from nothing'
+
+# Possible but unproven explanation:
+#
+# The main target is "all", which depends on "use-inference.to".
+# The inference connects the .from to the .to file, otherwise make
+# would not know that the .from file would need to be built.
+#
+# The .from file is then built.
+#
+# After this, make stops since it doesn't know how to make the .to file.
+# This is strange since make definitely knows about the .from.to suffix
+# inference rule. But it seems to ignore it, maybe because it doesn't
+# have any associated commands.