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): enable test for .IMPSRC



details:   https://anonhg.NetBSD.org/src/rev/7de1145af8c0
branches:  trunk
changeset: 937043:7de1145af8c0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Aug 07 13:43:50 2020 +0000

description:
make(1): enable test for .IMPSRC

Having this test disabled was very confusing since its content didn't
match the actual behavior, and this also differs from the GNU make
behavior.

diffstat:

 usr.bin/make/unit-tests/Makefile   |   4 ++--
 usr.bin/make/unit-tests/impsrc.exp |  16 ++++++++--------
 usr.bin/make/unit-tests/impsrc.mk  |  29 +++++++++++++++++++++++------
 3 files changed, 33 insertions(+), 16 deletions(-)

diffs (107 lines):

diff -r 0493aef229cb -r 7de1145af8c0 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Fri Aug 07 13:36:28 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Fri Aug 07 13:43:50 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.85 2020/08/06 16:23:52 sjg Exp $
+# $NetBSD: Makefile,v 1.86 2020/08/07 13:43:50 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -55,7 +55,7 @@
 TESTS+=                forloop
 TESTS+=                forsubst
 TESTS+=                hash
-TESTS+=                # impsrc        # broken by reverting POSIX changes
+TESTS+=                impsrc
 TESTS+=                include-main
 TESTS+=                lint
 TESTS+=                misc
diff -r 0493aef229cb -r 7de1145af8c0 usr.bin/make/unit-tests/impsrc.exp
--- a/usr.bin/make/unit-tests/impsrc.exp        Fri Aug 07 13:36:28 2020 +0000
+++ b/usr.bin/make/unit-tests/impsrc.exp        Fri Aug 07 13:43:50 2020 +0000
@@ -1,13 +1,13 @@
-expected: source4
-actual:   source4
+expected: 
+actual:   
 expected: target1.x
 actual:   target1.x
 expected: target1.y
 actual:   target1.y
-expected: source1
-actual:   source1
-expected: source2
-actual:   source2
-expected: source1
-actual:   source1
+expected: 
+actual:   
+expected: 
+actual:   
+expected: 
+actual:   
 exit status 0
diff -r 0493aef229cb -r 7de1145af8c0 usr.bin/make/unit-tests/impsrc.mk
--- a/usr.bin/make/unit-tests/impsrc.mk Fri Aug 07 13:36:28 2020 +0000
+++ b/usr.bin/make/unit-tests/impsrc.mk Fri Aug 07 13:43:50 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: impsrc.mk,v 1.2 2014/08/30 22:21:07 sjg Exp $
+# $NetBSD: impsrc.mk,v 1.3 2020/08/07 13:43:50 rillig Exp $
 
 # Does ${.IMPSRC} work properly?
 # It should be set, in order of precedence, to ${.TARGET} of:
@@ -6,6 +6,8 @@
 #  2) the first prerequisite from the dependency line of an explicit rule, or
 #  3) the first prerequisite of an explicit rule.
 #
+# Items 2 and 3 work in GNU make.
+# Items 2 and 3 are not required by POSIX 2018.
 
 all: target1.z target2 target3 target4
 
@@ -19,25 +21,40 @@
        @echo 'expected: target1.y'
        @echo 'actual:   $<'
 
+# (3) Making target1.z out of target1.y is done because of an inference rule.
+# Therefore $< is available here.
+
+# (2) This is an additional dependency on the inference rule .x.y.
+# The dependency target1.x comes from the inference rule,
+# therefore it is available as $<.
 target1.y: source3
 
+# (1) This is an explicit dependency, not an inference rule.
+# Therefore POSIX does not specify that $< be available here.
 target1.x: source4
-       @echo 'expected: source4'
+       @echo 'expected: '              # either 'source4' or ''
        @echo 'actual:   $<'
 
+# (4) This is an explicit dependency, independent of any inference rule.
+# Therefore $< is not available here.
 target2: source1 source2
-       @echo 'expected: source1'
+       @echo 'expected: '
        @echo 'actual:   $<'
 
+# (5) These are two explicit dependency rules.
+# The first doesn't have any dependencies, only the second has.
+# If any, the value of $< would be 'source2'.
 target3: source1
 target3: source2 source3
-       @echo 'expected: source2'
+       @echo 'expected: '
        @echo 'actual:   $<'
 
+# (6) The explicit rule does not have associated commands.
+# The value of $< might come from that rule,
+# but it's equally fine to leave $< undefined.
 target4: source1
 target4:
-       @echo 'expected: source1'
+       @echo 'expected: '
        @echo 'actual:   $<'
 
 source1 source2 source3 source4:
-



Home | Main Index | Thread Index | Old Index