diff options
author | rillig <rillig@pkgsrc.org> | 2020-05-16 19:02:32 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2020-05-16 19:02:32 +0000 |
commit | f0d0fd758520082f20c18a7a232563883bf3144a (patch) | |
tree | 9d3a34ae1db0a98e96dfedcbc23ef4e600156969 /regress/infra-unittests | |
parent | 202d1cd9ef54503ec2d494cea2408ea2cf232060 (diff) | |
download | pkgsrc-f0d0fd758520082f20c18a7a232563883bf3144a.tar.gz |
mk/subst.mk: change default value for SUBST_NOOP_OK from yes to no
This makes the SUBST blocks stricter than before, to detect outdated or
unnecessary definitions.
Filename patterns that are not affected by any of the SUBST_SED
expressions make the build fail. It is still ok if only some of the
files from a pattern are affected and some aren't.
The latest bulk build shows that most of the build failures are fixed.
The packages that fail in that build are mostly due to other failures,
like missing C headers, wrong PLIST files, unresolved references at link
time. There may be a few packages that still fail because of this, but
these are near the leaves of the dependency tree.
https://mail-index.netbsd.org/pkgsrc-bulk/2020/05/14/msg018919.html
Diffstat (limited to 'regress/infra-unittests')
-rw-r--r-- | regress/infra-unittests/subst.sh | 161 |
1 files changed, 153 insertions, 8 deletions
diff --git a/regress/infra-unittests/subst.sh b/regress/infra-unittests/subst.sh index 8e92aa9e46d..b99fe257cf5 100644 --- a/regress/infra-unittests/subst.sh +++ b/regress/infra-unittests/subst.sh @@ -1,5 +1,5 @@ #! /bin/sh -# $NetBSD: subst.sh,v 1.41 2020/05/16 12:43:10 rillig Exp $ +# $NetBSD: subst.sh,v 1.42 2020/05/16 19:02:32 rillig Exp $ # # Tests for mk/subst.mk. # @@ -141,7 +141,7 @@ if test_case_begin 'several files by pattern'; then fi -if test_case_begin 'pattern with 1 noop'; then +if test_case_begin 'pattern with 1 noop, no-op ok'; then # Several files are given via a pattern. # Most of the files are patched, but one stays the same. @@ -155,6 +155,7 @@ if test_case_begin 'pattern with 1 noop'; then SUBST_STAGE.class= pre-configure SUBST_FILES.class= pattern-* SUBST_SED.class= -e 's,file,example,' + SUBST_NOOP_OK.class= yes .include "prepare-subst.mk" .include "mk/subst.mk" @@ -166,7 +167,7 @@ if test_case_begin 'pattern with 1 noop'; then create_file_lines 'pattern-second' 'the second is already an example' create_file_lines 'pattern-third' 'the third file' - run_bmake 'testcase.mk' 1> "$tmpdir/output" \ + run_bmake 'testcase.mk' 1> "$tmpdir/output" 2>&1 \ && exitcode=0 || exitcode=$? assert_that "$tmpdir/output" --file-is-lines \ @@ -180,6 +181,46 @@ if test_case_begin 'pattern with 1 noop'; then fi +if test_case_begin 'pattern with 1 noop, no-op not ok'; then + + # Several files are given via a pattern. + # Most of the files are patched, but one stays the same. + # Since it is easier to give a too broad pattern like *.py + # than to exclude a few files from such a pattern, + # only a warning is logged. + # This is not an error. + + create_file 'testcase.mk' <<-EOF + SUBST_CLASSES+= class + SUBST_STAGE.class= pre-configure + SUBST_FILES.class= pattern-* + SUBST_SED.class= -e 's,file,example,' + SUBST_NOOP_OK.class= no + + .include "prepare-subst.mk" + .include "mk/subst.mk" + + all: subst-class + EOF + + create_file_lines 'pattern-first' 'the first file' + create_file_lines 'pattern-second' 'the second is already an example' + create_file_lines 'pattern-third' 'the third file' + + run_bmake 'testcase.mk' 1> "$tmpdir/output" 2>&1 \ + && exitcode=0 || exitcode=$? + + assert_that "$tmpdir/output" --file-is-lines \ + '=> Substituting "class" in pattern-*' \ + 'warning: [subst.mk:class] Nothing changed in "pattern-second".' + assert_that 'pattern-first' --file-is-lines 'the first example' + assert_that 'pattern-second' --file-is-lines 'the second is already an example' + assert_that 'pattern-third' --file-is-lines 'the third example' + + test_case_end +fi + + if test_case_begin 'single file noop, noop_ok=yes'; then create_file 'testcase.mk' <<-EOF @@ -295,13 +336,14 @@ if test_case_begin 'single file nonexistent ok'; then fi -if test_case_begin 'several patterns, 1 nonexistent'; then +if test_case_begin 'several filename patterns, 1 nonexistent, no-op ok'; then create_file 'testcase.mk' <<-EOF SUBST_CLASSES+= class SUBST_STAGE.class= pre-configure SUBST_FILES.class= *exist* *not-found* SUBST_SED.class= -e 's,file,example,' + SUBST_NOOP_OK.class= yes .include "prepare-subst.mk" .include "mk/subst.mk" @@ -322,19 +364,85 @@ if test_case_begin 'several patterns, 1 nonexistent'; then fi -if test_case_begin 'multiple missing files, all are reported at once'; then +if test_case_begin 'several filename patterns, 1 nonexistent, no-op not ok'; then + + create_file 'testcase.mk' <<-EOF + SUBST_CLASSES+= class + SUBST_STAGE.class= pre-configure + SUBST_FILES.class= *exist* *not-found* + SUBST_SED.class= -e 's,file,example,' + SUBST_NOOP_OK.class= no + + .include "prepare-subst.mk" + .include "mk/subst.mk" + EOF + + create_file_lines 'exists' 'this file exists' + + run_bmake 'testcase.mk' 'subst-class' 1> "$tmpdir/output" 2>&1 \ + && exitcode=0 || exitcode=$? + + assert_that "$tmpdir/output" --file-is-lines \ + '=> Substituting "class" in *exist* *not-found*' \ + 'warning: [subst.mk:class] Ignoring nonexistent file "./*not-found*".' \ + 'fail: [subst.mk:class] The filename pattern "*not-found*" has no effect.' \ + '*** Error code 1' \ + '' \ + 'Stop.' \ + "$make: stopped in $PWD" + assert_that 'exists' --file-is-lines 'this example exists' + assert_that "$exitcode" --equals '1' + + test_case_end +fi + + +if test_case_begin 'multiple missing files, all are reported at once, no-op not ok'; then + + create_file 'testcase.mk' <<-EOF + SUBST_CLASSES+= class + SUBST_STAGE.class= pre-configure + SUBST_FILES.class= does not exist + SUBST_SED.class= -e 'sahara' + SUBST_NOOP_OK.class= no + + .include "prepare-subst.mk" + .include "mk/subst.mk" + EOF + + run_bmake 'testcase.mk' 1> "$tmpdir/output" 2>&1 \ + && exitcode=0 || exitcode=$? + + assert_that "$tmpdir/output" --file-is-lines \ + '=> Substituting "class" in does not exist' \ + 'warning: [subst.mk:class] Ignoring nonexistent file "does".' \ + 'warning: [subst.mk:class] Ignoring nonexistent file "not".' \ + 'warning: [subst.mk:class] Ignoring nonexistent file "exist".' \ + 'fail: [subst.mk:class] The filename patterns "does not exist" have no effect.' \ + '*** Error code 1' \ + '' \ + 'Stop.' \ + "$make: stopped in $PWD" + assert_that "$exitcode" --equals '1' + + test_case_end +fi + + +if test_case_begin 'multiple missing files, all are reported at once, no-op ok'; then create_file 'testcase.mk' <<-EOF SUBST_CLASSES+= class SUBST_STAGE.class= pre-configure SUBST_FILES.class= does not exist SUBST_SED.class= -e 'sahara' + SUBST_NOOP_OK.class= yes .include "prepare-subst.mk" .include "mk/subst.mk" EOF - run_bmake 'testcase.mk' > "$tmpdir/output" \ + run_bmake 'testcase.mk' 1> "$tmpdir/output" 2>&1 \ && exitcode=0 || exitcode=$? assert_that "$tmpdir/output" --file-is-lines \ @@ -348,13 +456,49 @@ if test_case_begin 'multiple missing files, all are reported at once'; then fi -if test_case_begin 'multiple no-op files, all are reported at once'; then +if test_case_begin 'multiple no-op files, all are reported at once, no-op not ok'; then create_file 'testcase.mk' <<-EOF SUBST_CLASSES+= class SUBST_STAGE.class= pre-configure SUBST_FILES.class= first second third SUBST_SED.class= -e 's,from,to,' + SUBST_NOOP_OK.class= no + + .include "prepare-subst.mk" + .include "mk/subst.mk" + EOF + create_file_lines 'first' 'text' + create_file_lines 'second' 'second' + create_file_lines 'third' 'third' + + run_bmake 'testcase.mk' 1> "$tmpdir/output" 2>&1 \ + && exitcode=0 || exitcode=$? + + assert_that "$tmpdir/output" --file-is-lines \ + '=> Substituting "class" in first second third' \ + 'warning: [subst.mk:class] Nothing changed in "first".' \ + 'warning: [subst.mk:class] Nothing changed in "second".' \ + 'warning: [subst.mk:class] Nothing changed in "third".' \ + 'fail: [subst.mk:class] The filename patterns "first second third" have no effect.' \ + '*** Error code 1' \ + '' \ + 'Stop.' \ + "$make: stopped in $PWD" + assert_that "$exitcode" --equals '1' + + test_case_end +fi + + +if test_case_begin 'multiple no-op files, all are reported at once, no-op ok'; then + + create_file 'testcase.mk' <<-EOF + SUBST_CLASSES+= class + SUBST_STAGE.class= pre-configure + SUBST_FILES.class= first second third + SUBST_SED.class= -e 's,from,to,' + SUBST_NOOP_OK.class= yes .include "prepare-subst.mk" .include "mk/subst.mk" @@ -363,7 +507,7 @@ if test_case_begin 'multiple no-op files, all are reported at once'; then create_file_lines 'second' 'second' create_file_lines 'third' 'third' - run_bmake 'testcase.mk' > "$tmpdir/output" \ + run_bmake 'testcase.mk' 1> "$tmpdir/output" 2>&1 \ && exitcode=0 || exitcode=$? assert_that "$tmpdir/output" --file-is-lines \ @@ -1441,6 +1585,7 @@ if test_case_begin 'backtick in SUBST_SED'; then 'SUBST_CLASSES+= id' \ 'SUBST_FILES.id= file' \ "SUBST_SED.id= -e 's,\"\\\\\`,\"\\\\\`,'" \ + 'SUBST_NOOP_OK.id= yes' \ '' \ '.include "prepare-subst.mk"' \ '.include "mk/subst.mk"' |