| @@ -1,25 +1,26 @@ | | | @@ -1,25 +1,26 @@ |
1 | #! /bin/sh | | 1 | #! /bin/sh |
2 | # $NetBSD: subst.sh,v 1.33 2020/05/09 17:10:38 rillig Exp $ | | 2 | # $NetBSD: subst.sh,v 1.34 2020/05/11 19:13:10 rillig Exp $ |
3 | # | | 3 | # |
4 | # Tests for mk/subst.mk. | | 4 | # Tests for mk/subst.mk. |
5 | # | | 5 | # |
6 | | | 6 | |
7 | set -eu | | 7 | set -eu |
8 | | | 8 | |
9 | . "./test.subr" | | 9 | . "./test.subr" |
10 | | | 10 | |
11 | test_case_set_up() { | | 11 | test_case_set_up() { |
12 | rm -rf "$tmpdir"/.??* "$tmpdir"/* | | 12 | wrkdir="$tmpdir/wrkdir" |
| | | 13 | mkdir "$wrkdir" |
13 | | | 14 | |
14 | create_file "prepare-subst.mk" <<-EOF | | 15 | create_file "prepare-subst.mk" <<-EOF |
15 | # The tools that are used by subst.mk | | 16 | # The tools that are used by subst.mk |
16 | AWK= awk | | 17 | AWK= awk |
17 | CHMOD= chmod | | 18 | CHMOD= chmod |
18 | CMP= cmp | | 19 | CMP= cmp |
19 | DIFF= diff | | 20 | DIFF= diff |
20 | ECHO= echo | | 21 | ECHO= echo |
21 | MKDIR= mkdir -p | | 22 | MKDIR= mkdir -p |
22 | MV= mv | | 23 | MV= mv |
23 | RM= rm | | 24 | RM= rm |
24 | RMDIR= rmdir | | 25 | RMDIR= rmdir |
25 | SED= sed | | 26 | SED= sed |
| @@ -27,83 +28,91 @@ test_case_set_up() { | | | @@ -27,83 +28,91 @@ test_case_set_up() { |
27 | TOUCH= touch | | 28 | TOUCH= touch |
28 | TOUCH_FLAGS= # none | | 29 | TOUCH_FLAGS= # none |
29 | TR= tr | | 30 | TR= tr |
30 | TRUE= true | | 31 | TRUE= true |
31 | | | 32 | |
32 | # Commands that are specific to pkgsrc | | 33 | # Commands that are specific to pkgsrc |
33 | RUN= @set -e; | | 34 | RUN= @set -e; |
34 | STEP_MSG= echo "=>" | | 35 | STEP_MSG= echo "=>" |
35 | DO_NADA= : do-nada | | 36 | DO_NADA= : do-nada |
36 | INFO_MSG= echo "info:" | | 37 | INFO_MSG= echo "info:" |
37 | WARNING_MSG= echo "warning:" | | 38 | WARNING_MSG= echo "warning:" |
38 | FAIL_MSG= sh $pkgsrcdir/mk/scripts/fail echo "fail:" | | 39 | FAIL_MSG= sh $pkgsrcdir/mk/scripts/fail echo "fail:" |
39 | | | 40 | |
40 | WRKDIR= $tmpdir | | 41 | WRKDIR= $tmpdir/wrkdir |
41 | WRKSRC= $tmpdir | | 42 | WRKSRC= . |
42 | EOF | | 43 | EOF |
43 | } | | 44 | } |
44 | | | 45 | |
| | | 46 | test_case_tear_down() { |
| | | 47 | # Clean up the .subst_*_done cookie files. |
| | | 48 | rm -r "$wrkdir" |
| | | 49 | } |
| | | 50 | |
45 | | | 51 | |
46 | if test_case_begin "single file"; then | | 52 | if test_case_begin "single file"; then |
47 | | | 53 | |
48 | # A single file is patched successfully. | | 54 | # A single file is patched successfully. |
49 | | | 55 | |
50 | create_file "subst-single.mk" <<-EOF | | 56 | create_file "subst-single.mk" <<-EOF |
51 | SUBST_CLASSES+= class | | 57 | SUBST_CLASSES+= class |
52 | SUBST_STAGE.class= pre-configure | | 58 | SUBST_STAGE.class= pre-configure |
53 | SUBST_FILES.class= subst-single.txt | | 59 | SUBST_FILES.class= subst-single.txt |
54 | SUBST_SED.class= -e 's,before,after,' | | 60 | SUBST_SED.class= -e 's,before,after,' |
55 | | | 61 | |
56 | .include "prepare-subst.mk" | | 62 | .include "prepare-subst.mk" |
57 | .include "mk/subst.mk" | | 63 | .include "mk/subst.mk" |
58 | | | 64 | |
59 | all: subst-class | | 65 | all: subst-class |
60 | EOF | | 66 | EOF |
61 | | | 67 | |
62 | create_file_lines "subst-single.txt" \ | | 68 | create_file_lines "subst-single.txt" \ |
63 | "before" | | 69 | "before" |
64 | | | 70 | |
65 | run_bmake "subst-single.mk" > "$tmpdir/output" | | 71 | run_bmake "subst-single.mk" > "$tmpdir/output" |
66 | | | 72 | |
67 | assert_that "output" --file-contains-exactly "=> Substituting \"class\" in subst-single.txt" | | 73 | assert_that "$tmpdir/output" --file-contains-exactly \ |
68 | assert_that "subst-single.txt" --file-contains-exactly "after" | | 74 | "=> Substituting \"class\" in subst-single.txt" |
| | | 75 | assert_that "subst-single.txt" --file-contains-exactly \ |
| | | 76 | "after" |
69 | | | 77 | |
70 | test_case_end | | 78 | test_case_end |
71 | fi | | 79 | fi |
72 | | | 80 | |
73 | | | 81 | |
74 | if test_case_begin "several individual files"; then | | 82 | if test_case_begin "several individual files"; then |
75 | | | 83 | |
76 | # Several individual files are patched successfully. | | 84 | # Several individual files are patched successfully. |
77 | | | 85 | |
78 | create_file "testcase.mk" <<-EOF | | 86 | create_file "testcase.mk" <<-EOF |
79 | SUBST_CLASSES+= class | | 87 | SUBST_CLASSES+= class |
80 | SUBST_STAGE.class= pre-configure | | 88 | SUBST_STAGE.class= pre-configure |
81 | SUBST_FILES.class= first second third | | 89 | SUBST_FILES.class= first second third |
82 | SUBST_SED.class= -e 's,file,example,' | | 90 | SUBST_SED.class= -e 's,file,example,' |
83 | | | 91 | |
84 | .include "prepare-subst.mk" | | 92 | .include "prepare-subst.mk" |
85 | .include "mk/subst.mk" | | 93 | .include "mk/subst.mk" |
86 | | | 94 | |
87 | all: subst-class | | 95 | all: subst-class |
88 | EOF | | 96 | EOF |
89 | | | 97 | |
90 | create_file_lines "first" "the first file" | | 98 | create_file_lines "first" "the first file" |
91 | create_file_lines "second" "the second file" | | 99 | create_file_lines "second" "the second file" |
92 | create_file_lines "third" "the third file" | | 100 | create_file_lines "third" "the third file" |
93 | | | 101 | |
94 | output=$(run_bmake "testcase.mk") | | 102 | run_bmake "testcase.mk" > "$tmpdir/output" |
95 | | | 103 | |
96 | assert_that "$output" --equals "=> Substituting \"class\" in first second third" | | 104 | assert_that "$tmpdir/output" --file-is-lines \ |
| | | 105 | "=> Substituting \"class\" in first second third" |
97 | assert_that "first" --file-contains-exactly "the first example" | | 106 | assert_that "first" --file-contains-exactly "the first example" |
98 | assert_that "second" --file-contains-exactly "the second example" | | 107 | assert_that "second" --file-contains-exactly "the second example" |
99 | assert_that "third" --file-contains-exactly "the third example" | | 108 | assert_that "third" --file-contains-exactly "the third example" |
100 | | | 109 | |
101 | test_case_end | | 110 | test_case_end |
102 | fi | | 111 | fi |
103 | | | 112 | |
104 | | | 113 | |
105 | if test_case_begin "several files by pattern"; then | | 114 | if test_case_begin "several files by pattern"; then |
106 | | | 115 | |
107 | # Several files are patched successfully. | | 116 | # Several files are patched successfully. |
108 | # The filenames are given by a pattern. | | 117 | # The filenames are given by a pattern. |
109 | | | 118 | |
| @@ -149,242 +158,243 @@ if test_case_begin "pattern with 1 noop" | | | @@ -149,242 +158,243 @@ if test_case_begin "pattern with 1 noop" |
149 | SUBST_FILES.class= pattern-* | | 158 | SUBST_FILES.class= pattern-* |
150 | SUBST_SED.class= -e 's,file,example,' | | 159 | SUBST_SED.class= -e 's,file,example,' |
151 | | | 160 | |
152 | .include "prepare-subst.mk" | | 161 | .include "prepare-subst.mk" |
153 | .include "mk/subst.mk" | | 162 | .include "mk/subst.mk" |
154 | | | 163 | |
155 | all: subst-class | | 164 | all: subst-class |
156 | EOF | | 165 | EOF |
157 | | | 166 | |
158 | create_file_lines "pattern-first" "the first file" | | 167 | create_file_lines "pattern-first" "the first file" |
159 | create_file_lines "pattern-second" "the second is already an example" | | 168 | create_file_lines "pattern-second" "the second is already an example" |
160 | create_file_lines "pattern-third" "the third file" | | 169 | create_file_lines "pattern-third" "the third file" |
161 | | | 170 | |
162 | run_bmake "testcase.mk" > "$tmpdir/actual-output" | | 171 | run_bmake "testcase.mk" > "$tmpdir/output" |
163 | create_file_lines "expected-output" \ | | 172 | create_file_lines "expected-output" \ |
164 | '=> Substituting "class" in pattern-*' \ | | 173 | '=> Substituting "class" in pattern-*' \ |
165 | 'info: [subst.mk:class] Nothing changed in "pattern-second".' | | 174 | 'info: [subst.mk:class] Nothing changed in "pattern-second".' |
166 | | | 175 | |
167 | assert_that "actual-output" --file-equals "expected-output" | | 176 | assert_that "$tmpdir/output" --file-equals "expected-output" |
168 | assert_that "pattern-first" --file-contains-exactly "the first example" | | 177 | assert_that "pattern-first" --file-contains-exactly "the first example" |
169 | assert_that "pattern-second" --file-contains-exactly "the second is already an example" | | 178 | assert_that "pattern-second" --file-contains-exactly "the second is already an example" |
170 | assert_that "pattern-third" --file-contains-exactly "the third example" | | 179 | assert_that "pattern-third" --file-contains-exactly "the third example" |
171 | | | 180 | |
172 | test_case_end | | 181 | test_case_end |
173 | fi | | 182 | fi |
174 | | | 183 | |
175 | | | 184 | |
176 | if test_case_begin "single file noop, noop_ok=yes"; then | | 185 | if test_case_begin "single file noop, noop_ok=yes"; then |
177 | | | 186 | |
178 | create_file "testcase.mk" <<-EOF | | 187 | create_file "testcase.mk" <<-EOF |
179 | SUBST_CLASSES+= class | | 188 | SUBST_CLASSES+= class |
180 | SUBST_STAGE.class= pre-configure | | 189 | SUBST_STAGE.class= pre-configure |
181 | SUBST_FILES.class= single | | 190 | SUBST_FILES.class= single |
182 | SUBST_SED.class= -e 's,file,example,' | | 191 | SUBST_SED.class= -e 's,file,example,' |
183 | SUBST_NOOP_OK.class= yes | | 192 | SUBST_NOOP_OK.class= yes |
184 | | | 193 | |
185 | .include "prepare-subst.mk" | | 194 | .include "prepare-subst.mk" |
186 | .include "mk/subst.mk" | | 195 | .include "mk/subst.mk" |
187 | | | 196 | |
188 | all: subst-class | | 197 | all: subst-class |
189 | EOF | | 198 | EOF |
190 | | | 199 | |
191 | create_file_lines "single" "already an example" | | 200 | create_file_lines "single" "already an example" |
192 | | | 201 | |
193 | run_bmake "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$? | | 202 | run_bmake "testcase.mk" > "$tmpdir/output" \ |
| | | 203 | && exitcode=0 || exitcode=$? |
194 | | | 204 | |
195 | create_file_lines "expected-output" \ | | 205 | assert_that "$tmpdir/output" --file-is-lines \ |
196 | '=> Substituting "class" in single' \ | | 206 | '=> Substituting "class" in single' \ |
197 | 'info: [subst.mk:class] Nothing changed in "single".' | | 207 | 'info: [subst.mk:class] Nothing changed in "single".' |
198 | assert_that "actual-output" --file-equals "expected-output" | | | |
199 | assert_that "single" --file-contains-exactly "already an example" | | 208 | assert_that "single" --file-contains-exactly "already an example" |
200 | assert_that "$exitcode" --equals "0" | | 209 | assert_that "$exitcode" --equals "0" |
201 | | | 210 | |
202 | test_case_end | | 211 | test_case_end |
203 | fi | | 212 | fi |
204 | | | 213 | |
205 | | | 214 | |
206 | if test_case_begin "single file noop, noop_ok=no"; then | | 215 | if test_case_begin "single file noop, noop_ok=no"; then |
207 | | | 216 | |
208 | create_file "testcase.mk" <<-EOF | | 217 | create_file "testcase.mk" <<-EOF |
209 | SUBST_CLASSES+= class | | 218 | SUBST_CLASSES+= class |
210 | SUBST_STAGE.class= pre-configure | | 219 | SUBST_STAGE.class= pre-configure |
211 | SUBST_FILES.class= single | | 220 | SUBST_FILES.class= single |
212 | SUBST_SED.class= -e 's,file,example,' | | 221 | SUBST_SED.class= -e 's,file,example,' |
213 | SUBST_NOOP_OK.class= no | | 222 | SUBST_NOOP_OK.class= no |
214 | | | 223 | |
215 | .include "prepare-subst.mk" | | 224 | .include "prepare-subst.mk" |
216 | .include "mk/subst.mk" | | 225 | .include "mk/subst.mk" |
217 | | | 226 | |
218 | all: subst-class | | 227 | all: subst-class |
219 | EOF | | 228 | EOF |
220 | | | 229 | |
221 | create_file_lines "single" "already an example" | | 230 | create_file_lines "single" "already an example" |
222 | | | 231 | |
223 | run_bmake "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$? | | 232 | run_bmake "testcase.mk" > "$tmpdir/output" \ |
| | | 233 | && exitcode=0 || exitcode=$? |
224 | | | 234 | |
225 | create_file_lines "expected-output" \ | | 235 | create_file_lines "expected-output" \ |
226 | '=> Substituting "class" in single' \ | | 236 | '=> Substituting "class" in single' \ |
227 | 'warning: [subst.mk:class] Nothing changed in "single".' \ | | 237 | 'warning: [subst.mk:class] Nothing changed in "single".' \ |
228 | 'fail: [subst.mk:class] The filename pattern "single" has no effect.' \ | | 238 | 'fail: [subst.mk:class] The filename pattern "single" has no effect.' \ |
229 | '*** Error code 1' \ | | 239 | '*** Error code 1' \ |
230 | '' \ | | 240 | '' \ |
231 | 'Stop.' \ | | 241 | 'Stop.' \ |
232 | "$make: stopped in $PWD" | | 242 | "$make: stopped in $PWD" |
233 | assert_that "actual-output" --file-equals "expected-output" | | 243 | assert_that "$tmpdir/output" --file-equals "expected-output" |
234 | assert_that "single" --file-contains-exactly "already an example" | | 244 | assert_that "single" --file-contains-exactly "already an example" |
235 | assert_that "$exitcode" --equals "1" | | 245 | assert_that "$exitcode" --equals "1" |
236 | | | 246 | |
237 | test_case_end | | 247 | test_case_end |
238 | fi | | 248 | fi |
239 | | | 249 | |
240 | | | 250 | |
241 | if test_case_begin "single file nonexistent"; then | | 251 | if test_case_begin "single file nonexistent"; then |
242 | | | 252 | |
243 | create_file "testcase.mk" <<-EOF | | 253 | create_file "testcase.mk" <<-EOF |
244 | SUBST_CLASSES+= class | | 254 | SUBST_CLASSES+= class |
245 | SUBST_STAGE.class= pre-configure | | 255 | SUBST_STAGE.class= pre-configure |
246 | SUBST_FILES.class= nonexistent | | 256 | SUBST_FILES.class= nonexistent |
247 | SUBST_SED.class= -e 's,file,example,' | | 257 | SUBST_SED.class= -e 's,file,example,' |
248 | SUBST_NOOP_OK.class= no | | 258 | SUBST_NOOP_OK.class= no |
249 | | | 259 | |
250 | .include "prepare-subst.mk" | | 260 | .include "prepare-subst.mk" |
251 | .include "mk/subst.mk" | | 261 | .include "mk/subst.mk" |
252 | | | 262 | |
253 | all: subst-class | | 263 | all: subst-class |
254 | EOF | | 264 | EOF |
255 | | | 265 | |
256 | run_bmake "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$? | | 266 | run_bmake "testcase.mk" > "$tmpdir/output" \ |
| | | 267 | && exitcode=0 || exitcode=$? |
257 | | | 268 | |
258 | create_file_lines "expected-output" \ | | 269 | assert_that "$tmpdir/output" --file-is-lines \ |
259 | '=> Substituting "class" in nonexistent' \ | | 270 | '=> Substituting "class" in nonexistent' \ |
260 | 'warning: [subst.mk:class] Ignoring nonexistent file "nonexistent".' \ | | 271 | 'warning: [subst.mk:class] Ignoring nonexistent file "nonexistent".' \ |
261 | 'fail: [subst.mk:class] The filename pattern "nonexistent" has no effect.' \ | | 272 | 'fail: [subst.mk:class] The filename pattern "nonexistent" has no effect.' \ |
262 | '*** Error code 1' \ | | 273 | '*** Error code 1' \ |
263 | '' \ | | 274 | '' \ |
264 | 'Stop.' \ | | 275 | 'Stop.' \ |
265 | "$make: stopped in $PWD" | | 276 | "$make: stopped in $PWD" |
266 | assert_that "actual-output" --file-equals "expected-output" | | | |
267 | assert_that "$exitcode" --equals "1" | | 277 | assert_that "$exitcode" --equals "1" |
268 | | | 278 | |
269 | test_case_end | | 279 | test_case_end |
270 | fi | | 280 | fi |
271 | | | 281 | |
272 | | | 282 | |
273 | if test_case_begin "single file nonexistent ok"; then | | 283 | if test_case_begin "single file nonexistent ok"; then |
274 | | | 284 | |
275 | create_file "testcase.mk" <<-EOF | | 285 | create_file "testcase.mk" <<-EOF |
276 | SUBST_CLASSES+= class | | 286 | SUBST_CLASSES+= class |
277 | SUBST_STAGE.class= pre-configure | | 287 | SUBST_STAGE.class= pre-configure |
278 | SUBST_FILES.class= nonexistent | | 288 | SUBST_FILES.class= nonexistent |
279 | SUBST_SED.class= -e 's,file,example,' | | 289 | SUBST_SED.class= -e 's,file,example,' |
280 | SUBST_NOOP_OK.class= yes | | 290 | SUBST_NOOP_OK.class= yes |
281 | | | 291 | |
282 | .include "prepare-subst.mk" | | 292 | .include "prepare-subst.mk" |
283 | .include "mk/subst.mk" | | 293 | .include "mk/subst.mk" |
284 | | | 294 | |
285 | all: subst-class | | 295 | all: subst-class |
286 | EOF | | 296 | EOF |
287 | | | 297 | |
288 | run_bmake "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$? | | 298 | run_bmake "testcase.mk" > "$tmpdir/output" \ |
| | | 299 | && exitcode=0 || exitcode=$? |
289 | | | 300 | |
290 | create_file_lines "expected-output" \ | | 301 | assert_that "$tmpdir/output" --file-is-lines \ |
291 | '=> Substituting "class" in nonexistent' \ | | 302 | '=> Substituting "class" in nonexistent' \ |
292 | 'info: [subst.mk:class] Ignoring nonexistent file "nonexistent".' | | 303 | 'info: [subst.mk:class] Ignoring nonexistent file "nonexistent".' |
293 | assert_that "actual-output" --file-equals "expected-output" | | | |
294 | assert_that "$exitcode" --equals "0" | | 304 | assert_that "$exitcode" --equals "0" |
295 | | | 305 | |
296 | test_case_end | | 306 | test_case_end |
297 | fi | | 307 | fi |
298 | | | 308 | |
299 | | | 309 | |
300 | if test_case_begin "several patterns, 1 nonexistent"; then | | 310 | if test_case_begin "several patterns, 1 nonexistent"; then |
301 | | | 311 | |
302 | create_file "testcase.mk" <<-EOF | | 312 | create_file "testcase.mk" <<-EOF |
303 | SUBST_CLASSES+= class | | 313 | SUBST_CLASSES+= class |
304 | SUBST_STAGE.class= pre-configure | | 314 | SUBST_STAGE.class= pre-configure |
305 | SUBST_FILES.class= *exist* *not-found* | | 315 | SUBST_FILES.class= *exist* *not-found* |
306 | SUBST_SED.class= -e 's,file,example,' | | 316 | SUBST_SED.class= -e 's,file,example,' |
307 | | | 317 | |
308 | .include "prepare-subst.mk" | | 318 | .include "prepare-subst.mk" |
309 | .include "mk/subst.mk" | | 319 | .include "mk/subst.mk" |
310 | | | 320 | |
311 | all: subst-class | | 321 | all: subst-class |
312 | EOF | | 322 | EOF |
313 | | | 323 | |
314 | create_file_lines "exists" "this file exists" | | 324 | create_file_lines "exists" "this file exists" |
315 | | | 325 | |
316 | run_bmake "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$? | | 326 | run_bmake "testcase.mk" > "$tmpdir/output" \ |
| | | 327 | && exitcode=0 || exitcode=$? |
317 | | | 328 | |
318 | create_file_lines "expected-output" \ | | 329 | assert_that "$tmpdir/output" --file-is-lines \ |
319 | '=> Substituting "class" in *exist* *not-found*' \ | | 330 | '=> Substituting "class" in *exist* *not-found*' \ |
320 | 'info: [subst.mk:class] Ignoring nonexistent file "./*not-found*".' | | 331 | 'info: [subst.mk:class] Ignoring nonexistent file "./*not-found*".' |
321 | assert_that "actual-output" --file-equals "expected-output" | | | |
322 | assert_that "exists" --file-contains-exactly "this example exists" | | 332 | assert_that "exists" --file-contains-exactly "this example exists" |
323 | assert_that "$exitcode" --equals "0" | | 333 | assert_that "$exitcode" --equals "0" |
324 | | | 334 | |
325 | test_case_end | | 335 | test_case_end |
326 | fi | | 336 | fi |
327 | | | 337 | |
328 | | | 338 | |
329 | if test_case_begin "multiple missing files, all are reported at once"; then | | 339 | if test_case_begin "multiple missing files, all are reported at once"; then |
330 | | | 340 | |
331 | create_file "testcase.mk" <<-EOF | | 341 | create_file "testcase.mk" <<-EOF |
332 | SUBST_CLASSES+= class | | 342 | SUBST_CLASSES+= class |
333 | SUBST_STAGE.class= pre-configure | | 343 | SUBST_STAGE.class= pre-configure |
334 | SUBST_FILES.class= does not exist | | 344 | SUBST_FILES.class= does not exist |
335 | SUBST_SED.class= -e 'sahara' | | 345 | SUBST_SED.class= -e 'sahara' |
336 | | | 346 | |
337 | .include "prepare-subst.mk" | | 347 | .include "prepare-subst.mk" |
338 | .include "mk/subst.mk" | | 348 | .include "mk/subst.mk" |
339 | EOF | | 349 | EOF |
340 | | | 350 | |
341 | run_bmake "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$? | | 351 | run_bmake "testcase.mk" > "$tmpdir/output" \ |
| | | 352 | && exitcode=0 || exitcode=$? |
342 | | | 353 | |
343 | create_file_lines "expected-output" \ | | 354 | assert_that "$tmpdir/output" --file-is-lines \ |
344 | '=> Substituting "class" in does not exist' \ | | 355 | '=> Substituting "class" in does not exist' \ |
345 | 'info: [subst.mk:class] Ignoring nonexistent file "does".' \ | | 356 | 'info: [subst.mk:class] Ignoring nonexistent file "does".' \ |
346 | 'info: [subst.mk:class] Ignoring nonexistent file "not".' \ | | 357 | 'info: [subst.mk:class] Ignoring nonexistent file "not".' \ |
347 | 'info: [subst.mk:class] Ignoring nonexistent file "exist".' | | 358 | 'info: [subst.mk:class] Ignoring nonexistent file "exist".' |
348 | assert_that "actual-output" --file-equals "expected-output" | | | |
349 | assert_that "$exitcode" --equals "0" | | 359 | assert_that "$exitcode" --equals "0" |
350 | | | 360 | |
351 | test_case_end | | 361 | test_case_end |
352 | fi | | 362 | fi |
353 | | | 363 | |
354 | | | 364 | |
355 | if test_case_begin "multiple no-op files, all are reported at once"; then | | 365 | if test_case_begin "multiple no-op files, all are reported at once"; then |
356 | | | 366 | |
357 | create_file "testcase.mk" <<-EOF | | 367 | create_file "testcase.mk" <<-EOF |
358 | SUBST_CLASSES+= class | | 368 | SUBST_CLASSES+= class |
359 | SUBST_STAGE.class= pre-configure | | 369 | SUBST_STAGE.class= pre-configure |
360 | SUBST_FILES.class= first second third | | 370 | SUBST_FILES.class= first second third |
361 | SUBST_SED.class= -e 's,from,to,' | | 371 | SUBST_SED.class= -e 's,from,to,' |
362 | | | 372 | |
363 | .include "prepare-subst.mk" | | 373 | .include "prepare-subst.mk" |
364 | .include "mk/subst.mk" | | 374 | .include "mk/subst.mk" |
365 | EOF | | 375 | EOF |
366 | create_file_lines "first" "text" | | 376 | create_file_lines "first" "text" |
367 | create_file_lines "second" "second" | | 377 | create_file_lines "second" "second" |
368 | create_file_lines "third" "third" | | 378 | create_file_lines "third" "third" |
369 | | | 379 | |
370 | run_bmake "testcase.mk" > "$tmpdir/actual-output" && exitcode=0 || exitcode=$? | | 380 | run_bmake "testcase.mk" > "$tmpdir/output" \ |
| | | 381 | && exitcode=0 || exitcode=$? |
371 | | | 382 | |
372 | create_file_lines "expected-output" \ | | 383 | assert_that "$tmpdir/output" --file-is-lines \ |
373 | '=> Substituting "class" in first second third' \ | | 384 | '=> Substituting "class" in first second third' \ |
374 | 'info: [subst.mk:class] Nothing changed in "first".' \ | | 385 | 'info: [subst.mk:class] Nothing changed in "first".' \ |
375 | 'info: [subst.mk:class] Nothing changed in "second".' \ | | 386 | 'info: [subst.mk:class] Nothing changed in "second".' \ |
376 | 'info: [subst.mk:class] Nothing changed in "third".' | | 387 | 'info: [subst.mk:class] Nothing changed in "third".' |
377 | assert_that "actual-output" --file-equals "expected-output" | | | |
378 | assert_that "$exitcode" --equals "0" | | 388 | assert_that "$exitcode" --equals "0" |
379 | | | 389 | |
380 | test_case_end | | 390 | test_case_end |
381 | fi | | 391 | fi |
382 | | | 392 | |
383 | | | 393 | |
384 | if test_case_begin "late evaluation of SUBST_FILES"; then | | 394 | if test_case_begin "late evaluation of SUBST_FILES"; then |
385 | | | 395 | |
386 | # Ensure that SUBST_FILES is evaluated as late as possible. | | 396 | # Ensure that SUBST_FILES is evaluated as late as possible. |
387 | # Evaluating it early breaks cases like pkglocaledir where the | | 397 | # Evaluating it early breaks cases like pkglocaledir where the |
388 | # list of files is generated by a shell command. | | 398 | # list of files is generated by a shell command. |
389 | # See mk/configure/replace-localedir.mk. | | 399 | # See mk/configure/replace-localedir.mk. |
390 | | | 400 | |
| @@ -403,37 +413,36 @@ WRKSRC= \${WRKDIR}/package-1.0 | | | @@ -403,37 +413,36 @@ WRKSRC= \${WRKDIR}/package-1.0 |
403 | .include "mk/subst.mk" | | 413 | .include "mk/subst.mk" |
404 | | | 414 | |
405 | # It is tricky that the dependency must use an internal implementation | | 415 | # It is tricky that the dependency must use an internal implementation |
406 | # detail, but that's the only way to guarantee the correct ordering. | | 416 | # detail, but that's the only way to guarantee the correct ordering. |
407 | \${_SUBST_COOKIE.class}: prepare-subst-class | | 417 | \${_SUBST_COOKIE.class}: prepare-subst-class |
408 | prepare-subst-class: | | 418 | prepare-subst-class: |
409 | \${RUN} \${MKDIR} \${WRKSRC} | | 419 | \${RUN} \${MKDIR} \${WRKSRC} |
410 | \${RUN} \${ECHO} "from" > "\${WRKSRC}/first" | | 420 | \${RUN} \${ECHO} "from" > "\${WRKSRC}/first" |
411 | \${RUN} \${ECHO} "from" > "\${WRKSRC}/second" | | 421 | \${RUN} \${ECHO} "from" > "\${WRKSRC}/second" |
412 | \${RUN} \${ECHO} "from" > "\${WRKSRC}/third" | | 422 | \${RUN} \${ECHO} "from" > "\${WRKSRC}/third" |
413 | EOF | | 423 | EOF |
414 | | | 424 | |
415 | run_bmake "testcase.mk" "subst-class" \ | | 425 | run_bmake "testcase.mk" "subst-class" \ |
416 | 1> "$tmpdir/actual-output" \ | | 426 | 1> "$tmpdir/stdout" \ |
417 | 2> "$tmpdir/actual-stderr" \ | | 427 | 2> "$tmpdir/stderr" \ |
418 | && exitcode=0 || exitcode=$? | | 428 | && exitcode=0 || exitcode=$? |
419 | | | 429 | |
420 | create_file_lines "expected-output" \ | | 430 | assert_that "$tmpdir/stdout" --file-is-lines \ |
421 | '=> Substituting "class" in first third' | | 431 | '=> Substituting "class" in first third' |
422 | assert_that "actual-output" --file-equals "expected-output" | | 432 | assert_that "$tmpdir/stderr" --file-is-empty |
423 | assert_that "actual-stderr" --file-is-empty | | 433 | assert_that "$wrkdir/package-1.0/first" --file-contains-exactly "to" |
424 | assert_that "package-1.0/first" --file-contains-exactly "to" | | 434 | assert_that "$wrkdir/package-1.0/second" --file-contains-exactly "from" |
425 | assert_that "package-1.0/second" --file-contains-exactly "from" | | 435 | assert_that "$wrkdir/package-1.0/third" --file-contains-exactly "to" |
426 | assert_that "package-1.0/third" --file-contains-exactly "to" | | | |
427 | assert_that "$exitcode" --equals "0" | | 436 | assert_that "$exitcode" --equals "0" |
428 | | | 437 | |
429 | test_case_end | | 438 | test_case_end |
430 | fi | | 439 | fi |
431 | | | 440 | |
432 | | | 441 | |
433 | if test_case_begin "special characters in filenames"; then | | 442 | if test_case_begin "special characters in filenames"; then |
434 | | | 443 | |
435 | create_file "testcase.mk" <<-EOF | | 444 | create_file "testcase.mk" <<-EOF |
436 | SUBST_CLASSES+= class | | 445 | SUBST_CLASSES+= class |
437 | SUBST_STAGE.class= pre-configure | | 446 | SUBST_STAGE.class= pre-configure |
438 | SUBST_FILES.class= * | | 447 | SUBST_FILES.class= * |
439 | SUBST_SED.class= -e s,before,after, | | 448 | SUBST_SED.class= -e s,before,after, |
| @@ -447,33 +456,30 @@ if test_case_begin "special characters i | | | @@ -447,33 +456,30 @@ if test_case_begin "special characters i |
447 | create_file_lines "0123456789:;<=>?" "before" | | 456 | create_file_lines "0123456789:;<=>?" "before" |
448 | create_file_lines "@ABCDEFGHIJKLMNO" "before" | | 457 | create_file_lines "@ABCDEFGHIJKLMNO" "before" |
449 | create_file_lines "PQRSTUVWXYZ[\\]^_" "before" | | 458 | create_file_lines "PQRSTUVWXYZ[\\]^_" "before" |
450 | create_file_lines "\`abcdefghijklmno" "before" | | 459 | create_file_lines "\`abcdefghijklmno" "before" |
451 | create_file_lines "pqrstuvwxyz{|}~" "before" | | 460 | create_file_lines "pqrstuvwxyz{|}~" "before" |
452 | create_file_lines "--no-option" "before" | | 461 | create_file_lines "--no-option" "before" |
453 | create_file_lines ".hidden" "before" | | 462 | create_file_lines ".hidden" "before" |
454 | | | 463 | |
455 | run_bmake "testcase.mk" "subst-class" \ | | 464 | run_bmake "testcase.mk" "subst-class" \ |
456 | 1> "$tmpdir/stdout" \ | | 465 | 1> "$tmpdir/stdout" \ |
457 | 2> "$tmpdir/stderr" \ | | 466 | 2> "$tmpdir/stderr" \ |
458 | && exitcode=0 || exitcode=$? | | 467 | && exitcode=0 || exitcode=$? |
459 | | | 468 | |
460 | assert_that "stdout" --file-is-lines \ | | 469 | assert_that "$tmpdir/stdout" --file-is-lines \ |
461 | '=> Substituting "class" in *' \ | | 470 | '=> Substituting "class" in *' \ |
462 | 'info: [subst.mk:class] Nothing changed in "prepare-subst.mk".' \ | | 471 | 'info: [subst.mk:class] Nothing changed in "prepare-subst.mk".' |
463 | 'info: [subst.mk:class] Nothing changed in "stderr".' \ | | 472 | assert_that "$tmpdir/stderr" --file-is-empty |
464 | 'info: [subst.mk:class] Nothing changed in "stdout".' \ | | | |
465 | 'info: [subst.mk:class] Nothing changed in "test.subr.main.mk".' | | | |
466 | assert_that "stderr" --file-is-empty | | | |
467 | assert_that "$exitcode" --equals "0" | | 473 | assert_that "$exitcode" --equals "0" |
468 | | | 474 | |
469 | assert_that " !\"#\$%&'()*+,-." --file-is-lines "after" | | 475 | assert_that " !\"#\$%&'()*+,-." --file-is-lines "after" |
470 | assert_that "0123456789:;<=>?" --file-is-lines "after" | | 476 | assert_that "0123456789:;<=>?" --file-is-lines "after" |
471 | assert_that "@ABCDEFGHIJKLMNO" --file-is-lines "after" | | 477 | assert_that "@ABCDEFGHIJKLMNO" --file-is-lines "after" |
472 | assert_that "PQRSTUVWXYZ[\\]^_" --file-is-lines "after" | | 478 | assert_that "PQRSTUVWXYZ[\\]^_" --file-is-lines "after" |
473 | assert_that "\`abcdefghijklmno" --file-is-lines "after" | | 479 | assert_that "\`abcdefghijklmno" --file-is-lines "after" |
474 | assert_that "pqrstuvwxyz{|}~" --file-is-lines "after" | | 480 | assert_that "pqrstuvwxyz{|}~" --file-is-lines "after" |
475 | assert_that "--no-option" --file-is-lines "after" | | 481 | assert_that "--no-option" --file-is-lines "after" |
476 | assert_that ".hidden" --file-is-lines "before" | | 482 | assert_that ".hidden" --file-is-lines "before" |
477 | | | 483 | |
478 | test_case_end | | 484 | test_case_end |
479 | fi | | 485 | fi |
| @@ -491,29 +497,29 @@ if test_case_begin "brackets in filename | | | @@ -491,29 +497,29 @@ if test_case_begin "brackets in filename |
491 | .include "mk/subst.mk" | | 497 | .include "mk/subst.mk" |
492 | EOF | | 498 | EOF |
493 | | | 499 | |
494 | create_file_lines "any" "before" | | 500 | create_file_lines "any" "before" |
495 | create_file_lines "x" "before" | | 501 | create_file_lines "x" "before" |
496 | create_file_lines "*" "before" | | 502 | create_file_lines "*" "before" |
497 | create_file_lines "[*]" "before" | | 503 | create_file_lines "[*]" "before" |
498 | | | 504 | |
499 | run_bmake "testcase.mk" "subst-class" \ | | 505 | run_bmake "testcase.mk" "subst-class" \ |
500 | 1> "$tmpdir/stdout" \ | | 506 | 1> "$tmpdir/stdout" \ |
501 | 2> "$tmpdir/stderr" \ | | 507 | 2> "$tmpdir/stderr" \ |
502 | && exitcode=0 || exitcode=$? | | 508 | && exitcode=0 || exitcode=$? |
503 | | | 509 | |
504 | assert_that "stdout" --file-is-lines \ | | 510 | assert_that "$tmpdir/stdout" --file-is-lines \ |
505 | '=> Substituting "class" in [*]' | | 511 | '=> Substituting "class" in [*]' |
506 | assert_that "stderr" --file-is-empty | | 512 | assert_that "$tmpdir/stderr" --file-is-empty |
507 | assert_that "$exitcode" --equals "0" | | 513 | assert_that "$exitcode" --equals "0" |
508 | | | 514 | |
509 | assert_that "any" --file-is-lines "before" | | 515 | assert_that "any" --file-is-lines "before" |
510 | assert_that "x" --file-is-lines "before" | | 516 | assert_that "x" --file-is-lines "before" |
511 | assert_that "*" --file-is-lines "after" | | 517 | assert_that "*" --file-is-lines "after" |
512 | assert_that "[*]" --file-is-lines "before" | | 518 | assert_that "[*]" --file-is-lines "before" |
513 | | | 519 | |
514 | test_case_end | | 520 | test_case_end |
515 | fi | | 521 | fi |
516 | | | 522 | |
517 | | | 523 | |
518 | if test_case_begin "duplicate SUBST class"; then | | 524 | if test_case_begin "duplicate SUBST class"; then |
519 | | | 525 | |
| @@ -524,28 +530,28 @@ SUBST_CLASSES+= one | | | @@ -524,28 +530,28 @@ SUBST_CLASSES+= one |
524 | | | 530 | |
525 | all: | | 531 | all: |
526 | @printf 'fail reason: %s\n' \${PKG_FAIL_REASON} 1>&2 | | 532 | @printf 'fail reason: %s\n' \${PKG_FAIL_REASON} 1>&2 |
527 | | | 533 | |
528 | .include "prepare-subst.mk" | | 534 | .include "prepare-subst.mk" |
529 | .include "mk/subst.mk" | | 535 | .include "mk/subst.mk" |
530 | EOF | | 536 | EOF |
531 | | | 537 | |
532 | run_bmake "testcase.mk" "all" \ | | 538 | run_bmake "testcase.mk" "all" \ |
533 | 1> "$tmpdir/stdout" \ | | 539 | 1> "$tmpdir/stdout" \ |
534 | 2> "$tmpdir/stderr" \ | | 540 | 2> "$tmpdir/stderr" \ |
535 | && exitcode=0 || exitcode=$? | | 541 | && exitcode=0 || exitcode=$? |
536 | | | 542 | |
537 | assert_that "stdout" --file-is-empty | | 543 | assert_that "$tmpdir/stdout" --file-is-empty |
538 | assert_that "stderr" --file-is-lines \ | | 544 | assert_that "$tmpdir/stderr" --file-is-lines \ |
539 | "fail reason: [subst.mk] duplicate SUBST class in: one one two" | | 545 | "fail reason: [subst.mk] duplicate SUBST class in: one one two" |
540 | assert_that "$exitcode" --equals 0 | | 546 | assert_that "$exitcode" --equals 0 |
541 | | | 547 | |
542 | test_case_end | | 548 | test_case_end |
543 | fi | | 549 | fi |
544 | | | 550 | |
545 | | | 551 | |
546 | if test_case_begin "several SUBST classes"; then | | 552 | if test_case_begin "several SUBST classes"; then |
547 | | | 553 | |
548 | # It's ok to have several SUBST classes that apply to the same file. | | 554 | # It's ok to have several SUBST classes that apply to the same file. |
549 | # The order of execution is not guaranteed though. | | 555 | # The order of execution is not guaranteed though. |
550 | | | 556 | |
551 | create_file_lines "file" "zero one two three four" | | 557 | create_file_lines "file" "zero one two three four" |
| @@ -569,31 +575,31 @@ if test_case_begin "several SUBST classe | | | @@ -569,31 +575,31 @@ if test_case_begin "several SUBST classe |
569 | .include "prepare-subst.mk" | | 575 | .include "prepare-subst.mk" |
570 | .include "mk/subst.mk" | | 576 | .include "mk/subst.mk" |
571 | EOF | | 577 | EOF |
572 | | | 578 | |
573 | run_bmake "testcase.mk" "pre-configure" \ | | 579 | run_bmake "testcase.mk" "pre-configure" \ |
574 | 1> "$tmpdir/stdout" \ | | 580 | 1> "$tmpdir/stdout" \ |
575 | 2> "$tmpdir/stderr" \ | | 581 | 2> "$tmpdir/stderr" \ |
576 | && exitcode=0 || exitcode=$? | | 582 | && exitcode=0 || exitcode=$? |
577 | | | 583 | |
578 | # The order of the above output is not guaranteed. | | 584 | # The order of the above output is not guaranteed. |
579 | LC_ALL=C sort < "$tmpdir/stdout" > "$tmpdir/stdout-sorted" | | 585 | LC_ALL=C sort < "$tmpdir/stdout" > "$tmpdir/stdout-sorted" |
580 | | | 586 | |
581 | assert_that "file" --file-is-lines "zero I II III four" | | 587 | assert_that "file" --file-is-lines "zero I II III four" |
582 | assert_that "stdout-sorted" --file-is-lines \ | | 588 | assert_that "$tmpdir/stdout-sorted" --file-is-lines \ |
583 | "=> Substituting \"one\" in file" \ | | 589 | "=> Substituting \"one\" in file" \ |
584 | "=> Substituting \"three\" in file" \ | | 590 | "=> Substituting \"three\" in file" \ |
585 | "=> Substituting \"two\" in file" | | 591 | "=> Substituting \"two\" in file" |
586 | assert_that "stderr" --file-is-empty | | 592 | assert_that "$tmpdir/stderr" --file-is-empty |
587 | assert_that "$exitcode" --equals 0 | | 593 | assert_that "$exitcode" --equals 0 |
588 | | | 594 | |
589 | test_case_end | | 595 | test_case_end |
590 | fi | | 596 | fi |
591 | | | 597 | |
592 | | | 598 | |
593 | if test_case_begin "show diff"; then | | 599 | if test_case_begin "show diff"; then |
594 | | | 600 | |
595 | create_file_lines "file" "one" "two" "three" | | 601 | create_file_lines "file" "one" "two" "three" |
596 | | | 602 | |
597 | create_file "testcase.mk" <<-EOF | | 603 | create_file "testcase.mk" <<-EOF |
598 | SUBST_CLASSES+= two | | 604 | SUBST_CLASSES+= two |
599 | SUBST_STAGE.two= pre-configure | | 605 | SUBST_STAGE.two= pre-configure |
| @@ -605,36 +611,36 @@ if test_case_begin "show diff"; then | | | @@ -605,36 +611,36 @@ if test_case_begin "show diff"; then |
605 | .include "mk/subst.mk" | | 611 | .include "mk/subst.mk" |
606 | EOF | | 612 | EOF |
607 | | | 613 | |
608 | LC_ALL=C \ | | 614 | LC_ALL=C \ |
609 | run_bmake "testcase.mk" "pre-configure" \ | | 615 | run_bmake "testcase.mk" "pre-configure" \ |
610 | 1> "$tmpdir/stdout" \ | | 616 | 1> "$tmpdir/stdout" \ |
611 | 2> "$tmpdir/stderr" \ | | 617 | 2> "$tmpdir/stderr" \ |
612 | && exitcode=0 || exitcode=$? | | 618 | && exitcode=0 || exitcode=$? |
613 | | | 619 | |
614 | awk '{ if (/^(---|\+\+\+) /) { print $1 " " $2 " (filtered timestamp)" } else { print $0 } }' \ | | 620 | awk '{ if (/^(---|\+\+\+) /) { print $1 " " $2 " (filtered timestamp)" } else { print $0 } }' \ |
615 | < "$tmpdir/stdout" > "$tmpdir/stdout-filtered" | | 621 | < "$tmpdir/stdout" > "$tmpdir/stdout-filtered" |
616 | | | 622 | |
617 | assert_that "file" --file-is-lines "one" "II" "three" | | 623 | assert_that "file" --file-is-lines "one" "II" "three" |
618 | assert_that "stdout-filtered" --file-is-lines \ | | 624 | assert_that "$tmpdir/stdout-filtered" --file-is-lines \ |
619 | "=> Substituting \"two\" in file" \ | | 625 | "=> Substituting \"two\" in file" \ |
620 | "--- file (filtered timestamp)" \ | | 626 | "--- file (filtered timestamp)" \ |
621 | "+++ file.subst.sav (filtered timestamp)" \ | | 627 | "+++ file.subst.sav (filtered timestamp)" \ |
622 | "@@ -1,3 +1,3 @@" \ | | 628 | "@@ -1,3 +1,3 @@" \ |
623 | " one" \ | | 629 | " one" \ |
624 | "-two" \ | | 630 | "-two" \ |
625 | "+II" \ | | 631 | "+II" \ |
626 | " three" | | 632 | " three" |
627 | assert_that "stderr" --file-is-empty | | 633 | assert_that "$tmpdir/stderr" --file-is-empty |
628 | assert_that "$exitcode" --equals 0 | | 634 | assert_that "$exitcode" --equals 0 |
629 | | | 635 | |
630 | test_case_end | | 636 | test_case_end |
631 | fi | | 637 | fi |
632 | | | 638 | |
633 | | | 639 | |
634 | if test_case_begin "global show diff"; then | | 640 | if test_case_begin "global show diff"; then |
635 | | | 641 | |
636 | create_file_lines "file" "one" "two" "three" | | 642 | create_file_lines "file" "one" "two" "three" |
637 | | | 643 | |
638 | create_file "testcase.mk" <<-EOF | | 644 | create_file "testcase.mk" <<-EOF |
639 | SUBST_CLASSES+= two | | 645 | SUBST_CLASSES+= two |
640 | SUBST_STAGE.two= pre-configure | | 646 | SUBST_STAGE.two= pre-configure |
| @@ -645,36 +651,36 @@ if test_case_begin "global show diff"; t | | | @@ -645,36 +651,36 @@ if test_case_begin "global show diff"; t |
645 | .include "prepare-subst.mk" | | 651 | .include "prepare-subst.mk" |
646 | .include "mk/subst.mk" | | 652 | .include "mk/subst.mk" |
647 | EOF | | 653 | EOF |
648 | | | 654 | |
649 | run_bmake "testcase.mk" "pre-configure" \ | | 655 | run_bmake "testcase.mk" "pre-configure" \ |
650 | 1> "$tmpdir/stdout" \ | | 656 | 1> "$tmpdir/stdout" \ |
651 | 2> "$tmpdir/stderr" \ | | 657 | 2> "$tmpdir/stderr" \ |
652 | && exitcode=0 || exitcode=$? | | 658 | && exitcode=0 || exitcode=$? |
653 | | | 659 | |
654 | awk '{ if (/^(---|\+\+\+) /) { print $1 " " $2 " (filtered timestamp)" } else { print $0 } }' \ | | 660 | awk '{ if (/^(---|\+\+\+) /) { print $1 " " $2 " (filtered timestamp)" } else { print $0 } }' \ |
655 | < "$tmpdir/stdout" > "$tmpdir/stdout-filtered" | | 661 | < "$tmpdir/stdout" > "$tmpdir/stdout-filtered" |
656 | | | 662 | |
657 | assert_that "file" --file-is-lines "one" "II" "three" | | 663 | assert_that "file" --file-is-lines "one" "II" "three" |
658 | assert_that "stdout-filtered" --file-is-lines \ | | 664 | assert_that "$tmpdir/stdout-filtered" --file-is-lines \ |
659 | "=> Substituting \"two\" in file" \ | | 665 | "=> Substituting \"two\" in file" \ |
660 | "--- file (filtered timestamp)" \ | | 666 | "--- file (filtered timestamp)" \ |
661 | "+++ file.subst.sav (filtered timestamp)" \ | | 667 | "+++ file.subst.sav (filtered timestamp)" \ |
662 | "@@ -1,3 +1,3 @@" \ | | 668 | "@@ -1,3 +1,3 @@" \ |
663 | " one" \ | | 669 | " one" \ |
664 | "-two" \ | | 670 | "-two" \ |
665 | "+II" \ | | 671 | "+II" \ |
666 | " three" | | 672 | " three" |
667 | assert_that "stderr" --file-is-empty | | 673 | assert_that "$tmpdir/stderr" --file-is-empty |
668 | assert_that "$exitcode" --equals 0 | | 674 | assert_that "$exitcode" --equals 0 |
669 | | | 675 | |
670 | test_case_end | | 676 | test_case_end |
671 | fi | | 677 | fi |
672 | | | 678 | |
673 | | | 679 | |
674 | if test_case_begin "SUBST_VARS"; then | | 680 | if test_case_begin "SUBST_VARS"; then |
675 | | | 681 | |
676 | create_file_lines "testcase.mk" \ | | 682 | create_file_lines "testcase.mk" \ |
677 | 'SUBST_CLASSES+= vars' \ | | 683 | 'SUBST_CLASSES+= vars' \ |
678 | 'SUBST_STAGE.vars= pre-configure' \ | | 684 | 'SUBST_STAGE.vars= pre-configure' \ |
679 | 'SUBST_FILES.vars= vars.txt' \ | | 685 | 'SUBST_FILES.vars= vars.txt' \ |
680 | 'SUBST_VARS.vars= PLAIN DQUOT SQUOT DELIM PRINTABLE' \ | | 686 | 'SUBST_VARS.vars= PLAIN DQUOT SQUOT DELIM PRINTABLE' \ |
| @@ -702,29 +708,29 @@ if test_case_begin "SUBST_VARS"; then | | | @@ -702,29 +708,29 @@ if test_case_begin "SUBST_VARS"; then |
702 | 2> "$tmpdir/stderr" \ | | 708 | 2> "$tmpdir/stderr" \ |
703 | && exitcode=0 || exitcode=$? | | 709 | && exitcode=0 || exitcode=$? |
704 | | | 710 | |
705 | # The double quotes and single quotes are kept since the variables | | 711 | # The double quotes and single quotes are kept since the variables |
706 | # are treated as simple string variables, not as lists of shell | | 712 | # are treated as simple string variables, not as lists of shell |
707 | # words. In these string variables, the quotes are part of the value. | | 713 | # words. In these string variables, the quotes are part of the value. |
708 | assert_that "vars.txt" --file-is-lines \ | | 714 | assert_that "vars.txt" --file-is-lines \ |
709 | "plain" \ | | 715 | "plain" \ |
710 | "\"double quoted\"" \ | | 716 | "\"double quoted\"" \ |
711 | "'single quoted'" \ | | 717 | "'single quoted'" \ |
712 | "hello, world" \ | | 718 | "hello, world" \ |
713 | '!"#$%&'\''()*+,-./09:;<=>?@AZ[\]^_`az{|}' \ | | 719 | '!"#$%&'\''()*+,-./09:;<=>?@AZ[\]^_`az{|}' \ |
714 | "" | | 720 | "" |
715 | assert_that "stdout" --file-is-lines \ | | 721 | assert_that "$tmpdir/stdout" --file-is-lines \ |
716 | "=> Substituting \"vars\" in vars.txt" | | 722 | "=> Substituting \"vars\" in vars.txt" |
717 | assert_that "stderr" --file-is-empty | | 723 | assert_that "$tmpdir/stderr" --file-is-empty |
718 | assert_that "$exitcode" --equals 0 | | 724 | assert_that "$exitcode" --equals 0 |
719 | | | 725 | |
720 | test_case_end | | 726 | test_case_end |
721 | fi | | 727 | fi |
722 | | | 728 | |
723 | if test_case_begin "SUBST_VARS with surrounding whitespace"; then | | 729 | if test_case_begin "SUBST_VARS with surrounding whitespace"; then |
724 | | | 730 | |
725 | # Ensure that leading and trailing whitespace is preserved | | 731 | # Ensure that leading and trailing whitespace is preserved |
726 | # in the variable values. | | 732 | # in the variable values. |
727 | | | 733 | |
728 | create_file_lines "testcase.mk" \ | | 734 | create_file_lines "testcase.mk" \ |
729 | 'SUBST_CLASSES+= vars' \ | | 735 | 'SUBST_CLASSES+= vars' \ |
730 | 'SUBST_STAGE.vars= pre-configure' \ | | 736 | 'SUBST_STAGE.vars= pre-configure' \ |
| @@ -745,29 +751,29 @@ if test_case_begin "SUBST_VARS with surr | | | @@ -745,29 +751,29 @@ if test_case_begin "SUBST_VARS with surr |
745 | run_bmake "testcase.mk" "pre-configure" \ | | 751 | run_bmake "testcase.mk" "pre-configure" \ |
746 | 1> "$tmpdir/stdout" \ | | 752 | 1> "$tmpdir/stdout" \ |
747 | 2> "$tmpdir/stderr" \ | | 753 | 2> "$tmpdir/stderr" \ |
748 | && exitcode=0 || exitcode=$? | | 754 | && exitcode=0 || exitcode=$? |
749 | | | 755 | |
750 | space=' ' | | 756 | space=' ' |
751 | tab=' ' | | 757 | tab=' ' |
752 | newline=' | | 758 | newline=' |
753 | ' | | 759 | ' |
754 | assert_that "vars.txt" --file-is-lines \ | | 760 | assert_that "vars.txt" --file-is-lines \ |
755 | "$space""between spaces""$space" \ | | 761 | "$space""between spaces""$space" \ |
756 | "$tab""between tabs""$tab" \ | | 762 | "$tab""between tabs""$tab" \ |
757 | "$newline""between newlines""$newline" | | 763 | "$newline""between newlines""$newline" |
758 | assert_that "stdout" --file-is-lines \ | | 764 | assert_that "$tmpdir/stdout" --file-is-lines \ |
759 | "=> Substituting \"vars\" in vars.txt" | | 765 | "=> Substituting \"vars\" in vars.txt" |
760 | assert_that "stderr" --file-is-empty | | 766 | assert_that "$tmpdir/stderr" --file-is-empty |
761 | assert_that "$exitcode" --equals 0 | | 767 | assert_that "$exitcode" --equals 0 |
762 | | | 768 | |
763 | test_case_end | | 769 | test_case_end |
764 | fi | | 770 | fi |
765 | | | 771 | |
766 | | | 772 | |
767 | if test_case_begin "SUBST_VARS with backslashes"; then | | 773 | if test_case_begin "SUBST_VARS with backslashes"; then |
768 | | | 774 | |
769 | create_file_lines "testcase.mk" \ | | 775 | create_file_lines "testcase.mk" \ |
770 | 'SUBST_CLASSES+= bs' \ | | 776 | 'SUBST_CLASSES+= bs' \ |
771 | 'SUBST_STAGE.bs= pre-configure' \ | | 777 | 'SUBST_STAGE.bs= pre-configure' \ |
772 | 'SUBST_FILES.bs= backslash.txt' \ | | 778 | 'SUBST_FILES.bs= backslash.txt' \ |
773 | 'SUBST_VARS.bs= BACKSLASHES' \ | | 779 | 'SUBST_VARS.bs= BACKSLASHES' \ |
| @@ -775,29 +781,29 @@ if test_case_begin "SUBST_VARS with back | | | @@ -775,29 +781,29 @@ if test_case_begin "SUBST_VARS with back |
775 | 'BACKSLASHES= \" \, \\, \" \'\'' \0\000 \x40 \089 \a \$$' \ | | 781 | 'BACKSLASHES= \" \, \\, \" \'\'' \0\000 \x40 \089 \a \$$' \ |
776 | '' \ | | 782 | '' \ |
777 | '.include "prepare-subst.mk"' \ | | 783 | '.include "prepare-subst.mk"' \ |
778 | '.include "mk/subst.mk"' | | 784 | '.include "mk/subst.mk"' |
779 | create_file_lines "backslash.txt" "@BACKSLASHES@" | | 785 | create_file_lines "backslash.txt" "@BACKSLASHES@" |
780 | | | 786 | |
781 | run_bmake "testcase.mk" "pre-configure" \ | | 787 | run_bmake "testcase.mk" "pre-configure" \ |
782 | 1> "$tmpdir/stdout" \ | | 788 | 1> "$tmpdir/stdout" \ |
783 | 2> "$tmpdir/stderr" \ | | 789 | 2> "$tmpdir/stderr" \ |
784 | && exitcode=0 || exitcode=$? | | 790 | && exitcode=0 || exitcode=$? |
785 | | | 791 | |
786 | assert_that "backslash.txt" --file-is-lines \ | | 792 | assert_that "backslash.txt" --file-is-lines \ |
787 | '\" \, \\, \" \'\'' \0\000 \x40 \089 \a \$' | | 793 | '\" \, \\, \" \'\'' \0\000 \x40 \089 \a \$' |
788 | assert_that "stdout" --file-is-lines \ | | 794 | assert_that "$tmpdir/stdout" --file-is-lines \ |
789 | "=> Substituting \"bs\" in backslash.txt" | | 795 | "=> Substituting \"bs\" in backslash.txt" |
790 | assert_that "stderr" --file-is-empty | | 796 | assert_that "$tmpdir/stderr" --file-is-empty |
791 | assert_that "$exitcode" --equals 0 | | 797 | assert_that "$exitcode" --equals 0 |
792 | | | 798 | |
793 | test_case_end | | 799 | test_case_end |
794 | fi | | 800 | fi |
795 | | | 801 | |
796 | | | 802 | |
797 | if test_case_begin "SUBST_VARS for variables with regex characters"; then | | 803 | if test_case_begin "SUBST_VARS for variables with regex characters"; then |
798 | | | 804 | |
799 | # Ensure that special regex characters like dots and parentheses | | 805 | # Ensure that special regex characters like dots and parentheses |
800 | # may appear in variable names and are properly escaped. | | 806 | # may appear in variable names and are properly escaped. |
801 | | | 807 | |
802 | # Variable names containing a dollar are not supported. | | 808 | # Variable names containing a dollar are not supported. |
803 | # Bmake behaves very surprisingly when a $ is expanded inside a :C | | 809 | # Bmake behaves very surprisingly when a $ is expanded inside a :C |
| @@ -840,139 +846,137 @@ if test_case_begin "SUBST_VARS for varia | | | @@ -840,139 +846,137 @@ if test_case_begin "SUBST_VARS for varia |
840 | 1> "$tmpdir/stdout" \ | | 846 | 1> "$tmpdir/stdout" \ |
841 | 2> "$tmpdir/stderr" \ | | 847 | 2> "$tmpdir/stderr" \ |
842 | && exitcode=0 || exitcode=$? | | 848 | && exitcode=0 || exitcode=$? |
843 | | | 849 | |
844 | assert_that "vars.txt" --file-is-lines \ | | 850 | assert_that "vars.txt" --file-is-lines \ |
845 | "dots" \ | | 851 | "dots" \ |
846 | "letters" \ | | 852 | "letters" \ |
847 | "parentheses" \ | | 853 | "parentheses" \ |
848 | "angle brackets" \ | | 854 | "angle brackets" \ |
849 | "square brackets" \ | | 855 | "square brackets" \ |
850 | '@VAR.$x@' \ | | 856 | '@VAR.$x@' \ |
851 | 'circumflex' \ | | 857 | 'circumflex' \ |
852 | 'backslash' | | 858 | 'backslash' |
853 | assert_that "stdout" --file-is-lines \ | | 859 | assert_that "$tmpdir/stdout" --file-is-lines \ |
854 | "=> Substituting \"vars\" in vars.txt" | | 860 | "=> Substituting \"vars\" in vars.txt" |
855 | assert_that "stderr" --file-is-empty | | 861 | assert_that "$tmpdir/stderr" --file-is-empty |
856 | assert_that "$exitcode" --equals 0 | | 862 | assert_that "$exitcode" --equals 0 |
857 | | | 863 | |
858 | test_case_end | | 864 | test_case_end |
859 | fi | | 865 | fi |
860 | | | 866 | |
861 | if test_case_begin "pattern matches directory"; then | | 867 | if test_case_begin "pattern matches directory"; then |
862 | | | 868 | |
863 | # When a pattern matches a directory, that directory is silently | | 869 | # When a pattern matches a directory, that directory is silently |
864 | # skipped. | | 870 | # skipped. |
865 | # | | 871 | # |
866 | # In this test case, the pattern also matches a regular file that | | 872 | # In this test case, the pattern also matches a regular file that |
867 | # is actually modified. Therefore the pattern has an effect, and | | 873 | # is actually modified. Therefore the pattern has an effect, and |
868 | # there is no error message. | | 874 | # there is no error message. |
869 | | | 875 | |
870 | create_file_lines "testcase.mk" \ | | 876 | create_file_lines "testcase.mk" \ |
871 | 'SUBST_CLASSES+= dir' \ | | 877 | 'SUBST_CLASSES+= dir' \ |
872 | 'SUBST_STAGE.dir= pre-configure' \ | | 878 | 'SUBST_STAGE.dir= pre-configure' \ |
873 | 'SUBST_FILES.dir= sub*' \ | | 879 | 'SUBST_FILES.dir= sub*' \ |
874 | 'SUBST_VARS.dir= VAR' \ | | 880 | 'SUBST_VARS.dir= VAR' \ |
875 | 'SUBST_NOOP_OK.dir= no' \ | | 881 | 'SUBST_NOOP_OK.dir= no' \ |
876 | '' \ | | 882 | '' \ |
877 | 'VAR= value' \ | | 883 | 'VAR= value' \ |
878 | '' \ | | 884 | '' \ |
879 | '.include "prepare-subst.mk"' \ | | 885 | '.include "prepare-subst.mk"' \ |
880 | '.include "mk/subst.mk"' | | 886 | '.include "mk/subst.mk"' |
881 | mkdir "$tmpdir/subdir" | | | |
882 | create_file_lines "subdir/subfile" \ | | 887 | create_file_lines "subdir/subfile" \ |
883 | "@VAR@" | | 888 | "@VAR@" |
884 | create_file_lines "subst-file" \ | | 889 | create_file_lines "subst-file" \ |
885 | "@VAR@" | | 890 | "@VAR@" |
886 | | | 891 | |
887 | run_bmake "testcase.mk" "pre-configure" \ | | 892 | run_bmake "testcase.mk" "pre-configure" \ |
888 | 1> "$tmpdir/stdout" \ | | 893 | 1> "$tmpdir/stdout" \ |
889 | 2> "$tmpdir/stderr" \ | | 894 | 2> "$tmpdir/stderr" \ |
890 | && exitcode=0 || exitcode=$? | | 895 | && exitcode=0 || exitcode=$? |
891 | | | 896 | |
892 | assert_that "subst-file" --file-is-lines "value" | | 897 | assert_that "subst-file" --file-is-lines "value" |
893 | assert_that "subdir/subfile" --file-is-lines "@VAR@" # unchanged | | 898 | assert_that "subdir/subfile" --file-is-lines "@VAR@" # unchanged |
894 | assert_that "stdout" --file-is-lines \ | | 899 | assert_that "$tmpdir/stdout" --file-is-lines \ |
895 | "=> Substituting \"dir\" in sub*" | | 900 | "=> Substituting \"dir\" in sub*" |
896 | assert_that "stderr" --file-is-empty | | 901 | assert_that "$tmpdir/stderr" --file-is-empty |
897 | assert_that "$exitcode" --equals 0 | | 902 | assert_that "$exitcode" --equals 0 |
898 | | | 903 | |
899 | test_case_end | | 904 | test_case_end |
900 | fi | | 905 | fi |
901 | | | 906 | |
902 | | | 907 | |
903 | if test_case_begin "pattern matches only directory"; then | | 908 | if test_case_begin "pattern matches only directory"; then |
904 | | | 909 | |
905 | # When a pattern matches a directory, that directory is silently | | 910 | # When a pattern matches a directory, that directory is silently |
906 | # skipped. | | 911 | # skipped. |
907 | | | 912 | |
908 | create_file_lines "testcase.mk" \ | | 913 | create_file_lines "testcase.mk" \ |
909 | 'SUBST_CLASSES+= dir' \ | | 914 | 'SUBST_CLASSES+= dir' \ |
910 | 'SUBST_STAGE.dir= pre-configure' \ | | 915 | 'SUBST_STAGE.dir= pre-configure' \ |
911 | 'SUBST_FILES.dir= sub*' \ | | 916 | 'SUBST_FILES.dir= sub*' \ |
912 | 'SUBST_VARS.dir= VAR' \ | | 917 | 'SUBST_VARS.dir= VAR' \ |
913 | 'SUBST_NOOP_OK.dir= no' \ | | 918 | 'SUBST_NOOP_OK.dir= no' \ |
914 | '' \ | | 919 | '' \ |
915 | 'VAR= value' \ | | 920 | 'VAR= value' \ |
916 | '' \ | | 921 | '' \ |
917 | '.include "prepare-subst.mk"' \ | | 922 | '.include "prepare-subst.mk"' \ |
918 | '.include "mk/subst.mk"' | | 923 | '.include "mk/subst.mk"' |
919 | mkdir "$tmpdir/subdir" | | | |
920 | create_file_lines "subdir/subfile" \ | | 924 | create_file_lines "subdir/subfile" \ |
921 | "@VAR@" | | 925 | "@VAR@" |
922 | | | 926 | |
923 | run_bmake "testcase.mk" "pre-configure" \ | | 927 | run_bmake "testcase.mk" "pre-configure" \ |
924 | 1> "$tmpdir/stdout" \ | | 928 | 1> "$tmpdir/stdout" \ |
925 | 2> "$tmpdir/stderr" \ | | 929 | 2> "$tmpdir/stderr" \ |
926 | && exitcode=0 || exitcode=$? | | 930 | && exitcode=0 || exitcode=$? |
927 | | | 931 | |
928 | assert_that "subdir/subfile" --file-is-lines "@VAR@" # unchanged | | 932 | assert_that "subdir/subfile" --file-is-lines "@VAR@" # unchanged |
929 | assert_that "stdout" --file-is-lines \ | | 933 | assert_that "$tmpdir/stdout" --file-is-lines \ |
930 | "=> Substituting \"dir\" in sub*" \ | | 934 | "=> Substituting \"dir\" in sub*" \ |
931 | 'fail: [subst.mk:dir] The filename pattern "sub*" has no effect.' \ | | 935 | 'fail: [subst.mk:dir] The filename pattern "sub*" has no effect.' \ |
932 | "*** Error code 1" \ | | 936 | "*** Error code 1" \ |
933 | "" \ | | 937 | "" \ |
934 | "Stop." \ | | 938 | "Stop." \ |
935 | "$make: stopped in $PWD" | | 939 | "$make: stopped in $PWD" |
936 | assert_that "stderr" --file-is-empty | | 940 | assert_that "$tmpdir/stderr" --file-is-empty |
937 | assert_that "$exitcode" --equals 1 | | 941 | assert_that "$exitcode" --equals 1 |
938 | | | 942 | |
939 | test_case_end | | 943 | test_case_end |
940 | fi | | 944 | fi |
941 | | | 945 | |
942 | | | 946 | |
943 | if test_case_begin "two filename patterns have no effect"; then | | 947 | if test_case_begin "two filename patterns have no effect"; then |
944 | | | 948 | |
945 | # All patterns of SUBST_FILES should be applied before erroring out, | | 949 | # All patterns of SUBST_FILES should be applied before erroring out, |
946 | # to give a complete picture of the situation. | | 950 | # to give a complete picture of the situation. |
947 | | | 951 | |
948 | create_file_lines "testcase.mk" \ | | 952 | create_file_lines "testcase.mk" \ |
949 | 'SUBST_CLASSES+= id' \ | | 953 | 'SUBST_CLASSES+= id' \ |
950 | 'SUBST_STAGE.id= pre-configure' \ | | 954 | 'SUBST_STAGE.id= pre-configure' \ |
951 | 'SUBST_FILES.id= file1 file2' \ | | 955 | 'SUBST_FILES.id= file1 file2' \ |
952 | 'SUBST_VARS.id= A B' \ | | 956 | 'SUBST_VARS.id= A B' \ |
953 | 'SUBST_NOOP_OK.id= no' \ | | 957 | 'SUBST_NOOP_OK.id= no' \ |
954 | 'A= a-value' \ | | 958 | 'A= a-value' \ |
955 | 'B= b-value' \ | | 959 | 'B= b-value' \ |
956 | '' \ | | 960 | '' \ |
957 | '.include "prepare-subst.mk"' \ | | 961 | '.include "prepare-subst.mk"' \ |
958 | '.include "mk/subst.mk"' | | 962 | '.include "mk/subst.mk"' |
959 | create_file_lines "file1" "nothing to replace" | | 963 | create_file_lines "file1" "nothing to replace" |
960 | create_file_lines "file2" "nothing to replace" | | 964 | create_file_lines "file2" "nothing to replace" |
961 | | | 965 | |
962 | run_bmake "testcase.mk" "pre-configure" 1> "$tmpdir/out" 2>&1 \ | | 966 | run_bmake "testcase.mk" "pre-configure" 1> "$tmpdir/output" 2>&1 \ |
963 | && exitcode=0 || exitcode=$? | | 967 | && exitcode=0 || exitcode=$? |
964 | | | 968 | |
965 | assert_that "out" --file-is-lines \ | | 969 | assert_that "$tmpdir/output" --file-is-lines \ |
966 | '=> Substituting "id" in file1 file2' \ | | 970 | '=> Substituting "id" in file1 file2' \ |
967 | 'warning: [subst.mk:id] Nothing changed in "file1".' \ | | 971 | 'warning: [subst.mk:id] Nothing changed in "file1".' \ |
968 | 'warning: [subst.mk:id] Nothing changed in "file2".' \ | | 972 | 'warning: [subst.mk:id] Nothing changed in "file2".' \ |
969 | 'fail: [subst.mk:id] The filename patterns "file1 file2" have no effect.' \ | | 973 | 'fail: [subst.mk:id] The filename patterns "file1 file2" have no effect.' \ |
970 | '*** Error code 1' \ | | 974 | '*** Error code 1' \ |
971 | '' \ | | 975 | '' \ |
972 | 'Stop.' \ | | 976 | 'Stop.' \ |
973 | "$make: stopped in $PWD" | | 977 | "$make: stopped in $PWD" |
974 | | | 978 | |
975 | test_case_end | | 979 | test_case_end |
976 | fi | | 980 | fi |
977 | | | 981 | |
978 | | | 982 | |
| @@ -984,56 +988,56 @@ if test_case_begin "empty SUBST_FILES"; | | | @@ -984,56 +988,56 @@ if test_case_begin "empty SUBST_FILES"; |
984 | create_file_lines "testcase.mk" \ | | 988 | create_file_lines "testcase.mk" \ |
985 | 'SUBST_CLASSES+= id' \ | | 989 | 'SUBST_CLASSES+= id' \ |
986 | 'SUBST_STAGE.id= pre-configure' \ | | 990 | 'SUBST_STAGE.id= pre-configure' \ |
987 | 'SUBST_FILES.id= # none' \ | | 991 | 'SUBST_FILES.id= # none' \ |
988 | 'SUBST_SED.id= -e s,from,to,' \ | | 992 | 'SUBST_SED.id= -e s,from,to,' \ |
989 | 'SUBST_NOOP_OK.id= no' \ | | 993 | 'SUBST_NOOP_OK.id= no' \ |
990 | '' \ | | 994 | '' \ |
991 | 'all:' \ | | 995 | 'all:' \ |
992 | ' @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \ | | 996 | ' @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \ |
993 | '' \ | | 997 | '' \ |
994 | '.include "prepare-subst.mk"' \ | | 998 | '.include "prepare-subst.mk"' \ |
995 | '.include "mk/subst.mk"' | | 999 | '.include "mk/subst.mk"' |
996 | | | 1000 | |
997 | run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/out" 2>&1 \ | | 1001 | run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/output" 2>&1 \ |
998 | && exitcode=0 || exitcode=$? | | 1002 | && exitcode=0 || exitcode=$? |
999 | | | 1003 | |
1000 | assert_that "out" --file-is-lines \ | | 1004 | assert_that "$tmpdir/output" --file-is-lines \ |
1001 | '=> Substituting "id" in ' \ | | 1005 | '=> Substituting "id" in ' \ |
1002 | 'ok' | | 1006 | 'ok' |
1003 | | | 1007 | |
1004 | test_case_end | | 1008 | test_case_end |
1005 | fi | | 1009 | fi |
1006 | | | 1010 | |
1007 | | | 1011 | |
1008 | if test_case_begin "empty SUBST_SED"; then | | 1012 | if test_case_begin "empty SUBST_SED"; then |
1009 | | | 1013 | |
1010 | create_file_lines "testcase.mk" \ | | 1014 | create_file_lines "testcase.mk" \ |
1011 | 'SUBST_CLASSES+= id' \ | | 1015 | 'SUBST_CLASSES+= id' \ |
1012 | 'SUBST_STAGE.id= pre-configure' \ | | 1016 | 'SUBST_STAGE.id= pre-configure' \ |
1013 | 'SUBST_FILES.id= file' \ | | 1017 | 'SUBST_FILES.id= file' \ |
1014 | 'SUBST_SED.id= # none' \ | | 1018 | 'SUBST_SED.id= # none' \ |
1015 | 'SUBST_NOOP_OK.id= no' \ | | 1019 | 'SUBST_NOOP_OK.id= no' \ |
1016 | '' \ | | 1020 | '' \ |
1017 | 'all:' \ | | 1021 | 'all:' \ |
1018 | ' @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \ | | 1022 | ' @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \ |
1019 | '' \ | | 1023 | '' \ |
1020 | '.include "prepare-subst.mk"' \ | | 1024 | '.include "prepare-subst.mk"' \ |
1021 | '.include "mk/subst.mk"' | | 1025 | '.include "mk/subst.mk"' |
1022 | | | 1026 | |
1023 | run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/out" 2>&1 \ | | 1027 | run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/output" 2>&1 \ |
1024 | && exitcode=0 || exitcode=$? | | 1028 | && exitcode=0 || exitcode=$? |
1025 | | | 1029 | |
1026 | assert_that "out" --file-is-lines \ | | 1030 | assert_that "$tmpdir/output" --file-is-lines \ |
1027 | '=> Substituting "id" in file' \ | | 1031 | '=> Substituting "id" in file' \ |
1028 | 'warning: [subst.mk:id] Ignoring nonexistent file "file".' \ | | 1032 | 'warning: [subst.mk:id] Ignoring nonexistent file "file".' \ |
1029 | 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ | | 1033 | 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ |
1030 | '*** Error code 1' \ | | 1034 | '*** Error code 1' \ |
1031 | '' \ | | 1035 | '' \ |
1032 | 'Stop.' \ | | 1036 | 'Stop.' \ |
1033 | "$make: stopped in $PWD" | | 1037 | "$make: stopped in $PWD" |
1034 | | | 1038 | |
1035 | test_case_end | | 1039 | test_case_end |
1036 | fi | | 1040 | fi |
1037 | | | 1041 | |
1038 | | | 1042 | |
1039 | if test_case_begin "typo in SUBST_CLASSES"; then | | 1043 | if test_case_begin "typo in SUBST_CLASSES"; then |
| @@ -1044,30 +1048,30 @@ if test_case_begin "typo in SUBST_CLASSE | | | @@ -1044,30 +1048,30 @@ if test_case_begin "typo in SUBST_CLASSE |
1044 | create_file_lines "testcase.mk" \ | | 1048 | create_file_lines "testcase.mk" \ |
1045 | 'SUBST_CLASSES=+ id' \ | | 1049 | 'SUBST_CLASSES=+ id' \ |
1046 | 'SUBST_STAGE.id= pre-configure' \ | | 1050 | 'SUBST_STAGE.id= pre-configure' \ |
1047 | 'SUBST_FILES.id= file' \ | | 1051 | 'SUBST_FILES.id= file' \ |
1048 | 'SUBST_SED.id= # none' \ | | 1052 | 'SUBST_SED.id= # none' \ |
1049 | 'SUBST_NOOP_OK.id= no' \ | | 1053 | 'SUBST_NOOP_OK.id= no' \ |
1050 | '' \ | | 1054 | '' \ |
1051 | 'all:' \ | | 1055 | 'all:' \ |
1052 | ' @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \ | | 1056 | ' @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \ |
1053 | '' \ | | 1057 | '' \ |
1054 | '.include "prepare-subst.mk"' \ | | 1058 | '.include "prepare-subst.mk"' \ |
1055 | '.include "mk/subst.mk"' | | 1059 | '.include "mk/subst.mk"' |
1056 | | | 1060 | |
1057 | run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/out" 2>&1 \ | | 1061 | run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/output" 2>&1 \ |
1058 | && exitcode=0 || exitcode=$? | | 1062 | && exitcode=0 || exitcode=$? |
1059 | | | 1063 | |
1060 | assert_that "out" --file-is-lines \ | | 1064 | assert_that "$tmpdir/output" --file-is-lines \ |
1061 | '=> Substituting "id" in file' \ | | 1065 | '=> Substituting "id" in file' \ |
1062 | 'warning: [subst.mk:id] Ignoring nonexistent file "file".' \ | | 1066 | 'warning: [subst.mk:id] Ignoring nonexistent file "file".' \ |
1063 | 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ | | 1067 | 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ |
1064 | '*** Error code 1' \ | | 1068 | '*** Error code 1' \ |
1065 | '' \ | | 1069 | '' \ |
1066 | 'Stop.' \ | | 1070 | 'Stop.' \ |
1067 | "$make: stopped in $PWD" | | 1071 | "$make: stopped in $PWD" |
1068 | | | 1072 | |
1069 | test_case_end | | 1073 | test_case_end |
1070 | fi | | 1074 | fi |
1071 | | | 1075 | |
1072 | | | 1076 | |
1073 | if test_case_begin "executable bit is preserved"; then | | 1077 | if test_case_begin "executable bit is preserved"; then |
| @@ -1075,62 +1079,62 @@ if test_case_begin "executable bit is pr | | | @@ -1075,62 +1079,62 @@ if test_case_begin "executable bit is pr |
1075 | create_file_lines "testcase.mk" \ | | 1079 | create_file_lines "testcase.mk" \ |
1076 | 'SUBST_CLASSES+= id' \ | | 1080 | 'SUBST_CLASSES+= id' \ |
1077 | 'SUBST_STAGE.id= pre-configure' \ | | 1081 | 'SUBST_STAGE.id= pre-configure' \ |
1078 | 'SUBST_FILES.id= cmd data' \ | | 1082 | 'SUBST_FILES.id= cmd data' \ |
1079 | 'SUBST_VARS.id= VAR' \ | | 1083 | 'SUBST_VARS.id= VAR' \ |
1080 | 'VAR= replaced' \ | | 1084 | 'VAR= replaced' \ |
1081 | '' \ | | 1085 | '' \ |
1082 | '.include "prepare-subst.mk"' \ | | 1086 | '.include "prepare-subst.mk"' \ |
1083 | '.include "mk/subst.mk"' | | 1087 | '.include "mk/subst.mk"' |
1084 | create_file_lines "cmd" \ | | 1088 | create_file_lines "cmd" \ |
1085 | '@VAR@' | | 1089 | '@VAR@' |
1086 | create_file_lines "data" \ | | 1090 | create_file_lines "data" \ |
1087 | '@VAR@' | | 1091 | '@VAR@' |
1088 | chmod +x "$tmpdir/cmd" | | 1092 | chmod +x 'cmd' |
1089 | | | 1093 | |
1090 | run_bmake "testcase.mk" "pre-configure" 1> "$tmpdir/out" 2>&1 \ | | 1094 | run_bmake "testcase.mk" "pre-configure" 1> "$tmpdir/output" 2>&1 \ |
1091 | && exitcode=0 || exitcode=$? | | 1095 | && exitcode=0 || exitcode=$? |
1092 | | | 1096 | |
1093 | assert_that "out" --file-is-lines \ | | 1097 | assert_that "$tmpdir/output" --file-is-lines \ |
1094 | '=> Substituting "id" in cmd data' | | 1098 | '=> Substituting "id" in cmd data' |
1095 | assert_that "cmd" --file-is-lines "replaced" | | 1099 | assert_that "cmd" --file-is-lines "replaced" |
1096 | assert_that "data" --file-is-lines "replaced" | | 1100 | assert_that "data" --file-is-lines "replaced" |
1097 | [ -x "$tmpdir/cmd" ] \ | | 1101 | [ -x 'cmd' ] \ |
1098 | || assert_fail "cmd must still be executable" | | 1102 | || assert_fail 'cmd must still be executable\n' |
1099 | [ -x "$tmpdir/data" ] \ | | 1103 | [ -x 'data' ] \ |
1100 | && assert_fail "data must not be executable" | | 1104 | && assert_fail 'data must not be executable\n' |
1101 | | | 1105 | |
1102 | test_case_end | | 1106 | test_case_end |
1103 | fi | | 1107 | fi |
1104 | | | 1108 | |
1105 | | | 1109 | |
1106 | if test_case_begin "unreadable file"; then | | 1110 | if test_case_begin "unreadable file"; then |
1107 | | | 1111 | |
1108 | create_file_lines "testcase.mk" \ | | 1112 | create_file_lines "testcase.mk" \ |
1109 | 'SUBST_CLASSES+= id' \ | | 1113 | 'SUBST_CLASSES+= id' \ |
1110 | 'SUBST_STAGE.id= pre-configure' \ | | 1114 | 'SUBST_STAGE.id= pre-configure' \ |
1111 | 'SUBST_FILES.id= unreadable-file' \ | | 1115 | 'SUBST_FILES.id= unreadable-file' \ |
1112 | 'SUBST_SED.id= -e s,before,after,' \ | | 1116 | 'SUBST_SED.id= -e s,before,after,' \ |
1113 | '' \ | | 1117 | '' \ |
1114 | '.include "prepare-subst.mk"' \ | | 1118 | '.include "prepare-subst.mk"' \ |
1115 | '.include "mk/subst.mk"' | | 1119 | '.include "mk/subst.mk"' |
1116 | create_file_lines "unreadable-file" \ | | 1120 | create_file_lines "unreadable-file" \ |
1117 | 'before' | | 1121 | 'before' |
1118 | chmod 0000 "$tmpdir/unreadable-file" | | 1122 | chmod 0000 'unreadable-file' |
1119 | | | 1123 | |
1120 | run_bmake "testcase.mk" "pre-configure" 1> "$tmpdir/out" 2>&1 \ | | 1124 | run_bmake "testcase.mk" "pre-configure" 1> "$tmpdir/output" 2>&1 \ |
1121 | && exitcode=0 || exitcode=$? | | 1125 | && exitcode=0 || exitcode=$? |
1122 | | | 1126 | |
1123 | assert_that "out" --file-is-lines \ | | 1127 | assert_that "$tmpdir/output" --file-is-lines \ |
1124 | '=> Substituting "id" in unreadable-file' \ | | 1128 | '=> Substituting "id" in unreadable-file' \ |
1125 | 'sh: cannot open unreadable-file: permission denied' \ | | 1129 | 'sh: cannot open unreadable-file: permission denied' \ |
1126 | 'sh: cannot open unreadable-file: permission denied' \ | | 1130 | 'sh: cannot open unreadable-file: permission denied' \ |
1127 | '*** Error code 1' \ | | 1131 | '*** Error code 1' \ |
1128 | '' \ | | 1132 | '' \ |
1129 | 'Stop.' \ | | 1133 | 'Stop.' \ |
1130 | "$make: stopped in $PWD" | | 1134 | "$make: stopped in $PWD" |
1131 | | | 1135 | |
1132 | test_case_end | | 1136 | test_case_end |
1133 | fi | | 1137 | fi |
1134 | | | 1138 | |
1135 | | | 1139 | |
1136 | if test_case_begin "identity substitution implementation"; then | | 1140 | if test_case_begin "identity substitution implementation"; then |
| @@ -1243,83 +1247,83 @@ if test_case_begin "identity substitutio | | | @@ -1243,83 +1247,83 @@ if test_case_begin "identity substitutio |
1243 | create_file_lines "testcase.mk" \ | | 1247 | create_file_lines "testcase.mk" \ |
1244 | 'SUBST_CLASSES+= id' \ | | 1248 | 'SUBST_CLASSES+= id' \ |
1245 | 'SUBST_FILES.id= file' \ | | 1249 | 'SUBST_FILES.id= file' \ |
1246 | 'SUBST_SED.id= -e s,before,before,' \ | | 1250 | 'SUBST_SED.id= -e s,before,before,' \ |
1247 | 'SUBST_SED.id+= -e "s,before,before,"' \ | | 1251 | 'SUBST_SED.id+= -e "s,before,before,"' \ |
1248 | "SUBST_SED.id+= -e 's,before,before,'" \ | | 1252 | "SUBST_SED.id+= -e 's,before,before,'" \ |
1249 | 'SUBST_NOOP_OK.id= no' \ | | 1253 | 'SUBST_NOOP_OK.id= no' \ |
1250 | '' \ | | 1254 | '' \ |
1251 | '.include "prepare-subst.mk"' \ | | 1255 | '.include "prepare-subst.mk"' \ |
1252 | '.include "mk/subst.mk"' | | 1256 | '.include "mk/subst.mk"' |
1253 | create_file_lines "file" \ | | 1257 | create_file_lines "file" \ |
1254 | 'before' | | 1258 | 'before' |
1255 | | | 1259 | |
1256 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/out" 2>&1 \ | | 1260 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/output" 2>&1 \ |
1257 | && exitcode=0 || exitcode=$? | | 1261 | && exitcode=0 || exitcode=$? |
1258 | | | 1262 | |
1259 | assert_that "out" --file-is-lines \ | | 1263 | assert_that "$tmpdir/output" --file-is-lines \ |
1260 | '=> Substituting "id" in file' | | 1264 | '=> Substituting "id" in file' |
1261 | | | 1265 | |
1262 | test_case_end | | 1266 | test_case_end |
1263 | fi | | 1267 | fi |
1264 | | | 1268 | |
1265 | | | 1269 | |
1266 | if test_case_begin "identity substitution, not found in file"; then | | 1270 | if test_case_begin "identity substitution, not found in file"; then |
1267 | | | 1271 | |
1268 | create_file_lines "testcase.mk" \ | | 1272 | create_file_lines "testcase.mk" \ |
1269 | 'SUBST_CLASSES+= id' \ | | 1273 | 'SUBST_CLASSES+= id' \ |
1270 | 'SUBST_FILES.id= file' \ | | 1274 | 'SUBST_FILES.id= file' \ |
1271 | 'SUBST_SED.id= s,before,before,' \ | | 1275 | 'SUBST_SED.id= s,before,before,' \ |
1272 | 'SUBST_NOOP_OK.id= no' \ | | 1276 | 'SUBST_NOOP_OK.id= no' \ |
1273 | '' \ | | 1277 | '' \ |
1274 | '.include "prepare-subst.mk"' \ | | 1278 | '.include "prepare-subst.mk"' \ |
1275 | '.include "mk/subst.mk"' | | 1279 | '.include "mk/subst.mk"' |
1276 | create_file_lines "file" \ | | 1280 | create_file_lines "file" \ |
1277 | 'other' | | 1281 | 'other' |
1278 | | | 1282 | |
1279 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/out" 2>&1 \ | | 1283 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/output" 2>&1 \ |
1280 | && exitcode=0 || exitcode=$? | | 1284 | && exitcode=0 || exitcode=$? |
1281 | | | 1285 | |
1282 | assert_that "out" --file-is-lines \ | | 1286 | assert_that "$tmpdir/output" --file-is-lines \ |
1283 | '=> Substituting "id" in file' \ | | 1287 | '=> Substituting "id" in file' \ |
1284 | 'warning: [subst.mk:id] Nothing changed in "file".' \ | | 1288 | 'warning: [subst.mk:id] Nothing changed in "file".' \ |
1285 | 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ | | 1289 | 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ |
1286 | '*** Error code 1' \ | | 1290 | '*** Error code 1' \ |
1287 | '' \ | | 1291 | '' \ |
1288 | 'Stop.' \ | | 1292 | 'Stop.' \ |
1289 | "$make: stopped in $PWD" | | 1293 | "$make: stopped in $PWD" |
1290 | | | 1294 | |
1291 | test_case_end | | 1295 | test_case_end |
1292 | fi | | 1296 | fi |
1293 | | | 1297 | |
1294 | | | 1298 | |
1295 | if test_case_begin "identity + effective substitution"; then | | 1299 | if test_case_begin "identity + effective substitution"; then |
1296 | | | 1300 | |
1297 | create_file_lines "testcase.mk" \ | | 1301 | create_file_lines "testcase.mk" \ |
1298 | 'SUBST_CLASSES+= id' \ | | 1302 | 'SUBST_CLASSES+= id' \ |
1299 | 'SUBST_FILES.id= file' \ | | 1303 | 'SUBST_FILES.id= file' \ |
1300 | 'SUBST_SED.id= -e s,no-op,no-op,g' \ | | 1304 | 'SUBST_SED.id= -e s,no-op,no-op,g' \ |
1301 | 'SUBST_SED.id+= -e s,from,to,' \ | | 1305 | 'SUBST_SED.id+= -e s,from,to,' \ |
1302 | 'SUBST_NOOP_OK.id= no' \ | | 1306 | 'SUBST_NOOP_OK.id= no' \ |
1303 | '' \ | | 1307 | '' \ |
1304 | '.include "prepare-subst.mk"' \ | | 1308 | '.include "prepare-subst.mk"' \ |
1305 | '.include "mk/subst.mk"' | | 1309 | '.include "mk/subst.mk"' |
1306 | create_file_lines "file" \ | | 1310 | create_file_lines "file" \ |
1307 | 'from' | | 1311 | 'from' |
1308 | | | 1312 | |
1309 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/out" 2>&1 \ | | 1313 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/output" 2>&1 \ |
1310 | && exitcode=0 || exitcode=$? | | 1314 | && exitcode=0 || exitcode=$? |
1311 | | | 1315 | |
1312 | assert_that "out" --file-is-lines \ | | 1316 | assert_that "$tmpdir/output" --file-is-lines \ |
1313 | '=> Substituting "id" in file' | | 1317 | '=> Substituting "id" in file' |
1314 | assert_that "file" --file-is-lines \ | | 1318 | assert_that "file" --file-is-lines \ |
1315 | 'to' | | 1319 | 'to' |
1316 | | | 1320 | |
1317 | test_case_end | | 1321 | test_case_end |
1318 | fi | | 1322 | fi |
1319 | | | 1323 | |
1320 | | | 1324 | |
1321 | if test_case_begin "identity + no-op substitution"; then | | 1325 | if test_case_begin "identity + no-op substitution"; then |
1322 | | | 1326 | |
1323 | # If there were only an identity substitution, it wouldn't be an | | 1327 | # If there were only an identity substitution, it wouldn't be an |
1324 | # error. But since there is a regular substitution as well, | | 1328 | # error. But since there is a regular substitution as well, |
1325 | # that substitution is an unexpected no-op and is therefore | | 1329 | # that substitution is an unexpected no-op and is therefore |
| @@ -1327,30 +1331,30 @@ if test_case_begin "identity + no-op sub | | | @@ -1327,30 +1331,30 @@ if test_case_begin "identity + no-op sub |
1327 | | | 1331 | |
1328 | create_file_lines "testcase.mk" \ | | 1332 | create_file_lines "testcase.mk" \ |
1329 | 'SUBST_CLASSES+= id' \ | | 1333 | 'SUBST_CLASSES+= id' \ |
1330 | 'SUBST_FILES.id= file' \ | | 1334 | 'SUBST_FILES.id= file' \ |
1331 | 'SUBST_SED.id= -e s,no-op,no-op,g' \ | | 1335 | 'SUBST_SED.id= -e s,no-op,no-op,g' \ |
1332 | 'SUBST_SED.id+= -e s,from,to,' \ | | 1336 | 'SUBST_SED.id+= -e s,from,to,' \ |
1333 | 'SUBST_NOOP_OK.id= no' \ | | 1337 | 'SUBST_NOOP_OK.id= no' \ |
1334 | '' \ | | 1338 | '' \ |
1335 | '.include "prepare-subst.mk"' \ | | 1339 | '.include "prepare-subst.mk"' \ |
1336 | '.include "mk/subst.mk"' | | 1340 | '.include "mk/subst.mk"' |
1337 | create_file_lines "file" \ | | 1341 | create_file_lines "file" \ |
1338 | 'other' | | 1342 | 'other' |
1339 | | | 1343 | |
1340 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/out" 2>&1 \ | | 1344 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/output" 2>&1 \ |
1341 | && exitcode=0 || exitcode=$? | | 1345 | && exitcode=0 || exitcode=$? |
1342 | | | 1346 | |
1343 | assert_that "out" --file-is-lines \ | | 1347 | assert_that "$tmpdir/output" --file-is-lines \ |
1344 | '=> Substituting "id" in file' \ | | 1348 | '=> Substituting "id" in file' \ |
1345 | 'warning: [subst.mk:id] Nothing changed in "file".' \ | | 1349 | 'warning: [subst.mk:id] Nothing changed in "file".' \ |
1346 | 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ | | 1350 | 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ |
1347 | '*** Error code 1' \ | | 1351 | '*** Error code 1' \ |
1348 | '' \ | | 1352 | '' \ |
1349 | 'Stop.' \ | | 1353 | 'Stop.' \ |
1350 | "$make: stopped in $PWD" | | 1354 | "$make: stopped in $PWD" |
1351 | assert_that "file" --file-is-lines \ | | 1355 | assert_that "file" --file-is-lines \ |
1352 | 'other' | | 1356 | 'other' |
1353 | | | 1357 | |
1354 | test_case_end | | 1358 | test_case_end |
1355 | fi | | 1359 | fi |
1356 | | | 1360 | |
| @@ -1362,90 +1366,90 @@ if test_case_begin "SUBST_FILTER_CMD + S | | | @@ -1362,90 +1366,90 @@ if test_case_begin "SUBST_FILTER_CMD + S |
1362 | # redundant variable definitions, this case fails fast. | | 1366 | # redundant variable definitions, this case fails fast. |
1363 | | | 1367 | |
1364 | create_file_lines "testcase.mk" \ | | 1368 | create_file_lines "testcase.mk" \ |
1365 | 'SUBST_CLASSES+= id' \ | | 1369 | 'SUBST_CLASSES+= id' \ |
1366 | 'SUBST_FILES.id= file' \ | | 1370 | 'SUBST_FILES.id= file' \ |
1367 | 'SUBST_FILTER_CMD.id= tr -d "0-9"' \ | | 1371 | 'SUBST_FILTER_CMD.id= tr -d "0-9"' \ |
1368 | 'SUBST_SED.id= -e s,x,x,' \ | | 1372 | 'SUBST_SED.id= -e s,x,x,' \ |
1369 | 'SUBST_NOOP_OK.id= no' \ | | 1373 | 'SUBST_NOOP_OK.id= no' \ |
1370 | '' \ | | 1374 | '' \ |
1371 | '.include "prepare-subst.mk"' \ | | 1375 | '.include "prepare-subst.mk"' \ |
1372 | '.include "mk/subst.mk"' | | 1376 | '.include "mk/subst.mk"' |
1373 | create_file_lines "file" \ | | 1377 | create_file_lines "file" \ |
1374 | 'letters 123 letters' | | 1378 | 'letters 123 letters' |
1375 | create_file_lines "main.mk" \ | | 1379 | create_file_lines "$tmpdir/main.mk" \ |
1376 | "PKGSRCDIR= $pkgsrcdir" \ | | 1380 | "PKGSRCDIR= $pkgsrcdir" \ |
1377 | ".PATH: $mocked_pkgsrcdir" \ | | 1381 | ".PATH: $mocked_pkgsrcdir" \ |
1378 | ".PATH: $pkgsrcdir" \ | | 1382 | ".PATH: $pkgsrcdir" \ |
1379 | ".include \"testcase.mk\"" \ | | 1383 | ".include \"testcase.mk\"" \ |
1380 | '' \ | | 1384 | '' \ |
1381 | 'all: subst-id' \ | | 1385 | 'all: subst-id' \ |
1382 | ' @printf '\''fail reason: %s\n'\'' ${PKG_FAIL_REASON} 1>&2' | | 1386 | ' @printf '\''fail reason: %s\n'\'' ${PKG_FAIL_REASON} 1>&2' |
1383 | | | 1387 | |
1384 | "$make" -f "$tmpdir/main.mk" "all" 1> "$tmpdir/out" 2>&1 \ | | 1388 | "$make" -f "$tmpdir/main.mk" "all" 1> "$tmpdir/output" 2>&1 \ |
1385 | && exitcode=0 || exitcode=$? | | 1389 | && exitcode=0 || exitcode=$? |
1386 | | | 1390 | |
1387 | assert_that "out" --file-is-lines \ | | 1391 | assert_that "$tmpdir/output" --file-is-lines \ |
1388 | '=> Substituting "id" in file' \ | | 1392 | '=> Substituting "id" in file' \ |
1389 | 'fail reason: [subst.mk:id] SUBST_FILTER_CMD and SUBST_SED/SUBST_VARS cannot be combined.' | | 1393 | 'fail reason: [subst.mk:id] SUBST_FILTER_CMD and SUBST_SED/SUBST_VARS cannot be combined.' |
1390 | assert_that "file" --file-is-lines \ | | 1394 | assert_that "file" --file-is-lines \ |
1391 | 'letters letters' | | 1395 | 'letters letters' |
1392 | | | 1396 | |
1393 | test_case_end | | 1397 | test_case_end |
1394 | fi | | 1398 | fi |
1395 | | | 1399 | |
1396 | | | 1400 | |
1397 | if test_case_begin "effective SUBST_FILTER_CMD in NOOP_OK=no mode"; then | | 1401 | if test_case_begin "effective SUBST_FILTER_CMD in NOOP_OK=no mode"; then |
1398 | | | 1402 | |
1399 | create_file_lines "testcase.mk" \ | | 1403 | create_file_lines "testcase.mk" \ |
1400 | 'SUBST_CLASSES+= id' \ | | 1404 | 'SUBST_CLASSES+= id' \ |
1401 | 'SUBST_FILES.id= file' \ | | 1405 | 'SUBST_FILES.id= file' \ |
1402 | 'SUBST_FILTER_CMD.id= tr -d "0-9"' \ | | 1406 | 'SUBST_FILTER_CMD.id= tr -d "0-9"' \ |
1403 | 'SUBST_NOOP_OK.id= no' \ | | 1407 | 'SUBST_NOOP_OK.id= no' \ |
1404 | '' \ | | 1408 | '' \ |
1405 | '.include "prepare-subst.mk"' \ | | 1409 | '.include "prepare-subst.mk"' \ |
1406 | '.include "mk/subst.mk"' | | 1410 | '.include "mk/subst.mk"' |
1407 | create_file_lines "file" \ | | 1411 | create_file_lines "file" \ |
1408 | 'letters 123 letters' | | 1412 | 'letters 123 letters' |
1409 | | | 1413 | |
1410 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/out" 2>&1 \ | | 1414 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/output" 2>&1 \ |
1411 | && exitcode=0 || exitcode=$? | | 1415 | && exitcode=0 || exitcode=$? |
1412 | | | 1416 | |
1413 | assert_that "out" --file-is-lines \ | | 1417 | assert_that "$tmpdir/output" --file-is-lines \ |
1414 | '=> Substituting "id" in file' | | 1418 | '=> Substituting "id" in file' |
1415 | assert_that "file" --file-is-lines \ | | 1419 | assert_that "file" --file-is-lines \ |
1416 | 'letters letters' | | 1420 | 'letters letters' |
1417 | | | 1421 | |
1418 | test_case_end | | 1422 | test_case_end |
1419 | fi | | 1423 | fi |
1420 | | | 1424 | |
1421 | | | 1425 | |
1422 | if test_case_begin "no-op SUBST_FILTER_CMD in NOOP_OK=no mode"; then | | 1426 | if test_case_begin "no-op SUBST_FILTER_CMD in NOOP_OK=no mode"; then |
1423 | | | 1427 | |
1424 | create_file_lines "testcase.mk" \ | | 1428 | create_file_lines "testcase.mk" \ |
1425 | 'SUBST_CLASSES+= id' \ | | 1429 | 'SUBST_CLASSES+= id' \ |
1426 | 'SUBST_FILES.id= file' \ | | 1430 | 'SUBST_FILES.id= file' \ |
1427 | 'SUBST_FILTER_CMD.id= tr -d "0-9"' \ | | 1431 | 'SUBST_FILTER_CMD.id= tr -d "0-9"' \ |
1428 | 'SUBST_NOOP_OK.id= no' \ | | 1432 | 'SUBST_NOOP_OK.id= no' \ |
1429 | '' \ | | 1433 | '' \ |
1430 | '.include "prepare-subst.mk"' \ | | 1434 | '.include "prepare-subst.mk"' \ |
1431 | '.include "mk/subst.mk"' | | 1435 | '.include "mk/subst.mk"' |
1432 | create_file_lines "file" \ | | 1436 | create_file_lines "file" \ |
1433 | 'only letters' | | 1437 | 'only letters' |
1434 | | | 1438 | |
1435 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/out" 2>&1 \ | | 1439 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/output" 2>&1 \ |
1436 | && exitcode=0 || exitcode=$? | | 1440 | && exitcode=0 || exitcode=$? |
1437 | | | 1441 | |
1438 | assert_that "out" --file-is-lines \ | | 1442 | assert_that "$tmpdir/output" --file-is-lines \ |
1439 | '=> Substituting "id" in file' \ | | 1443 | '=> Substituting "id" in file' \ |
1440 | 'warning: [subst.mk:id] Nothing changed in "file".' \ | | 1444 | 'warning: [subst.mk:id] Nothing changed in "file".' \ |
1441 | 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ | | 1445 | 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ |
1442 | '*** Error code 1' \ | | 1446 | '*** Error code 1' \ |
1443 | '' \ | | 1447 | '' \ |
1444 | 'Stop.' \ | | 1448 | 'Stop.' \ |
1445 | "$make: stopped in $PWD" | | 1449 | "$make: stopped in $PWD" |
1446 | | | 1450 | |
1447 | assert_that "file" --file-is-lines \ | | 1451 | assert_that "file" --file-is-lines \ |
1448 | 'only letters' | | 1452 | 'only letters' |
1449 | | | 1453 | |
1450 | test_case_end | | 1454 | test_case_end |
1451 | fi | | 1455 | fi |
| @@ -1453,55 +1457,55 @@ fi | | | @@ -1453,55 +1457,55 @@ fi |
1453 | | | 1457 | |
1454 | if test_case_begin "backtick in SUBST_SED"; then | | 1458 | if test_case_begin "backtick in SUBST_SED"; then |
1455 | | | 1459 | |
1456 | create_file_lines "testcase.mk" \ | | 1460 | create_file_lines "testcase.mk" \ |
1457 | 'SUBST_CLASSES+= id' \ | | 1461 | 'SUBST_CLASSES+= id' \ |
1458 | 'SUBST_FILES.id= file' \ | | 1462 | 'SUBST_FILES.id= file' \ |
1459 | "SUBST_SED.id= -e 's,\"\\\\\`,\"\\\\\`,'" \ | | 1463 | "SUBST_SED.id= -e 's,\"\\\\\`,\"\\\\\`,'" \ |
1460 | '' \ | | 1464 | '' \ |
1461 | '.include "prepare-subst.mk"' \ | | 1465 | '.include "prepare-subst.mk"' \ |
1462 | '.include "mk/subst.mk"' | | 1466 | '.include "mk/subst.mk"' |
1463 | create_file_lines "file" \ | | 1467 | create_file_lines "file" \ |
1464 | 'from`' | | 1468 | 'from`' |
1465 | | | 1469 | |
1466 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/out" 2>&1 \ | | 1470 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/output" 2>&1 \ |
1467 | && exitcode=0 || exitcode=$? | | 1471 | && exitcode=0 || exitcode=$? |
1468 | | | 1472 | |
1469 | assert_that "out" --file-is-lines \ | | 1473 | assert_that "$tmpdir/output" --file-is-lines \ |
1470 | '=> Substituting "id" in file' \ | | 1474 | '=> Substituting "id" in file' \ |
1471 | 'info: [subst.mk:id] Nothing changed in "file".' | | 1475 | 'info: [subst.mk:id] Nothing changed in "file".' |
1472 | | | 1476 | |
1473 | test_case_end | | 1477 | test_case_end |
1474 | fi | | 1478 | fi |
1475 | | | 1479 | |
1476 | | | 1480 | |
1477 | if test_case_begin "multiple sed commands with semicolon"; then | | 1481 | if test_case_begin "multiple sed commands with semicolon"; then |
1478 | | | 1482 | |
1479 | # From PR pkg/55226: | | 1483 | # From PR pkg/55226: |
1480 | # ===> Configuring for perl-5.30.2 | | 1484 | # ===> Configuring for perl-5.30.2 |
1481 | # sh: 1: Syntax error: Word "/d"p" unexpected (expecting ")") | | 1485 | # sh: 1: Syntax error: Word "/d"p" unexpected (expecting ")") |
1482 | | | 1486 | |
1483 | create_file_lines "testcase.mk" \ | | 1487 | create_file_lines "testcase.mk" \ |
1484 | 'SUBST_CLASSES+= id' \ | | 1488 | 'SUBST_CLASSES+= id' \ |
1485 | 'SUBST_FILES.id= file' \ | | 1489 | 'SUBST_FILES.id= file' \ |
1486 | 'SUBST_SED.id= -e "s/755/755/g;/umask(/d"' \ | | 1490 | 'SUBST_SED.id= -e "s/755/755/g;/umask(/d"' \ |
1487 | 'SUBST_NOOP_OK.id= no' \ | | 1491 | 'SUBST_NOOP_OK.id= no' \ |
1488 | '' \ | | 1492 | '' \ |
1489 | '.include "prepare-subst.mk"' \ | | 1493 | '.include "prepare-subst.mk"' \ |
1490 | '.include "mk/subst.mk"' | | 1494 | '.include "mk/subst.mk"' |
1491 | create_file_lines "file" \ | | 1495 | create_file_lines "file" \ |
1492 | '$mode = 755;' | | 1496 | '$mode = 755;' |
1493 | | | 1497 | |
1494 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/out" 2>&1 \ | | 1498 | run_bmake "testcase.mk" "subst-id" 1> "$tmpdir/output" 2>&1 \ |
1495 | && exitcode=0 || exitcode=$? | | 1499 | && exitcode=0 || exitcode=$? |
1496 | | | 1500 | |
1497 | assert_that "out" --file-is-lines \ | | 1501 | assert_that "$tmpdir/output" --file-is-lines \ |
1498 | '=> Substituting "id" in file' \ | | 1502 | '=> Substituting "id" in file' \ |
1499 | 'warning: [subst.mk:id] Nothing changed in "file".' \ | | 1503 | 'warning: [subst.mk:id] Nothing changed in "file".' \ |
1500 | 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ | | 1504 | 'fail: [subst.mk:id] The filename pattern "file" has no effect.' \ |
1501 | '*** Error code 1' \ | | 1505 | '*** Error code 1' \ |
1502 | '' \ | | 1506 | '' \ |
1503 | 'Stop.' \ | | 1507 | 'Stop.' \ |
1504 | "$make: stopped in $PWD" | | 1508 | "$make: stopped in $PWD" |
1505 | | | 1509 | |
1506 | test_case_end | | 1510 | test_case_end |
1507 | fi | | 1511 | fi |