Module Name: src
Committed By: rillig
Date: Sat Aug 22 07:49:44 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: depsrc-use.exp depsrc-use.mk
depsrc-usebefore.mk
Log Message:
make(1): add test for the special source .USE
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/depsrc-use.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/depsrc-use.mk
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/depsrc-usebefore.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/unit-tests/depsrc-use.exp
diff -u src/usr.bin/make/unit-tests/depsrc-use.exp:1.1 src/usr.bin/make/unit-tests/depsrc-use.exp:1.2
--- src/usr.bin/make/unit-tests/depsrc-use.exp:1.1 Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/depsrc-use.exp Sat Aug 22 07:49:44 2020
@@ -1 +1,4 @@
+first
+second
+directly
exit status 0
Index: src/usr.bin/make/unit-tests/depsrc-use.mk
diff -u src/usr.bin/make/unit-tests/depsrc-use.mk:1.2 src/usr.bin/make/unit-tests/depsrc-use.mk:1.3
--- src/usr.bin/make/unit-tests/depsrc-use.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/depsrc-use.mk Sat Aug 22 07:49:44 2020
@@ -1,8 +1,22 @@
-# $NetBSD: depsrc-use.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: depsrc-use.mk,v 1.3 2020/08/22 07:49:44 rillig Exp $
#
-# Tests for the special source .USE in dependency declarations.
+# Tests for the special source .USE in dependency declarations,
+# which allows to append common commands to other targets.
-# TODO: Implementation
+all: action directly
-all:
- @:;
+first: .USE
+ @echo first # Using ${.TARGET} here would expand to "action"
+
+second: .USE
+ @echo second
+
+# It's possible but uncommon to have a .USE target with no commands.
+# This may happen as the result of expanding a .for loop.
+empty: .USE
+
+# It's possible but uncommon to directly make a .USEBEFORE target.
+directly: .USE
+ @echo directly
+
+action: first second empty
Index: src/usr.bin/make/unit-tests/depsrc-usebefore.mk
diff -u src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.3 src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.4
--- src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.3 Sat Aug 22 07:46:18 2020
+++ src/usr.bin/make/unit-tests/depsrc-usebefore.mk Sat Aug 22 07:49:44 2020
@@ -1,4 +1,4 @@
-# $NetBSD: depsrc-usebefore.mk,v 1.3 2020/08/22 07:46:18 rillig Exp $
+# $NetBSD: depsrc-usebefore.mk,v 1.4 2020/08/22 07:49:44 rillig Exp $
#
# Tests for the special source .USEBEFORE in dependency declarations,
# which allows to prepend common commands to other targets.
@@ -11,6 +11,8 @@ first: .USEBEFORE
second: .USEBEFORE
@echo second
+# It's possible but uncommon to have a .USEBEFORE target with no commands.
+# This may happen as the result of expanding a .for loop.
empty: .USEBEFORE
# It's possible but uncommon to directly make a .USEBEFORE target.