Sat May 16 19:02:32 2020 UTC ()
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


(rillig)
diff -r1.92 -r1.93 pkgsrc/mk/subst.mk
diff -r1.41 -r1.42 pkgsrc/regress/infra-unittests/subst.sh

cvs diff -r1.92 -r1.93 pkgsrc/mk/subst.mk (expand / switch to unified diff)

--- pkgsrc/mk/subst.mk 2020/05/02 05:52:09 1.92
+++ pkgsrc/mk/subst.mk 2020/05/16 19:02:32 1.93
@@ -1,54 +1,49 @@ @@ -1,54 +1,49 @@
1# $NetBSD: subst.mk,v 1.92 2020/05/02 05:52:09 rillig Exp $ 1# $NetBSD: subst.mk,v 1.93 2020/05/16 19:02:32 rillig Exp $
2# 2#
3# The subst framework replaces text in one or more files in the WRKSRC 3# The subst framework replaces text in one or more files in the WRKSRC
4# directory. Packages can define several ``classes'' of replacements. 4# directory. Packages can define several ``classes'' of replacements.
5# Each such class defines: 5# Each such class defines:
6# 6#
7# - in which stage of the build process the replacement happens 7# - in which stage of the build process the replacement happens
8# - which files are affected by the replacement 8# - which files are affected by the replacement
9# - which text or pattern is replaced by which replacement text 9# - which text or pattern is replaced by which replacement text
10# 10#
11# A typical example is: 11# A typical example is:
12# 12#
13# SUBST_CLASSES+= prefix 13# SUBST_CLASSES+= prefix
14# SUBST_STAGE.prefix= pre-configure 14# SUBST_STAGE.prefix= pre-configure
15# SUBST_FILES.prefix= ./configure doc/*.html 15# SUBST_FILES.prefix= ./configure doc/*.html
16# SUBST_SED.prefix= -e 's,/usr/local,${PREFIX},g' 16# SUBST_SED.prefix= -e 's,/usr/local,${PREFIX},g'
17# 17#
18# User-settable variables: 18# User-settable variables:
19# 19#
20# SUBST_SHOW_DIFF 20# SUBST_SHOW_DIFF
21# Whether to log each changed file as a unified diff, for all 21# Whether to log each changed file as a unified diff, for all
22# SUBST classes. Defaults to "no". 22# SUBST classes. Defaults to "no".
23# 23#
24# SUBST_NOOP_OK 24# SUBST_NOOP_OK
25# Whether it is ok to list files in SUBST_FILES that don't contain 25# Whether it is ok to have patterns in SUBST_FILES that don't
26# any of the patterns from SUBST_SED or SUBST_VARS. Such a 26# contain any of the patterns from SUBST_SED or SUBST_VARS and
27# situation often arises when a package is updated to a newer 27# thus are not modified at all.
28# version, and the build instructions of the package have been 28#
29# made more portable or flexible. 29# This setting only detects redundant filename patterns. It does
30# 30# not detect redundant patterns in SUBST_SED.
31# This setting only affects the filename patterns in SUBST_FILES. 31#
32# It does not (yet) affect the regular expressions in SUBST_SED. 32# Identity substitutions like s|man|man| do not count as no-ops
33# 33# since their replacement part usually comes from a variable, such
34# From the viewpoint of sed(1), a pattern like s|man|man| may look 34# as PKGMANDIR.
35# redundant but it really isn't, because the second "man" probably 
36# comes from ${PKGMANDIR}, which may be configured to a different 
37# directory. Patterns like these are therefore allowed, even if 
38# they are no-ops in the current configuration. 
39# 35#
40# For backwards compatibility this defaults to "yes", but it 36# Defaults to no. Will be removed after 2020Q3.
41# should rather be set to "no". 
42# 37#
43# Package-settable variables: 38# Package-settable variables:
44# 39#
45# SUBST_CLASSES 40# SUBST_CLASSES
46# A list of class names. When adding new classes to this list, be 41# A list of class names. When adding new classes to this list, be
47# sure to append them (+=) instead of overriding them (=). 42# sure to append them (+=) instead of overriding them (=).
48# 43#
49# SUBST_STAGE.<class> 44# SUBST_STAGE.<class>
50# "stage" at which we do the text replacement. Should be one of 45# "stage" at which we do the text replacement. Should be one of
51# {pre,do,post}-{extract,configure,build,install}. 46# {pre,do,post}-{extract,configure,build,install}.
52# 47#
53# SUBST_MESSAGE.<class> 48# SUBST_MESSAGE.<class>
54# The message to display before doing the substitution. 49# The message to display before doing the substitution.
@@ -83,40 +78,48 @@ @@ -83,40 +78,48 @@
83# Filter used to perform the actual substitution on the specified 78# Filter used to perform the actual substitution on the specified
84# files. Defaults to ${SED} ${SUBST_SED.<class>}. 79# files. Defaults to ${SED} ${SUBST_SED.<class>}.
85# 80#
86# SUBST_SKIP_TEXT_CHECK.<class> 81# SUBST_SKIP_TEXT_CHECK.<class>
87# By default, each file is checked whether it really is a text file 82# By default, each file is checked whether it really is a text file
88# before any substitutions are done to it. Since that test is not 83# before any substitutions are done to it. Since that test is not
89# perfect, it can be disabled by setting this variable to "yes". 84# perfect, it can be disabled by setting this variable to "yes".
90# 85#
91# SUBST_SHOW_DIFF.<class> 86# SUBST_SHOW_DIFF.<class>
92# During development of a package, this can be set to "yes" to see 87# During development of a package, this can be set to "yes" to see
93# the actual changes as a unified diff. 88# the actual changes as a unified diff.
94# 89#
95# SUBST_NOOP_OK.<class> 90# SUBST_NOOP_OK.<class>
96# Whether to fail when a SUBST_FILES pattern has no effect. 91# Whether to allow filename patterns in SUBST_FILES that don't
97# In most cases, "yes" is appropriate, to catch typos and outdated 92# contain any of the patterns from SUBST_SED.
98# definitions. 
99# 93#
100# Default: no (up to 2019Q4), yes (starting with 2020Q1) 94# Defaults to no, since May 2020.
 95#
 96# Typical reasons to change this to yes are:
 97#
 98# 1. SUBST_FILES is generated dynamically and may include
 99# unaffected files.
 100#
 101# 2. There are multiple SUBST_SED patterns, and some of these
 102# do not count as identity substitution since they contain
 103# ".*" or similar parts.
