| @@ -1,21 +1,31 @@ | | | @@ -1,21 +1,31 @@ |
1 | # $NetBSD: dep-duplicate.mk,v 1.1 2022/01/19 22:10:41 rillig Exp $ | | 1 | # $NetBSD: dep-duplicate.mk,v 1.2 2022/01/20 19:16:25 rillig Exp $ |
2 | # | | 2 | # |
3 | # Test for a target whose commands are defined twice. This generates a | | 3 | # Test for a target whose commands are defined twice. This generates a |
4 | # warning, not an error, so ensure that the correct commands are kept. | | 4 | # warning, not an error, so ensure that the correct commands are kept. |
5 | # | | 5 | # |
6 | # Also ensure that the diagnostics mention the correct file in case of | | 6 | # Also ensure that the diagnostics mention the correct file in case of |
7 | # included files. This particular case had been broken in parse.c 1.231 from | | 7 | # included files. Since parse.c 1.231 from 2018-12-22 and before parse.c |
8 | # 2018-12-22. | | 8 | # 1.653 from 2022-01-20, the wrong filename had been printed if the file of |
| | | 9 | # the first commands section was in a file that was included by its relative |
| | | 10 | # path. |
9 | | | 11 | |
10 | # expect: make: "dep-duplicate.inc" line 15: warning: using previous script for "all" defined here | | 12 | # expect: make: "dep-duplicate.inc" line 3: warning: using previous script for "all" defined here |
11 | # FIXME: The file "dep-duplicate.inc" has no line 15. | | 13 | # FIXME: The file "dep-duplicate.inc" has no line 3. |
12 | | | 14 | |
13 | # expect: first | | | |
14 | all: .PHONY | | 15 | all: .PHONY |
15 | @echo first | | 16 | @exec > dep-duplicate.main; \ |
| | | 17 | echo '# empty line 1'; \ |
| | | 18 | echo '# empty line 2'; \ |
| | | 19 | echo 'all:; @echo main-output'; \ |
| | | 20 | echo '.include "dep-duplicate.inc"' |
16 | | | 21 | |
17 | _!= echo 'all:;echo second' > dep-duplicate.inc | | 22 | @exec > dep-duplicate.inc; \ |
18 | .include "${.CURDIR}/dep-duplicate.inc" | | 23 | echo 'all:; @echo inc-output' |
19 | | | 24 | |
20 | .END: | | 25 | # The main file must be specified using a relative path, just like the |
| | | 26 | # default 'makefile' or 'Makefile', to produce the same result when |
| | | 27 | # run via ATF or 'make test'. |
| | | 28 | @${MAKE} -r -f dep-duplicate.main |
| | | 29 | |
| | | 30 | @rm -f dep-duplicate.main |
21 | @rm -f dep-duplicate.inc | | 31 | @rm -f dep-duplicate.inc |