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 tests/make: extend tests for .USE an...



details:   https://anonhg.NetBSD.org/src/rev/ed572304392f
branches:  trunk
changeset: 365694:ed572304392f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Apr 18 14:38:24 2022 +0000

description:
tests/make: extend tests for .USE and .USEBEFORE

diffstat:

 usr.bin/make/unit-tests/depsrc-use.exp       |    4 +
 usr.bin/make/unit-tests/depsrc-use.mk        |   16 +++-
 usr.bin/make/unit-tests/depsrc-usebefore.exp |   46 ++++++++++-
 usr.bin/make/unit-tests/depsrc-usebefore.mk  |  102 ++++++++++++++++++++++++--
 4 files changed, 149 insertions(+), 19 deletions(-)

diffs (232 lines):

diff -r c8557aad1bf7 -r ed572304392f usr.bin/make/unit-tests/depsrc-use.exp
--- a/usr.bin/make/unit-tests/depsrc-use.exp    Mon Apr 18 14:11:43 2022 +0000
+++ b/usr.bin/make/unit-tests/depsrc-use.exp    Mon Apr 18 14:38:24 2022 +0000
@@ -2,5 +2,9 @@
 first 2
 second 1
 second 2
+first-first 1
+first-first 2
+first-second 1
+first-second 2
 directly
 exit status 0
diff -r c8557aad1bf7 -r ed572304392f usr.bin/make/unit-tests/depsrc-use.mk
--- a/usr.bin/make/unit-tests/depsrc-use.mk     Mon Apr 18 14:11:43 2022 +0000
+++ b/usr.bin/make/unit-tests/depsrc-use.mk     Mon Apr 18 14:38:24 2022 +0000
@@ -1,7 +1,11 @@
-# $NetBSD: depsrc-use.mk,v 1.5 2021/12/28 14:22:51 rillig Exp $
+# $NetBSD: depsrc-use.mk,v 1.6 2022/04/18 14:38:24 rillig Exp $
 #
 # Tests for the special source .USE in dependency declarations,
 # which allows to append common commands to other targets.
+#
+# See also:
+#      .USEBEFORE
+#      depsrc-usebefore.mk
 
 # Before make.h 1.280 from 2021-12-28, a .USEBEFORE target was accidentally
 # regarded as a candidate for the main target.  On the other hand, a .USE
@@ -10,9 +14,15 @@
 
 all: action directly
 
-first: .USE
+first: .USE first-first first-second
        @echo first 1           # Using ${.TARGET} here would expand to "action"
        @echo first 2
+first-first: .USE
+       @echo first-first 1
+       @echo first-first 2
+first-second: .USE
+       @echo first-second 1
+       @echo first-second 2
 
 second: .USE
        @echo second 1
@@ -22,7 +32,7 @@
 # This may happen as the result of expanding a .for loop.
 empty: .USE
 
-# It's possible but uncommon to directly make a .USEBEFORE target.
+# It's possible but uncommon to directly make a .USE target.
 directly: .USE
        @echo directly
 
