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 turning a targ...



details:   https://anonhg.NetBSD.org/src/rev/57cfb86e287d
branches:  trunk
changeset: 941088:57cfb86e287d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 18 16:33:18 2020 +0000

description:
make(1): add test for turning a target into a transformation

diffstat:

 distrib/sets/lists/tests/mi           |   4 +++-
 usr.bin/make/unit-tests/Makefile      |   3 ++-
 usr.bin/make/unit-tests/suff-main.exp |   2 ++
 usr.bin/make/unit-tests/suff-main.mk  |  22 ++++++++++++++++++++++
 4 files changed, 29 insertions(+), 2 deletions(-)

diffs (67 lines):

diff -r a1d59cb4a711 -r 57cfb86e287d distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun Oct 18 16:28:57 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Oct 18 16:33:18 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.942 2020/10/16 07:12:26 mgorny Exp $
+# $NetBSD: mi,v 1.943 2020/10/18 16:33:18 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4987,6 +4987,8 @@
 ./usr/tests/usr.bin/make/unit-tests/shell-ksh.mk                               tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/shell-sh.exp                               tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/shell-sh.mk                                        tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-main.exp                              tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-main.mk                               tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/suff-rebuild.exp                           tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/suff-rebuild.mk                            tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/suffixes.exp                               tests-usr.bin-tests     compattestfile,atf
diff -r a1d59cb4a711 -r 57cfb86e287d usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Sun Oct 18 16:28:57 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Sun Oct 18 16:33:18 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.166 2020/10/17 16:53:26 rillig Exp $
+# $NetBSD: Makefile,v 1.167 2020/10/18 16:33:18 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -250,6 +250,7 @@
 TESTS+=                shell-ksh
 TESTS+=                shell-sh
 TESTS+=                # suffixes      # runs into an endless loop (try -dA)
+TESTS+=                suff-main
 TESTS+=                suff-rebuild
 TESTS+=                sunshcmd
 TESTS+=                sysv
diff -r a1d59cb4a711 -r 57cfb86e287d usr.bin/make/unit-tests/suff-main.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-main.exp     Sun Oct 18 16:33:18 2020 +0000
@@ -0,0 +1,2 @@
+: Making next-main
+exit status 0
diff -r a1d59cb4a711 -r 57cfb86e287d usr.bin/make/unit-tests/suff-main.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-main.mk      Sun Oct 18 16:33:18 2020 +0000
@@ -0,0 +1,22 @@
+# $NetBSD: suff-main.mk,v 1.1 2020/10/18 16:33:18 rillig Exp $
+#
+# Demonstrate that an inference rule is considered the main target if its
+# suffixes are not known at the point of declaration.
+
+.1.2:
+       : Making ${.TARGET} from ${.IMPSRC}.
+
+# At this point, the target '.1.2' is a normal target.
+# Since it is the first target in the first dependency declaration,
+# it becomes the main target.
+
+next-main:
+       : Making ${.TARGET}
+
+# At this point, 'next-main' is effectively ignored.
+
+# Declaring both '.1' and '.2' as suffixes turns the '.1.2' target into an
+# inference rule (OP_TRANSFORM).  As a side effect, this target is no longer
+# a candidate for the main target.  Therefore the next target is selected as
+# the main target, which in this case is 'next-main'.
+.SUFFIXES: .1 .2



Home | Main Index | Thread Index | Old Index