Fri May 1 19:53:48 2020 UTC ()
mk/subst.mk: fix typo in diagnostic


(rillig)
diff -r1.90 -r1.91 pkgsrc/mk/subst.mk
diff -r1.28 -r1.29 pkgsrc/regress/infra-unittests/subst.sh

cvs diff -r1.90 -r1.91 pkgsrc/mk/subst.mk (expand / switch to unified diff)

--- pkgsrc/mk/subst.mk 2020/05/01 06:42:32 1.90
+++ pkgsrc/mk/subst.mk 2020/05/01 19:53:48 1.91
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: subst.mk,v 1.90 2020/05/01 06:42:32 rillig Exp $ 1# $NetBSD: subst.mk,v 1.91 2020/05/01 19:53:48 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
@@ -180,27 +180,27 @@ ${_SUBST_COOKIE.${class}}: @@ -180,27 +180,27 @@ ${_SUBST_COOKIE.${class}}:
180 patterns=${SUBST_FILES.${class}:Q}; \ 180 patterns=${SUBST_FILES.${class}:Q}; \
181 set -f; \ 181 set -f; \
182 noop_count=''; \ 182 noop_count=''; \
183 noop_patterns=''; \ 183 noop_patterns=''; \
184 noop_sep=''; \ 184 noop_sep=''; \
185 for pattern in $$patterns; do \ 185 for pattern in $$patterns; do \
186 set +f; \ 186 set +f; \
187 changed=no; \ 187 changed=no; \
188 for file in $$pattern; do \ 188 for file in $$pattern; do \
189 case $$file in ([!A-Za-z0-9/]*) file="./$$file";; esac; \ 189 case $$file in ([!A-Za-z0-9/]*) file="./$$file";; esac; \
190 tmpfile="$$file.subst.sav"; \ 190 tmpfile="$$file.subst.sav"; \
191 [ -d "$$file" ] && continue; \ 191 [ -d "$$file" ] && continue; \
192 [ -f "$$file" ] || { \ 192 [ -f "$$file" ] || { \
193 ${_SUBST_WARN.${class}} "Ignoring non-existent file \"$$file\"."; \ 193 ${_SUBST_WARN.${class}} "Ignoring nonexistent file \"$$file\"."; \
194 continue; \ 194 continue; \
195 }; \ 195 }; \
196 ${_SUBST_IS_TEXT_FILE_CMD.${class}} || { \ 196 ${_SUBST_IS_TEXT_FILE_CMD.${class}} || { \
197 ${_SUBST_WARN.${class}} "Ignoring non-text file \"$$file\"."; \ 197 ${_SUBST_WARN.${class}} "Ignoring non-text file \"$$file\"."; \
198 continue; \ 198 continue; \
199 }; \ 199 }; \
200 ${SUBST_FILTER_CMD.${class}} < "$$file" > "$$tmpfile"; \ 200 ${SUBST_FILTER_CMD.${class}} < "$$file" > "$$tmpfile"; \
201 ${CMP} -s "$$tmpfile" "$$file" && { \ 201 ${CMP} -s "$$tmpfile" "$$file" && { \
202 ${AWK} -f ${PKGSRCDIR}/mk/scripts/subst-identity.awk -- ${SUBST_SED.${class}} \ 202 ${AWK} -f ${PKGSRCDIR}/mk/scripts/subst-identity.awk -- ${SUBST_SED.${class}} \
203 && found=`LC_ALL=C ${SED} -n ${SUBST_SED.${class}:C,^['"]?s.*,&p,:C,[\\`"],\\\\&,g} "$$file"` \ 203 && found=`LC_ALL=C ${SED} -n ${SUBST_SED.${class}:C,^['"]?s.*,&p,:C,[\\`"],\\\\&,g} "$$file"` \
204 && [ -n "$$found" ] && { \ 204 && [ -n "$$found" ] && { \
205 changed=yes; \ 205 changed=yes; \
206 continue; \ 206 continue; \

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

--- pkgsrc/regress/infra-unittests/subst.sh 2020/05/01 06:42:32 1.28
+++ pkgsrc/regress/infra-unittests/subst.sh 2020/05/01 19:53:48 1.29
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1#! /bin/sh 1#! /bin/sh
2# $NetBSD: subst.sh,v 1.28 2020/05/01 06:42:32 rillig Exp $ 2# $NetBSD: subst.sh,v 1.29 2020/05/01 19:53:48 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 rm -rf "$tmpdir"/.??* "$tmpdir"/* 12 rm -rf "$tmpdir"/.??* "$tmpdir"/*
13 13
14 create_file "prepare-subst.mk" <<EOF 14 create_file "prepare-subst.mk" <<EOF
15 15
@@ -248,27 +248,27 @@ SUBST_FILES.class= nonexistent @@ -248,27 +248,27 @@ SUBST_FILES.class= nonexistent
248SUBST_SED.class= -e 's,file,example,' 248SUBST_SED.class= -e 's,file,example,'
249SUBST_NOOP_OK.class= no 249SUBST_NOOP_OK.class= no
250 250
251.include "prepare-subst.mk" 251.include "prepare-subst.mk"
252.include "mk/subst.mk" 252.include "mk/subst.mk"
253 253
254all: subst-class 254all: subst-class
255EOF 255EOF
256 256
257 run_bmake "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$? 257 run_bmake "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$?
258 258
259 create_file_lines "expected-output" \ 259 create_file_lines "expected-output" \
260 '=> Substituting "class" in nonexistent' \ 260 '=> Substituting "class" in nonexistent' \
261 'warning: [subst.mk:class] Ignoring non-existent file "nonexistent".' \ 261 'warning: [subst.mk:class] Ignoring nonexistent file "nonexistent".' \
262 'fail: [subst.mk:class] The filename pattern "nonexistent" has no effect.' \ 262 'fail: [subst.mk:class] The filename pattern "nonexistent" has no effect.' \
263 '*** Error code 1' \ 263 '*** Error code 1' \
264 '' \ 264 '' \
265 'Stop.' \ 265 'Stop.' \
266 "$make: stopped in $PWD" 266 "$make: stopped in $PWD"
267 assert_that "actual-output" --file-equals "expected-output" 267 assert_that "actual-output" --file-equals "expected-output"
268 assert_that "$exitcode" --equals "1" 268 assert_that "$exitcode" --equals "1"
269 269
270 test_case_end 270 test_case_end
271fi 271fi
272 272
273 273
274if test_case_begin "single file nonexistent ok"; then 274if test_case_begin "single file nonexistent ok"; then
@@ -280,27 +280,27 @@ SUBST_FILES.class= nonexistent @@ -280,27 +280,27 @@ SUBST_FILES.class= nonexistent
280SUBST_SED.class= -e 's,file,example,' 280SUBST_SED.class= -e 's,file,example,'
281SUBST_NOOP_OK.class= yes 281SUBST_NOOP_OK.class= yes
282 282
283.include "prepare-subst.mk" 283.include "prepare-subst.mk"
284.include "mk/subst.mk" 284.include "mk/subst.mk"
285 285
286all: subst-class 286all: subst-class
287EOF 287EOF
288 288
289 run_bmake "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$? 289 run_bmake "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$?
290 290
291 create_file_lines "expected-output" \ 291 create_file_lines "expected-output" \
292 '=> Substituting "class" in nonexistent' \ 292 '=> Substituting "class" in nonexistent' \
293 'info: [subst.mk:class] Ignoring non-existent file "nonexistent".' 293 'info: [subst.mk:class] Ignoring nonexistent file "nonexistent".'
294 assert_that "actual-output" --file-equals "expected-output" 294 assert_that "actual-output" --file-equals "expected-output"
295 assert_that "$exitcode" --equals "0" 295 assert_that "$exitcode" --equals "0"
296 296
297 test_case_end 297 test_case_end
298fi 298fi
299 299
300 300
301if test_case_begin "several patterns, 1 nonexistent"; then 301if test_case_begin "several patterns, 1 nonexistent"; then
302 302
303 create_file "testcase.mk" <<EOF 303 create_file "testcase.mk" <<EOF
304SUBST_CLASSES+= class 304SUBST_CLASSES+= class
305SUBST_STAGE.class= pre-configure 305SUBST_STAGE.class= pre-configure
306SUBST_FILES.class= *exist* *not-found* 306SUBST_FILES.class= *exist* *not-found*
@@ -308,54 +308,54 @@ SUBST_SED.class= -e 's,file,example,' @@ -308,54 +308,54 @@ SUBST_SED.class= -e 's,file,example,'
308 308
309.include "prepare-subst.mk" 309.include "prepare-subst.mk"
310.include "mk/subst.mk" 310.include "mk/subst.mk"
311 311
312all: subst-class 312all: subst-class
313EOF 313EOF
314 314
315 create_file_lines "exists" "this file exists" 315 create_file_lines "exists" "this file exists"
316 316
317 run_bmake "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$? 317 run_bmake "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$?
318 318
319 create_file_lines "expected-output" \ 319 create_file_lines "expected-output" \
320 '=> Substituting "class" in *exist* *not-found*' \ 320 '=> Substituting "class" in *exist* *not-found*' \
321 'info: [subst.mk:class] Ignoring non-existent file "./*not-found*".' 321 'info: [subst.mk:class] Ignoring nonexistent file "./*not-found*".'
322 assert_that "actual-output" --file-equals "expected-output" 322 assert_that "actual-output" --file-equals "expected-output"
323 assert_that "exists" --file-contains-exactly "this example exists" 323 assert_that "exists" --file-contains-exactly "this example exists"
324 assert_that "$exitcode" --equals "0" 324 assert_that "$exitcode" --equals "0"
325 325
326 test_case_end 326 test_case_end
327fi 327fi
328 328
329 329
330if test_case_begin "multiple missing files, all are reported at once"; then 330if test_case_begin "multiple missing files, all are reported at once"; then
331 331
332 create_file "testcase.mk" <<EOF 332 create_file "testcase.mk" <<EOF
333SUBST_CLASSES+= class 333SUBST_CLASSES+= class
334SUBST_STAGE.class= pre-configure 334SUBST_STAGE.class= pre-configure
335SUBST_FILES.class= does not exist 335SUBST_FILES.class= does not exist
336SUBST_SED.class= -e 'sahara' 336SUBST_SED.class= -e 'sahara'
337 337
338.include "prepare-subst.mk" 338.include "prepare-subst.mk"
339.include "mk/subst.mk" 339.include "mk/subst.mk"
340EOF 340EOF
341 341
342 run_bmake "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$? 342 run_bmake "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$?
343 343
344 create_file_lines "expected-output" \ 344 create_file_lines "expected-output" \
345 '=> Substituting "class" in does not exist' \ 345 '=> Substituting "class" in does not exist' \
346 'info: [subst.mk:class] Ignoring non-existent file "does".' \ 346 'info: [subst.mk:class] Ignoring nonexistent file "does".' \
347 'info: [subst.mk:class] Ignoring non-existent file "not".' \ 347 'info: [subst.mk:class] Ignoring nonexistent file "not".' \
348 'info: [subst.mk:class] Ignoring non-existent file "exist".' 348 'info: [subst.mk:class] Ignoring nonexistent file "exist".'
349 assert_that "actual-output" --file-equals "expected-output" 349 assert_that "actual-output" --file-equals "expected-output"
350 assert_that "$exitcode" --equals "0" 350 assert_that "$exitcode" --equals "0"
351 351
352 test_case_end 352 test_case_end
353fi 353fi
354 354
355 355
356if test_case_begin "multiple no-op files, all are reported at once"; then 356if test_case_begin "multiple no-op files, all are reported at once"; then
357 357
358 create_file "testcase.mk" <<EOF 358 create_file "testcase.mk" <<EOF
359SUBST_CLASSES+= class 359SUBST_CLASSES+= class
360SUBST_STAGE.class= pre-configure 360SUBST_STAGE.class= pre-configure
361SUBST_FILES.class= first second third 361SUBST_FILES.class= first second third
@@ -1016,27 +1016,27 @@ if test_case_begin "empty SUBST_SED"; th @@ -1016,27 +1016,27 @@ if test_case_begin "empty SUBST_SED"; th
1016 'SUBST_NOOP_OK.id= no' \ 1016 'SUBST_NOOP_OK.id= no' \
1017 '' \ 1017 '' \
1018 'all:' \ 1018 'all:' \
1019 ' @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \ 1019 ' @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \
1020 '' \ 1020 '' \
1021 '.include "prepare-subst.mk"' \ 1021 '.include "prepare-subst.mk"' \
1022 '.include "mk/subst.mk"' 1022 '.include "mk/subst.mk"'
1023 1023
1024 run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/out" 2>&1 \ 1024 run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/out" 2>&1 \
1025 && exitcode=0 || exitcode=$? 1025 && exitcode=0 || exitcode=$?
1026 1026
1027 assert_that "out" --file-is-lines \ 1027 assert_that "out" --file-is-lines \
1028 '=> Substituting "id" in file' \ 1028 '=> Substituting "id" in file' \
1029 'warning: [subst.mk:id] Ignoring non-existent file "file".' \ 1029 'warning: [subst.mk:id] Ignoring nonexistent file "file".' \
1030 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ 1030 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \
1031 '*** Error code 1' \ 1031 '*** Error code 1' \
1032 '' \ 1032 '' \
1033 'Stop.' \ 1033 'Stop.' \
1034 "$make: stopped in $PWD" 1034 "$make: stopped in $PWD"
1035 1035
1036 test_case_end 1036 test_case_end
1037fi 1037fi
1038 1038
1039 1039
1040if test_case_begin "typo in SUBST_CLASSES"; then 1040if test_case_begin "typo in SUBST_CLASSES"; then
1041 1041
1042 # Look closely. The SUBST_CLASSES line contains a typo. 1042 # Look closely. The SUBST_CLASSES line contains a typo.
@@ -1050,27 +1050,27 @@ if test_case_begin "typo in SUBST_CLASSE @@ -1050,27 +1050,27 @@ if test_case_begin "typo in SUBST_CLASSE
1050 'SUBST_NOOP_OK.id= no' \ 1050 'SUBST_NOOP_OK.id= no' \
1051 '' \ 1051 '' \
1052 'all:' \ 1052 'all:' \
1053 ' @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \ 1053 ' @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \
1054 '' \ 1054 '' \
1055 '.include "prepare-subst.mk"' \ 1055 '.include "prepare-subst.mk"' \
1056 '.include "mk/subst.mk"' 1056 '.include "mk/subst.mk"'
1057 1057
1058 run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/out" 2>&1 \ 1058 run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/out" 2>&1 \
1059 && exitcode=0 || exitcode=$? 1059 && exitcode=0 || exitcode=$?
1060 1060
1061 assert_that "out" --file-is-lines \ 1061 assert_that "out" --file-is-lines \
1062 '=> Substituting "id" in file' \ 1062 '=> Substituting "id" in file' \
1063 'warning: [subst.mk:id] Ignoring non-existent file "file".' \ 1063 'warning: [subst.mk:id] Ignoring nonexistent file "file".' \
1064 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ 1064 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \
1065 '*** Error code 1' \ 1065 '*** Error code 1' \
1066 '' \ 1066 '' \
1067 'Stop.' \ 1067 'Stop.' \
1068 "$make: stopped in $PWD" 1068 "$make: stopped in $PWD"
1069 1069
1070 test_case_end 1070 test_case_end
1071fi 1071fi
1072 1072
1073 1073
1074if test_case_begin "executable bit is preserved"; then 1074if test_case_begin "executable bit is preserved"; then
1075 1075
1076 create_file_lines "testcase.mk" \ 1076 create_file_lines "testcase.mk" \