101# 104#
102# See also: 105# See also:
103# PLIST_SUBST 106# PLIST_SUBST
104# 107#
105# Keywords: subst 108# Keywords: subst
106# 109#
107 110
108SUBST_SHOW_DIFF?= no 111SUBST_SHOW_DIFF?= no
109SUBST_NOOP_OK?= yes # only for backwards compatibility 112SUBST_NOOP_OK?= no # since May 2020
110 113
111_VARGROUPS+= subst 114_VARGROUPS+= subst
112_USER_VARS.subst= SUBST_SHOW_DIFF SUBST_NOOP_OK 115_USER_VARS.subst= SUBST_SHOW_DIFF SUBST_NOOP_OK
113_PKG_VARS.subst= SUBST_CLASSES 116_PKG_VARS.subst= SUBST_CLASSES
114.for c in ${SUBST_CLASSES} 117.for c in ${SUBST_CLASSES}
115. for pv in SUBST_STAGE SUBST_MESSAGE SUBST_FILES SUBST_SED SUBST_VARS \ 118. for pv in SUBST_STAGE SUBST_MESSAGE SUBST_FILES SUBST_SED SUBST_VARS \
116 SUBST_FILTER_CMD SUBST_SKIP_TEXT_CHECK SUBST_NOOP_OK 119 SUBST_FILTER_CMD SUBST_SKIP_TEXT_CHECK SUBST_NOOP_OK
117_PKG_VARS.subst+= ${pv}.${c} 120_PKG_VARS.subst+= ${pv}.${c}
118. endfor 121. endfor
119.endfor 122.endfor
120_DEF_VARS.subst= ECHO_SUBST_MSG 123_DEF_VARS.subst= ECHO_SUBST_MSG
121_USE_VARS.subst= WRKDIR WRKSRC 124_USE_VARS.subst= WRKDIR WRKSRC
122_IGN_VARS.subst= _SUBST_IS_TEXT_FILE_CMD 125_IGN_VARS.subst= _SUBST_IS_TEXT_FILE_CMD

cvs diff -r1.41 -r1.42 pkgsrc/regress/infra-unittests/subst.sh (expand / switch to unified diff)

