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): split test suffixes.mk into...



details:   https://anonhg.NetBSD.org/src/rev/1a6993d5f78e
branches:  trunk
changeset: 956079:1a6993d5f78e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Oct 20 20:36:53 2020 +0000

description:
make(1): split test suffixes.mk into simpler, isolated tests

The code in suff.c is already hard to understand, and so were the tests
in suffixes.mk since several independent topics were merged into a
single test.

Splitting this test into a separate test per issue allows to document
the expected and actual behavior in more detail.  That's complicated
enough already.

PR bin/49086

diffstat:

 distrib/sets/lists/tests/mi                        |  18 +++-
 tests/usr.bin/make/t_make.sh                       |   4 +-
 usr.bin/make/unit-tests/Makefile                   |   9 +-
 usr.bin/make/unit-tests/suff-add-later.exp         |   9 ++
 usr.bin/make/unit-tests/suff-add-later.mk          |  31 +++++++
 usr.bin/make/unit-tests/suff-clear-regular.exp     |   5 +
 usr.bin/make/unit-tests/suff-clear-regular.mk      |  31 +++++++
 usr.bin/make/unit-tests/suff-clear-single.exp      |   3 +
 usr.bin/make/unit-tests/suff-clear-single.mk       |  19 ++++
 usr.bin/make/unit-tests/suff-transform-endless.exp |   4 +
 usr.bin/make/unit-tests/suff-transform-endless.mk  |  36 ++++++++
 usr.bin/make/unit-tests/suff-transform-expand.exp  |   5 +
 usr.bin/make/unit-tests/suff-transform-expand.mk   |  25 ++++++
 usr.bin/make/unit-tests/suff-transform-select.exp  |   4 +
 usr.bin/make/unit-tests/suff-transform-select.mk   |  28 ++++++
 usr.bin/make/unit-tests/suffixes.exp               |  35 --------
 usr.bin/make/unit-tests/suffixes.mk                |  89 ----------------------
 17 files changed, 223 insertions(+), 132 deletions(-)

diffs (truncated from 459 to 300 lines):

diff -r 97b82c75d911 -r 1a6993d5f78e distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Tue Oct 20 20:36:06 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Tue Oct 20 20:36:53 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.943 2020/10/18 16:33:18 rillig Exp $
+# $NetBSD: mi,v 1.944 2020/10/20 20:36:53 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4987,12 +4987,24 @@
 ./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-add-later.exp                         tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-add-later.mk                          tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-clear-regular.exp                     tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-clear-regular.mk                      tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-clear-single.exp                      tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-clear-single.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
-./usr/tests/usr.bin/make/unit-tests/suffixes.mk                                        tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-transform-endless.exp                 tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-transform-endless.mk                  tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-transform-expand.exp                  tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-transform-expand.mk                   tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-transform-select.exp                  tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-transform-select.mk                   tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suffixes.exp                               tests-obsolete          obsolete
+./usr/tests/usr.bin/make/unit-tests/suffixes.mk                                        tests-obsolete          obsolete
 ./usr/tests/usr.bin/make/unit-tests/sunshcmd.exp                               tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/sunshcmd.mk                                        tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/sysv.exp                                   tests-usr.bin-tests     compattestfile,atf
diff -r 97b82c75d911 -r 1a6993d5f78e tests/usr.bin/make/t_make.sh
--- a/tests/usr.bin/make/t_make.sh      Tue Oct 20 20:36:06 2020 +0000
+++ b/tests/usr.bin/make/t_make.sh      Tue Oct 20 20:36:53 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_make.sh,v 1.11 2020/09/10 17:40:34 kre Exp $
+# $NetBSD: t_make.sh,v 1.12 2020/10/20 20:36:53 rillig Exp $
 #
 # Copyright (c) 2008, 2010, 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -36,8 +36,6 @@
        case ${makename} in
        escape)         atf_expect_fail "see PR toolchain/49085";;
        posix1)         atf_expect_fail "see PR toolchain/49085";;
-       suffixes)       atf_expect_fail "see PR toolchain/49085"
-                       atf_fail "this uses up all memory and then fails";;
        esac
 
        local srcdir="$(atf_get_srcdir)"
diff -r 97b82c75d911 -r 1a6993d5f78e usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Tue Oct 20 20:36:06 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Tue Oct 20 20:36:53 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.168 2020/10/18 22:55:52 sjg Exp $
+# $NetBSD: Makefile,v 1.169 2020/10/20 20:36:53 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -249,9 +249,14 @@
 TESTS+=                shell-custom
 TESTS+=                shell-ksh
 TESTS+=                shell-sh
-TESTS+=                # suffixes      # runs into an endless loop (try -dA)
+TESTS+=                suff-add-later
+TESTS+=                suff-clear-regular
+TESTS+=                suff-clear-single
 TESTS+=                suff-main
 TESTS+=                suff-rebuild
+TESTS+=                suff-transform-endless
+TESTS+=                suff-transform-expand
+TESTS+=                suff-transform-select
 TESTS+=                sunshcmd
 TESTS+=                sysv
 TESTS+=                ternary