diff -r c8557aad1bf7 -r ed572304392f usr.bin/make/unit-tests/depsrc-usebefore.exp
--- a/usr.bin/make/unit-tests/depsrc-usebefore.exp      Mon Apr 18 14:11:43 2022 +0000
+++ b/usr.bin/make/unit-tests/depsrc-usebefore.exp      Mon Apr 18 14:38:24 2022 +0000
@@ -1,6 +1,42 @@
-first 1
-first 2
-second 1
-second 2
-directly
+after-2-before-2 1
+after-2-before-2 2
+after-2-before-1 1
+after-2-before-1 2
+after-1-before-2 1
+after-1-before-2 2
+after-1-before-1 1
+after-1-before-1 2
+before-2-before-2 1
+before-2-before-2 2
+before-2-before-1 1
+before-2-before-1 2
+before-1-before-2 1
+before-1-before-2 2
+before-1-before-1 1
+before-1-before-1 2
+before-2 1
+before-2 2
+before-1 1
+before-1 2
+after-1 1
+after-1 2
+after-2 1
+after-2 2
+before-1-after-1 1
+before-1-after-1 2
+before-1-after-2 1
+before-1-after-2 2
+before-2-after-1 1
+before-2-after-1 2
+before-2-after-2 1
+before-2-after-2 2
+after-1-after-1 1
+after-1-after-1 2
+after-1-after-2 1
+after-1-after-2 2
+after-2-after-1 1
+after-2-after-1 2
+after-2-after-2 1
+after-2-after-2 2
+`directly' is up to date.
 exit status 0
diff -r c8557aad1bf7 -r ed572304392f usr.bin/make/unit-tests/depsrc-usebefore.mk
--- a/usr.bin/make/unit-tests/depsrc-usebefore.mk       Mon Apr 18 14:11:43 2022 +0000
+++ b/usr.bin/make/unit-tests/depsrc-usebefore.mk       Mon Apr 18 14:38:24 2022 +0000
@@ -1,8 +1,12 @@
-# $NetBSD: depsrc-usebefore.mk,v 1.7 2021/12/28 14:22:51 rillig Exp $
+# $NetBSD: depsrc-usebefore.mk,v 1.8 2022/04/18 14:38:24 rillig Exp $
 #
 # Tests for the special source .USEBEFORE in dependency declarations,
 # which allows to prepend common commands to other targets.
 #
+# If a target depends on several .USE or .USEBEFORE targets, the commands get
+# appended in declaration order.  For .USE targets, this is the expected
+# order, for .USEBEFORE targets the order is somewhat reversed.
+#
 # See also:
 #      .USE
 #      depsrc-use.mk
@@ -12,22 +16,98 @@
 # target was not.
 not-a-main-candidate: .USEBEFORE
 
-all: action directly
+all:
+       @${MAKE} -r -f ${MAKEFILE} ordering
+       @${MAKE} -r -f ${MAKEFILE} directly
+
+ordering: before-1 before-2 after-1 after-2
+
+before-1: .USEBEFORE before-1-before-1 before-1-before-2 before-1-after-1 before-1-after-2
+       @echo before-1 1
+       @echo before-1 2
+
+before-1-before-1: .USEBEFORE
+       @echo before-1-before-1 1
+       @echo before-1-before-1 2
+
+before-1-before-2: .USEBEFORE
+       @echo before-1-before-2 1
+       @echo before-1-before-2 2
+
+before-1-after-1: .USE
+       @echo before-1-after-1 1
+       @echo before-1-after-1 2
+
+before-1-after-2: .USE
+       @echo before-1-after-2 1
+       @echo before-1-after-2 2
+
+before-2: .USEBEFORE before-2-before-1 before-2-before-2 before-2-after-1 before-2-after-2
+       @echo before-2 1
+       @echo before-2 2
+
+before-2-before-1: .USEBEFORE
+       @echo before-2-before-1 1
+       @echo before-2-before-1 2
+
+before-2-before-2: .USEBEFORE
+       @echo before-2-before-2 1
+       @echo before-2-before-2 2
+
+before-2-after-1: .USE
+       @echo before-2-after-1 1
+       @echo before-2-after-1 2
 
-first: .USEBEFORE
-       @echo first 1           # Using ${.TARGET} here would expand to "action"
-       @echo first 2           # Using ${.TARGET} here would expand to "action"
+before-2-after-2: .USE
+       @echo before-2-after-2 1
+       @echo before-2-after-2 2
+
+after-1: .USE after-1-before-1 after-1-before-2 after-1-after-1 after-1-after-2
+       @echo after-1 1
+       @echo after-1 2
+
+after-1-before-1: .USEBEFORE
+       @echo after-1-before-1 1
+       @echo after-1-before-1 2
+
+after-1-before-2: .USEBEFORE
+       @echo after-1-before-2 1
+       @echo after-1-before-2 2
+
+after-1-after-1: .USE
+       @echo after-1-after-1 1
+       @echo after-1-after-1 2
 
-second: .USEBEFORE
-       @echo second 1
-       @echo second 2
+after-1-after-2: .USE
+       @echo after-1-after-2 1
+       @echo after-1-after-2 2
+
+after-2: .USE after-2-before-1 after-2-before-2 after-2-after-1 after-2-after-2
+       @echo after-2 1
+       @echo after-2 2
+
+after-2-before-1: .USEBEFORE
+       @echo after-2-before-1 1
+       @echo after-2-before-1 2
+
+after-2-before-2: .USEBEFORE
+       @echo after-2-before-2 1
+       @echo after-2-before-2 2
+
+after-2-after-1: .USE
+       @echo after-2-after-1 1
+       @echo after-2-after-1 2
+
+after-2-after-2: .USE
+       @echo after-2-after-2 1
+       @echo after-2-after-2 2
 
 # It is 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 is possible but uncommon to directly make a .USEBEFORE target.
+# It is technically possible to directly make a .USEBEFORE target, but it
+# doesn't make sense since GNode_IsOODate considers such a target to always be
+# up to date.
 directly: .USEBEFORE
        @echo directly
-
-action: second first empty



Home | Main Index | Thread Index | Old Index