Module Name: src Committed By: rillig Date: Tue Oct 20 20:36:53 UTC 2020
Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/make: t_make.sh src/usr.bin/make/unit-tests: Makefile Added Files: src/usr.bin/make/unit-tests: suff-add-later.exp suff-add-later.mk suff-clear-regular.exp suff-clear-regular.mk suff-clear-single.exp suff-clear-single.mk suff-transform-endless.exp suff-transform-endless.mk suff-transform-expand.exp suff-transform-expand.mk suff-transform-select.exp suff-transform-select.mk Removed Files: src/usr.bin/make/unit-tests: suffixes.exp suffixes.mk Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.943 -r1.944 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/make/t_make.sh cvs rdiff -u -r1.168 -r1.169 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/suff-add-later.exp \ src/usr.bin/make/unit-tests/suff-add-later.mk \ src/usr.bin/make/unit-tests/suff-clear-regular.exp \ src/usr.bin/make/unit-tests/suff-clear-regular.mk \ src/usr.bin/make/unit-tests/suff-clear-single.exp \ src/usr.bin/make/unit-tests/suff-clear-single.mk \ src/usr.bin/make/unit-tests/suff-transform-endless.exp \ src/usr.bin/make/unit-tests/suff-transform-endless.mk \ src/usr.bin/make/unit-tests/suff-transform-expand.exp \ src/usr.bin/make/unit-tests/suff-transform-expand.mk \ src/usr.bin/make/unit-tests/suff-transform-select.exp \ src/usr.bin/make/unit-tests/suff-transform-select.mk cvs rdiff -u -r1.1 -r0 src/usr.bin/make/unit-tests/suffixes.exp cvs rdiff -u -r1.3 -r0 src/usr.bin/make/unit-tests/suffixes.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.943 src/distrib/sets/lists/tests/mi:1.944 --- src/distrib/sets/lists/tests/mi:1.943 Sun Oct 18 16:33:18 2020 +++ src/distrib/sets/lists/tests/mi Tue Oct 20 20:36:53 2020 @@ -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 Index: src/tests/usr.bin/make/t_make.sh diff -u src/tests/usr.bin/make/t_make.sh:1.11 src/tests/usr.bin/make/t_make.sh:1.12 --- src/tests/usr.bin/make/t_make.sh:1.11 Thu Sep 10 17:40:34 2020 +++ src/tests/usr.bin/make/t_make.sh Tue Oct 20 20:36:53 2020 @@ -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 @@ run_and_check() 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)" Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.168 src/usr.bin/make/unit-tests/Makefile:1.169 --- src/usr.bin/make/unit-tests/Makefile:1.168 Sun Oct 18 22:55:52 2020 +++ src/usr.bin/make/unit-tests/Makefile Tue Oct 20 20:36:53 2020 @@ -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-csh 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 Added files: Index: src/usr.bin/make/unit-tests/suff-add-later.exp diff -u /dev/null src/usr.bin/make/unit-tests/suff-add-later.exp:1.1 --- /dev/null Tue Oct 20 20:36:53 2020 +++ src/usr.bin/make/unit-tests/suff-add-later.exp Tue Oct 20 20:36:53 2020 @@ -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 Index: src/usr.bin/make/unit-tests/suff-add-later.mk diff -u /dev/null src/usr.bin/make/unit-tests/suff-add-later.mk:1.1 --- /dev/null Tue Oct 20 20:36:53 2020 +++ src/usr.bin/make/unit-tests/suff-add-later.mk Tue Oct 20 20:36:53 2020 @@ -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 Index: src/usr.bin/make/unit-tests/suff-clear-regular.exp diff -u /dev/null src/usr.bin/make/unit-tests/suff-clear-regular.exp:1.1 --- /dev/null Tue Oct 20 20:36:53 2020 +++ src/usr.bin/make/unit-tests/suff-clear-regular.exp Tue Oct 20 20:36:53 2020 @@ -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 Index: src/usr.bin/make/unit-tests/suff-clear-regular.mk diff -u /dev/null src/usr.bin/make/unit-tests/suff-clear-regular.mk:1.1 --- /dev/null Tue Oct 20 20:36:53 2020 +++ src/usr.bin/make/unit-tests/suff-clear-regular.mk Tue Oct 20 20:36:53 2020 @@ -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 Index: src/usr.bin/make/unit-tests/suff-clear-single.exp diff -u /dev/null src/usr.bin/make/unit-tests/suff-clear-single.exp:1.1 --- /dev/null Tue Oct 20 20:36:53 2020 +++ src/usr.bin/make/unit-tests/suff-clear-single.exp Tue Oct 20 20:36:53 2020 @@ -0,0 +1,3 @@ +make: don't know how to make issue3 (continuing) +`all' not remade because of errors. +exit status 0 Index: src/usr.bin/make/unit-tests/suff-clear-single.mk diff -u /dev/null src/usr.bin/make/unit-tests/suff-clear-single.mk:1.1 --- /dev/null Tue Oct 20 20:36:53 2020 +++ src/usr.bin/make/unit-tests/suff-clear-single.mk Tue Oct 20 20:36:53 2020 @@ -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.' Index: src/usr.bin/make/unit-tests/suff-transform-endless.exp diff -u /dev/null src/usr.bin/make/unit-tests/suff-transform-endless.exp:1.1 --- /dev/null Tue Oct 20 20:36:53 2020 +++ src/usr.bin/make/unit-tests/suff-transform-endless.exp Tue Oct 20 20:36:53 2020 @@ -0,0 +1,4 @@ +make: "suff-transform-endless.mk" line 36: prevent endless loop + +make: stopped in unit-tests +exit status 1 Index: src/usr.bin/make/unit-tests/suff-transform-endless.mk diff -u /dev/null src/usr.bin/make/unit-tests/suff-transform-endless.mk:1.1 --- /dev/null Tue Oct 20 20:36:53 2020 +++ src/usr.bin/make/unit-tests/suff-transform-endless.mk Tue Oct 20 20:36:53 2020 @@ -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 Index: src/usr.bin/make/unit-tests/suff-transform-expand.exp diff -u /dev/null src/usr.bin/make/unit-tests/suff-transform-expand.exp:1.1 --- /dev/null Tue Oct 20 20:36:53 2020 +++ src/usr.bin/make/unit-tests/suff-transform-expand.exp Tue Oct 20 20:36:53 2020 @@ -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 Index: src/usr.bin/make/unit-tests/suff-transform-expand.mk diff -u /dev/null src/usr.bin/make/unit-tests/suff-transform-expand.mk:1.1 --- /dev/null Tue Oct 20 20:36:53 2020 +++ src/usr.bin/make/unit-tests/suff-transform-expand.mk Tue Oct 20 20:36:53 2020 @@ -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 Index: src/usr.bin/make/unit-tests/suff-transform-select.exp diff -u /dev/null src/usr.bin/make/unit-tests/suff-transform-select.exp:1.1 --- /dev/null Tue Oct 20 20:36:53 2020 +++ src/usr.bin/make/unit-tests/suff-transform-select.exp Tue Oct 20 20:36:53 2020 @@ -0,0 +1,4 @@ +make: "suff-transform-select.mk" line 28: prevent endless loop + +make: stopped in unit-tests +exit status 1 Index: src/usr.bin/make/unit-tests/suff-transform-select.mk diff -u /dev/null src/usr.bin/make/unit-tests/suff-transform-select.mk:1.1 --- /dev/null Tue Oct 20 20:36:53 2020 +++ src/usr.bin/make/unit-tests/suff-transform-select.mk Tue Oct 20 20:36:53 2020 @@ -0,0 +1,28 @@ +# $NetBSD: suff-transform-select.mk,v 1.1 2020/10/20 20:36:53 rillig Exp $ +# +# https://gnats.netbsd.org/49086, issue 10: +# Explicit dependencies affect transformation rule selection. +# +# If issue10.e is wanted and both issue10.d and issue10.f are available, +# make should choose the .d.e rule, because .d is before .f in .SUFFIXES. +# The bug was that if issue10.d had an explicit dependency on issue10.f, +# it would choose .f.e instead. + +_!= rm -f issue10.* + +all: issue10.e + +.c.d .d.c .d .d.e .e.d: + : 'Making ${.TARGET} from ${.IMPSRC} (first set).' + +.SUFFIXES: .c .d .e .f .g + +.e .e.f .f.e: + : 'Making ${.TARGET} from ${.IMPSRC} (second set).' + +issue10.d issue10.f: + : 'Making ${.TARGET} out of nothing.' + +# XXX: see suff-bug-endless, which must be fixed first. +#.MAKEFLAGS: -dg1 +.error prevent endless loop