diff -r 97b82c75d911 -r 1a6993d5f78e usr.bin/make/unit-tests/suff-add-later.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-add-later.exp        Tue Oct 20 20:36:53 2020 +0000
@@ -0,0 +1,9 @@
+: 'Making issue5a.c out of nothing.'
+make: don't know how to make issue5a.d (continuing)
+make: don't know how to make issue5b.c (continuing)
+make: don't know how to make issue5c (continuing)
+: 'Making issue5d.d out of nothing.'
+make: don't know how to make issue5d.e (continuing)
+make: don't know how to make issue5e.d (continuing)
+`all' not remade because of errors.
+exit status 0
diff -r 97b82c75d911 -r 1a6993d5f78e usr.bin/make/unit-tests/suff-add-later.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-add-later.mk Tue Oct 20 20:36:53 2020 +0000
@@ -0,0 +1,31 @@
+# $NetBSD: suff-add-later.mk,v 1.1 2020/10/20 20:36:53 rillig Exp $
+#
+# https://gnats.netbsd.org/49086, issue 5:
+# Adding more suffixes does not turn existing rules into suffix rules.
+
+all: issue5a.d issue5b.c issue5c issue5d.e issue5e.d
+
+.SUFFIXES: .c
+
+# At this point, only .c is a suffix, therefore the following are all regular
+# rules.
+.c.d .d.c .d .d.e .e.d:
+       : 'Making ${.TARGET} from ${.IMPSRC}.'
+
+# Adding .d and .e as suffixes should turn the above regular rules into
+# suffix rules.
+.SUFFIXES: .d .e
+
+issue5a.c issue5b.d issue5c.d issue5d.d issue5e.e:
+       : 'Making ${.TARGET} out of nothing.'
+
+# XXX: As of 2020-10-20, the result is unexpected.
+# XXX: .d.c is not a transformation rule but a regular target.
+# XXX: .d is not a transformation rule but a regular target.
+# XXX: .e.d is not a transformation but a regular target.
+# XXX: .c.d is listed as "Files that are only sources".
+# XXX: .d.e is listed as "Files that are only sources".
+# XXX: The suffixes .c and .e both have the number 2.
+# XXX: don't know how to make issue5a.d (even though .c.d is a transformation
+# rule and issue5a.c can be readily made)
+#.MAKEFLAGS: -dg1
diff -r 97b82c75d911 -r 1a6993d5f78e usr.bin/make/unit-tests/suff-clear-regular.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-clear-regular.exp    Tue Oct 20 20:36:53 2020 +0000
@@ -0,0 +1,5 @@
+make: don't know how to make .a (continuing)
+make: don't know how to make .a.b (continuing)
+make: don't know how to make .b.a (continuing)
+`all' not remade because of errors.
+exit status 0
diff -r 97b82c75d911 -r 1a6993d5f78e usr.bin/make/unit-tests/suff-clear-regular.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-clear-regular.mk     Tue Oct 20 20:36:53 2020 +0000
@@ -0,0 +1,31 @@
+# $NetBSD: suff-clear-regular.mk,v 1.1 2020/10/20 20:36:53 rillig Exp $
+#
+# https://gnats.netbsd.org/49086, issue 4:
+# Suffix rules do not become regular rules when .SUFFIXES is cleared.
+
+all: .a .a.b .b.a
+
+.SUFFIXES: .a .b .c
+
+# At this point, .a and .b are known suffixes, therefore the following
+# targets are interpreted as transformation rules.
+.a .a.b .b.a:
+       : 'Making ${.TARGET} from ${.IMPSRC}.'
+
+# The empty .SUFFIXES discards all previous suffixes.
+# This means the above rules should be turned into regular targets.
+.SUFFIXES:
+
+# XXX: As of 2020-10-20, the result is unexpected.
+# XXX: .a.b is still a transformation rule.
+# XXX: .a belongs to "Files that are only sources".
+# XXX: .a.b belongs to "Files that are only sources".
+# XXX: .b.a belongs to "Files that are only sources".
+# XXX: .a is listed in "Transformations".
+# XXX: .a.b is listed in "Transformations".
+# XXX: .b.a is listed in "Transformations".
+# XXX: don't know how to make .a
+# XXX: don't know how to make .a.b
+# XXX: don't know how to make .b.a
+# XXX: exit status 0
+#.MAKEFLAGS: -dg1
diff -r 97b82c75d911 -r 1a6993d5f78e usr.bin/make/unit-tests/suff-clear-single.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-clear-single.exp     Tue Oct 20 20:36:53 2020 +0000
@@ -0,0 +1,3 @@
+make: don't know how to make issue3 (continuing)
+`all' not remade because of errors.
+exit status 0
diff -r 97b82c75d911 -r 1a6993d5f78e usr.bin/make/unit-tests/suff-clear-single.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-clear-single.mk      Tue Oct 20 20:36:53 2020 +0000
@@ -0,0 +1,19 @@
+# $NetBSD: suff-clear-single.mk,v 1.1 2020/10/20 20:36:53 rillig Exp $
+#
+# https://gnats.netbsd.org/49086, issue 3:
+# Single suffix rules remain active after .SUFFIXES is cleared.
+#
+# There's a rule for issue3.a, but .a is no longer a known suffix when
+# targets are being made, so issue3 should not get made.
+
+all: issue3
+
+.SUFFIXES: .a .b .c
+
+.a .a.b .b.a:
+       : 'Making ${.TARGET} from ${.IMPSRC}.'
+
+.SUFFIXES:
+
+issue3.a:
+       : 'There is a bug if you see this.'
diff -r 97b82c75d911 -r 1a6993d5f78e usr.bin/make/unit-tests/suff-transform-endless.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-transform-endless.exp        Tue Oct 20 20:36:53 2020 +0000
@@ -0,0 +1,4 @@
+make: "suff-transform-endless.mk" line 36: prevent endless loop
+
+make: stopped in unit-tests
+exit status 1
diff -r 97b82c75d911 -r 1a6993d5f78e usr.bin/make/unit-tests/suff-transform-endless.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-transform-endless.mk Tue Oct 20 20:36:53 2020 +0000
@@ -0,0 +1,36 @@
+# $NetBSD: suff-transform-endless.mk,v 1.1 2020/10/20 20:36:53 rillig Exp $
+
+# https://gnats.netbsd.org/49086, issue 6:
+# Transformation search can end up in an infinite loop.
+#
+# There is no file or target from which issue6.f could be made, so
+# this should fail.  The bug is that because rules .e.f, .d.e and .e.d
+# exist, make would try to make .f from .e and then infinitely try
+# to do .e from .d and vice versa.
+
+all: issue6.f
+
+.c.d .d.c .d .d.e .e.d:
+       : 'Making ${.TARGET} from ${.IMPSRC}.'
+
+.SUFFIXES: .c .d .e .f
+
+.e .e.f .f.e:
+       : 'Making ${.TARGET} out of nothing.'
+
+# XXX: As of 2020-10-20, the result is unexpected.
+# XXX: .d.c is not a transformation rule.
+# XXX: .d is not a transformation rule.
+# XXX: .e.d is not a transformation rule.
+# XXX: .c.d is listed as "Files that are only sources".
+# XXX: .d.e is listed as "Files that are only sources".
+# XXX: The suffixes .d and .f both have the number 3.
+# XXX: .c.d is not listed as "Transformations".
+# XXX: .d.c is not listed as "Transformations".
+# XXX: .d is not listed as "Transformations".
+# XXX: .d.e is not listed as "Transformations".
+# XXX: .e.d is not listed as "Transformations".
+# XXX: Found 'all' as '(not found)'
+# XXX: trying all.e, all.e, all.f, all.e, all.e, repeatedly.
+#.MAKEFLAGS: -dg1
+.error prevent endless loop
diff -r 97b82c75d911 -r 1a6993d5f78e usr.bin/make/unit-tests/suff-transform-expand.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-transform-expand.exp Tue Oct 20 20:36:53 2020 +0000
@@ -0,0 +1,5 @@
+: 'Making issue11.h out of nothing.'
+make: don't know how to make .first (continuing)
+: 'Making issue11.second out of nothing.'
+`all' not remade because of errors.
+exit status 0
diff -r 97b82c75d911 -r 1a6993d5f78e usr.bin/make/unit-tests/suff-transform-expand.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-transform-expand.mk  Tue Oct 20 20:36:53 2020 +0000
@@ -0,0 +1,25 @@
+# $NetBSD: suff-transform-expand.mk,v 1.1 2020/10/20 20:36:53 rillig Exp $
+#
+# https://gnats.netbsd.org/49086, issue 11:
+# Sources from transformation rules are expanded incorrectly.
+#
+# issue11.j should depend on issue11.i and issue11.second.
+# issue11.i should depend on issue11.h and issue11.first.
+#
+# XXX: The dynamic sources are expanded before ${.PREFIX} and
+# ${.TARGET} were available, so they expand to an empty string.
+
+all: issue11.j
+
+.SUFFIXES: .h .i .j
+
+.h.i: ${.PREFIX}.first
+       : 'Making ${.TARGET} from ${.IMPSRC} all ${.ALLSRC}.'
+
+.i.j: ${.PREFIX}.second
+       : 'Making ${.TARGET} from ${.IMPSRC} all ${.ALLSRC}.'
+
+issue11.h issue11.first issue11.second:
+       : 'Making ${.TARGET} out of nothing.'
+
+#.MAKEFLAGS: -dg1
diff -r 97b82c75d911 -r 1a6993d5f78e usr.bin/make/unit-tests/suff-transform-select.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-transform-select.exp Tue Oct 20 20:36:53 2020 +0000
@@ -0,0 +1,4 @@
+make: "suff-transform-select.mk" line 28: prevent endless loop
+
+make: stopped in unit-tests
+exit status 1
diff -r 97b82c75d911 -r 1a6993d5f78e usr.bin/make/unit-tests/suff-transform-select.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-transform-select.mk  Tue Oct 20 20:36:53 2020 +0000
@@ -0,0 +1,28 @@
+# $NetBSD: suff-transform-select.mk,v 1.1 2020/10/20 20:36:53 rillig Exp $



Home | Main Index | Thread Index | Old Index