--- pkgsrc/regress/infra-unittests/subst.sh 2020/05/16 12:43:10 1.41
+++ pkgsrc/regress/infra-unittests/subst.sh 2020/05/16 19:02:32 1.42
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1#! /bin/sh 1#! /bin/sh
2# $NetBSD: subst.sh,v 1.41 2020/05/16 12:43:10 rillig Exp $ 2# $NetBSD: subst.sh,v 1.42 2020/05/16 19:02:32 rillig Exp $
3# 3#
4# Tests for mk/subst.mk. 4# Tests for mk/subst.mk.
5# 5#
6 6
7set -eu 7set -eu
8 8
9. './test.subr' 9. './test.subr'
10 10
11test_case_set_up() { 11test_case_set_up() {
12 wrkdir="$tmpdir/wrkdir" 12 wrkdir="$tmpdir/wrkdir"
13 mkdir "$wrkdir" 13 mkdir "$wrkdir"
14 14
15 create_file 'prepare-subst.mk' <<-EOF 15 create_file 'prepare-subst.mk' <<-EOF
@@ -131,65 +131,106 @@ if test_case_begin 'several files by pat @@ -131,65 +131,106 @@ if test_case_begin 'several files by pat
131 run_bmake 'testcase.mk' 'subst-class' 1> "$tmpdir/output" 2>&1 \ 131 run_bmake 'testcase.mk' 'subst-class' 1> "$tmpdir/output" 2>&1 \
132 && exitcode=0 || exitcode=$? 132 && exitcode=0 || exitcode=$?
133 133
134 assert_that "$tmpdir/output" --file-is-lines \ 134 assert_that "$tmpdir/output" --file-is-lines \
135 '=> Substituting "class" in pattern-*' 135 '=> Substituting "class" in pattern-*'
136 assert_that 'pattern-first' --file-is-lines 'the first example' 136 assert_that 'pattern-first' --file-is-lines 'the first example'
137 assert_that 'pattern-second' --file-is-lines 'the second example' 137 assert_that 'pattern-second' --file-is-lines 'the second example'
138 assert_that 'pattern-third' --file-is-lines 'the third example' 138 assert_that 'pattern-third' --file-is-lines 'the third example'
139 139
140 test_case_end 140 test_case_end
141fi 141fi
142 142
143 143
144if test_case_begin 'pattern with 1 noop'; then 144if test_case_begin 'pattern with 1 noop, no-op ok'; then
145 145
146 # Several files are given via a pattern. 146 # Several files are given via a pattern.
147 # Most of the files are patched, but one stays the same. 147 # Most of the files are patched, but one stays the same.
148 # Since it is easier to give a too broad pattern like *.py 148 # Since it is easier to give a too broad pattern like *.py
149 # than to exclude a few files from such a pattern, 149 # than to exclude a few files from such a pattern,
150 # only an info is logged. 150 # only an info is logged.
151 # This is not an error. 151 # This is not an error.
152 152
153 create_file 'testcase.mk' <<-EOF 153 create_file 'testcase.mk' <<-EOF
154 SUBST_CLASSES+= class 154 SUBST_CLASSES+= class
155 SUBST_STAGE.class= pre-configure 155 SUBST_STAGE.class= pre-configure
156 SUBST_FILES.class= pattern-* 156 SUBST_FILES.class= pattern-*
157 SUBST_SED.class= -e 's,file,example,' 157 SUBST_SED.class= -e 's,file,example,'
 158 SUBST_NOOP_OK.class= yes
158 159
159 .include "prepare-subst.mk" 160 .include "prepare-subst.mk"
160 .include "mk/subst.mk" 161 .include "mk/subst.mk"
161 162
162 all: subst-class 163 all: subst-class
163 EOF 164 EOF
164 165
165 create_file_lines 'pattern-first' 'the first file' 166 create_file_lines 'pattern-first' 'the first file'
166 create_file_lines 'pattern-second' 'the second is already an example' 167 create_file_lines 'pattern-second' 'the second is already an example'
167 create_file_lines 'pattern-third' 'the third file' 168 create_file_lines 'pattern-third' 'the third file'
168 169
169 run_bmake 'testcase.mk' 1> "$tmpdir/output" \ 170 run_bmake 'testcase.mk' 1> "$tmpdir/output" 2>&1 \
170 && exitcode=0 || exitcode=$? 171 && exitcode=0 || exitcode=$?
171 172
172 assert_that "$tmpdir/output" --file-is-lines \ 173 assert_that "$tmpdir/output" --file-is-lines \
173 '=> Substituting "class" in pattern-*' \ 174 '=> Substituting "class" in pattern-*' \
174 'info: [subst.mk:class] Nothing changed in "pattern-second".' 175 'info: [subst.mk:class] Nothing changed in "pattern-second".'
175 assert_that 'pattern-first' --file-is-lines 'the first example' 176 assert_that 'pattern-first' --file-is-lines 'the first example'
176 assert_that 'pattern-second' --file-is-lines 'the second is already an example' 177 assert_that 'pattern-second' --file-is-lines 'the second is already an example'
177 assert_that 'pattern-third' --file-is-lines 'the third example' 178 assert_that 'pattern-third' --file-is-lines 'the third example'
178 179
179 test_case_end 180 test_case_end
180fi 181fi
181 182
182 183
 184if test_case_begin 'pattern with 1 noop, no-op not ok'; then
 185
 186 # Several files are given via a pattern.
 187 # Most of the files are patched, but one stays the same.
 188 # Since it is easier to give a too broad pattern like *.py
 189 # than to exclude a few files from such a pattern,
 190 # only a warning is logged.
 191 # This is not an error.
 192
 193 create_file 'testcase.mk' <<-EOF
 194 SUBST_CLASSES+= class
 195 SUBST_STAGE.class= pre-configure
 196 SUBST_FILES.class= pattern-*
 197 SUBST_SED.class= -e 's,file,example,'
 198 SUBST_NOOP_OK.class= no
 199
 200 .include "prepare-subst.mk"
 201 .include "mk/subst.mk"
 202
 203 all: subst-class
 204 EOF
 205
 206 create_file_lines 'pattern-first' 'the first file'
 207 create_file_lines 'pattern-second' 'the second is already an example'
 208 create_file_lines 'pattern-third' 'the third file'
 209
 210 run_bmake 'testcase.mk' 1> "$tmpdir/output" 2>&1 \
 211 && exitcode=0 || exitcode=$?
 212
 213 assert_that "$tmpdir/output" --file-is-lines \
 214 '=> Substituting "class" in pattern-*' \
 215 'warning: [subst.mk:class] Nothing changed in "pattern-second".'
 216 assert_that 'pattern-first' --file-is-lines 'the first example'
 217 assert_that 'pattern-second' --file-is-lines 'the second is already an example'
 218 assert_that 'pattern-third' --file-is-lines 'the third example'
 219
 220 test_case_end
 221fi
 222
 223
183if test_case_begin 'single file noop, noop_ok=yes'; then 224if test_case_begin 'single file noop, noop_ok=yes'; then
184 225
185 create_file 'testcase.mk' <<-EOF 226 create_file 'testcase.mk' <<-EOF
186 SUBST_CLASSES+= class 227 SUBST_CLASSES+= class
187 SUBST_STAGE.class= pre-configure 228 SUBST_STAGE.class= pre-configure
188 SUBST_FILES.class= single 229 SUBST_FILES.class= single
189 SUBST_SED.class= -e 's,file,example,' 230 SUBST_SED.class= -e 's,file,example,'
190 SUBST_NOOP_OK.class= yes 231 SUBST_NOOP_OK.class= yes
191 232
192 .include "prepare-subst.mk" 233 .include "prepare-subst.mk"
193 .include "mk/subst.mk" 234 .include "mk/subst.mk"
194 EOF 235 EOF
195 236
@@ -285,95 +326,198 @@ if test_case_begin 'single file nonexist @@ -285,95 +326,198 @@ if test_case_begin 'single file nonexist
285 326
286 run_bmake 'testcase.mk' 'subst-class' 1> "$tmpdir/output" 2>&1 \ 327 run_bmake 'testcase.mk' 'subst-class' 1> "$tmpdir/output" 2>&1 \
287 && exitcode=0 || exitcode=$? 328 && exitcode=0 || exitcode=$?
288 329
289 assert_that "$tmpdir/output" --file-is-lines \ 330 assert_that "$tmpdir/output" --file-is-lines \
290 '=> Substituting "class" in nonexistent' \ 331 '=> Substituting "class" in nonexistent' \
291 'info: [subst.mk:class] Ignoring nonexistent file "nonexistent".' 332 'info: [subst.mk:class] Ignoring nonexistent file "nonexistent".'
292 assert_that "$exitcode" --equals '0' 333 assert_that "$exitcode" --equals '0'
293 334
294 test_case_end 335 test_case_end
295fi 336fi
296 337
297 338
298if test_case_begin 'several patterns, 1 nonexistent'; then 339if test_case_begin 'several filename patterns, 1 nonexistent, no-op ok'; then
299 340
300 create_file 'testcase.mk' <<-EOF 341 create_file 'testcase.mk' <<-EOF
301 SUBST_CLASSES+= class 342 SUBST_CLASSES+= class
302 SUBST_STAGE.class= pre-configure 343 SUBST_STAGE.class= pre-configure
303 SUBST_FILES.class= *exist* *not-found* 344 SUBST_FILES.class= *exist* *not-found*
304 SUBST_SED.class= -e 's,file,example,' 345 SUBST_SED.class= -e 's,file,example,'
 346 SUBST_NOOP_OK.class= yes
305 347
306 .include "prepare-subst.mk" 348 .include "prepare-subst.mk"
307 .include "mk/subst.mk" 349 .include "mk/subst.mk"
308 EOF 350 EOF
309 351
310 create_file_lines 'exists' 'this file exists' 352 create_file_lines 'exists' 'this file exists'
311 353
312 run_bmake 'testcase.mk' 'subst-class' 1> "$tmpdir/output" 2>&1 \ 354 run_bmake 'testcase.mk' 'subst-class' 1> "$tmpdir/output" 2>&1 \
313 && exitcode=0 || exitcode=$? 355 && exitcode=0 || exitcode=$?
314 356
315 assert_that "$tmpdir/output" --file-is-lines \ 357 assert_that "$tmpdir/output" --file-is-lines \
316 '=> Substituting "class" in *exist* *not-found*' \ 358 '=> Substituting "class" in *exist* *not-found*' \
317 'info: [subst.mk:class] Ignoring nonexistent file "./*not-found*".' 359 'info: [subst.mk:class] Ignoring nonexistent file "./*not-found*".'
318 assert_that 'exists' --file-is-lines 'this example exists' 360 assert_that 'exists' --file-is-lines 'this example exists'
319 assert_that "$exitcode" --equals '0' 361 assert_that "$exitcode" --equals '0'
320 362
321 test_case_end 363 test_case_end
322fi 364fi
323 365
324 366
325if test_case_begin 'multiple missing files, all are reported at once'; then 367if test_case_begin 'several filename patterns, 1 nonexistent, no-op not ok'; then
 368
 369 create_file 'testcase.mk' <<-EOF
 370 SUBST_CLASSES+= class
 371 SUBST_STAGE.class= pre-configure
 372 SUBST_FILES.class= *exist* *not-found*
 373 SUBST_SED.class= -e 's,file,example,'
 374 SUBST_NOOP_OK.class= no
 375
 376 .include "prepare-subst.mk"
 377 .include "mk/subst.mk"
 378 EOF
 379
 380 create_file_lines 'exists' 'this file exists'
 381
 382 run_bmake 'testcase.mk' 'subst-class' 1> "$tmpdir/output" 2>&1 \
 383 && exitcode=0 || exitcode=$?
 384
 385 assert_that "$tmpdir/output" --file-is-lines \
 386 '=> Substituting "class" in *exist* *not-found*' \
 387 'warning: [subst.mk:class] Ignoring nonexistent file "./*not-found*".' \
 388 'fail: [subst.mk:class] The filename pattern "*not-found*" has no effect.' \
 389 '*** Error code 1' \
 390 '' \
 391 'Stop.' \
 392 "$make: stopped in $PWD"
 393 assert_that 'exists' --file-is-lines 'this example exists'
 394 assert_that "$exitcode" --equals '1'
 395
 396 test_case_end
 397fi
 398
 399
 400if test_case_begin 'multiple missing files, all are reported at once, no-op not ok'; then
 401
 402 create_file 'testcase.mk' <<-EOF
 403 SUBST_CLASSES+= class
 404 SUBST_STAGE.class= pre-configure
 405 SUBST_FILES.class= does not exist
 406 SUBST_SED.class= -e 'sahara'
 407 SUBST_NOOP_OK.class= no
 408
 409 .include "prepare-subst.mk"
 410 .include "mk/subst.mk"
 411 EOF
 412
 413 run_bmake 'testcase.mk' 1> "$tmpdir/output" 2>&1 \
 414 && exitcode=0 || exitcode=$?
 415
 416 assert_that "$tmpdir/output" --file-is-lines \
 417 '=> Substituting "class" in does not exist' \
 418 'warning: [subst.mk:class] Ignoring nonexistent file "does".' \
 419 'warning: [subst.mk:class] Ignoring nonexistent file "not".' \
 420 'warning: [subst.mk:class] Ignoring nonexistent file "exist".' \
 421 'fail: [subst.mk:class] The filename patterns "does not exist" have no effect.' \
 422 '*** Error code 1' \
 423 '' \
 424 'Stop.' \
 425 "$make: stopped in $PWD"
 426 assert_that "$exitcode" --equals '1'
 427
 428 test_case_end
 429fi
 430
 431
 432if test_case_begin 'multiple missing files, all are reported at once, no-op ok'; then
326 433
327 create_file 'testcase.mk' <<-EOF 434 create_file 'testcase.mk' <<-EOF
328 SUBST_CLASSES+= class 435 SUBST_CLASSES+= class
329 SUBST_STAGE.class= pre-configure 436 SUBST_STAGE.class= pre-configure
330 SUBST_FILES.class= does not exist 437 SUBST_FILES.class= does not exist
331 SUBST_SED.class= -e 'sahara' 438 SUBST_SED.class= -e 'sahara'
 439 SUBST_NOOP_OK.class= yes
332 440
333 .include "prepare-subst.mk" 441 .include "prepare-subst.mk"
334 .include "mk/subst.mk" 442 .include "mk/subst.mk"
335 EOF 443 EOF
336 444
337 run_bmake 'testcase.mk' > "$tmpdir/output" \ 445 run_bmake 'testcase.mk' 1> "$tmpdir/output" 2>&1 \
338 && exitcode=0 || exitcode=$? 446 && exitcode=0 || exitcode=$?
339 447
340 assert_that "$tmpdir/output" --file-is-lines \ 448 assert_that "$tmpdir/output" --file-is-lines \
341 '=> Substituting "class" in does not exist' \ 449 '=> Substituting "class" in does not exist' \
342 'info: [subst.mk:class] Ignoring nonexistent file "does".' \ 450 'info: [subst.mk:class] Ignoring nonexistent file "does".' \
343 'info: [subst.mk:class] Ignoring nonexistent file "not".' \ 451 'info: [subst.mk:class] Ignoring nonexistent file "not".' \
344 'info: [subst.mk:class] Ignoring nonexistent file "exist".' 452 'info: [subst.mk:class] Ignoring nonexistent file "exist".'
345 assert_that "$exitcode" --equals '0' 453 assert_that "$exitcode" --equals '0'
346 454
347 test_case_end 455 test_case_end
348fi 456fi
349 457
350 458
351if test_case_begin 'multiple no-op files, all are reported at once'; then 459if test_case_begin 'multiple no-op files, all are reported at once, no-op not ok'; then
352 460
353 create_file 'testcase.mk' <<-EOF 461 create_file 'testcase.mk' <<-EOF
354 SUBST_CLASSES+= class 462 SUBST_CLASSES+= class
355 SUBST_STAGE.class= pre-configure 463 SUBST_STAGE.class= pre-configure
356 SUBST_FILES.class= first second third 464 SUBST_FILES.class= first second third
357 SUBST_SED.class= -e 's,from,to,' 465 SUBST_SED.class= -e 's,from,to,'
 466 SUBST_NOOP_OK.class= no
 467
 468 .include "prepare-subst.mk"
 469 .include "mk/subst.mk"
 470 EOF
 471 create_file_lines 'first' 'text'
 472 create_file_lines 'second' 'second'
 473 create_file_lines 'third' 'third'
 474
 475 run_bmake 'testcase.mk' 1> "$tmpdir/output" 2>&1 \
 476 && exitcode=0 || exitcode=$?
 477
 478 assert_that "$tmpdir/output" --file-is-lines \
 479 '=> Substituting "class" in first second third' \
 480 'warning: [subst.mk:class] Nothing changed in "first".' \
 481 'warning: [subst.mk:class] Nothing changed in "second".' \
 482 'warning: [subst.mk:class] Nothing changed in "third".' \
 483 'fail: [subst.mk:class] The filename patterns "first second third" have no effect.' \
 484 '*** Error code 1' \
 485 '' \
 486 'Stop.' \
 487 "$make: stopped in $PWD"
 488 assert_that "$exitcode" --equals '1'
 489
 490 test_case_end
 491fi
 492
 493
 494if test_case_begin 'multiple no-op files, all are reported at once, no-op ok'; then
 495
 496 create_file 'testcase.mk' <<-EOF
 497 SUBST_CLASSES+= class
 498 SUBST_STAGE.class= pre-configure
 499 SUBST_FILES.class= first second third
 500 SUBST_SED.class= -e 's,from,to,'
 501 SUBST_NOOP_OK.class= yes
358 502
359 .include "prepare-subst.mk" 503 .include "prepare-subst.mk"
360 .include "mk/subst.mk" 504 .include "mk/subst.mk"
361 EOF 505 EOF
362 create_file_lines 'first' 'text' 506 create_file_lines 'first' 'text'
363 create_file_lines 'second' 'second' 507 create_file_lines 'second' 'second'
364 create_file_lines 'third' 'third' 508 create_file_lines 'third' 'third'
365 509
366 run_bmake 'testcase.mk' > "$tmpdir/output" \ 510 run_bmake 'testcase.mk' 1> "$tmpdir/output" 2>&1 \
367 && exitcode=0 || exitcode=$? 511 && exitcode=0 || exitcode=$?
368 512
369 assert_that "$tmpdir/output" --file-is-lines \ 513 assert_that "$tmpdir/output" --file-is-lines \
370 '=> Substituting "class" in first second third' \ 514 '=> Substituting "class" in first second third' \
371 'info: [subst.mk:class] Nothing changed in "first".' \ 515 'info: [subst.mk:class] Nothing changed in "first".' \
372 'info: [subst.mk:class] Nothing changed in "second".' \ 516 'info: [subst.mk:class] Nothing changed in "second".' \
373 'info: [subst.mk:class] Nothing changed in "third".' 517 'info: [subst.mk:class] Nothing changed in "third".'
374 assert_that "$exitcode" --equals '0' 518 assert_that "$exitcode" --equals '0'
375 519
376 test_case_end 520 test_case_end
377fi 521fi
378 522
379 523
@@ -1431,26 +1575,27 @@ if test_case_begin 'no-op SUBST_FILTER_C @@ -1431,26 +1575,27 @@ if test_case_begin 'no-op SUBST_FILTER_C
1431 assert_that 'file' --file-is-lines \ 1575 assert_that 'file' --file-is-lines \
1432 'only letters' 1576 'only letters'
1433 1577
1434 test_case_end 1578 test_case_end
1435fi 1579fi
1436 1580
1437 1581
1438if test_case_begin 'backtick in SUBST_SED'; then 1582if test_case_begin 'backtick in SUBST_SED'; then
1439 1583
1440 create_file_lines 'testcase.mk' \ 1584 create_file_lines 'testcase.mk' \
1441 'SUBST_CLASSES+= id' \ 1585 'SUBST_CLASSES+= id' \
1442 'SUBST_FILES.id= file' \ 1586 'SUBST_FILES.id= file' \
1443 "SUBST_SED.id= -e 's,\"\\\\\`,\"\\\\\`,'" \ 1587 "SUBST_SED.id= -e 's,\"\\\\\`,\"\\\\\`,'" \
 1588 'SUBST_NOOP_OK.id= yes' \
1444 '' \ 1589 '' \
1445 '.include "prepare-subst.mk"' \ 1590 '.include "prepare-subst.mk"' \
1446 '.include "mk/subst.mk"' 1591 '.include "mk/subst.mk"'
1447 create_file_lines 'file' \ 1592 create_file_lines 'file' \
1448 'from`' 1593 'from`'
1449 1594
1450 run_bmake 'testcase.mk' 'subst-id' 1> "$tmpdir/output" 2>&1 \ 1595 run_bmake 'testcase.mk' 'subst-id' 1> "$tmpdir/output" 2>&1 \
1451 && exitcode=0 || exitcode=$? 1596 && exitcode=0 || exitcode=$?
1452 1597
1453 assert_that "$tmpdir/output" --file-is-lines \ 1598 assert_that "$tmpdir/output" --file-is-lines \
1454 '=> Substituting "id" in file' \ 1599 '=> Substituting "id" in file' \
1455 'info: [subst.mk:id] Nothing changed in "file".' 1600 'info: [subst.mk:id] Nothing changed in "file".'
1456 1601