aboutsummaryrefslogtreecommitdiff
path: root/contrib/bmake/unit-tests/dep-duplicate.mk
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bmake/unit-tests/dep-duplicate.mk')
-rw-r--r--contrib/bmake/unit-tests/dep-duplicate.mk27
1 files changed, 27 insertions, 0 deletions
diff --git a/contrib/bmake/unit-tests/dep-duplicate.mk b/contrib/bmake/unit-tests/dep-duplicate.mk
new file mode 100644
index 000000000000..6f64ba1c1981
--- /dev/null
+++ b/contrib/bmake/unit-tests/dep-duplicate.mk
@@ -0,0 +1,27 @@
+# $NetBSD: dep-duplicate.mk,v 1.3 2022/01/20 19:24:53 rillig Exp $
+#
+# Test for a target whose commands are defined twice. This generates a
+# warning, not an error, so ensure that the correct commands are kept.
+#
+# Also ensure that the diagnostics mention the correct file in case of
+# included files. Since parse.c 1.231 from 2018-12-22 and before parse.c
+# 1.653 from 2022-01-20, the wrong filename had been printed if the file of
+# the first commands section was included by its relative path.
+
+all: .PHONY
+ @exec > dep-duplicate.main; \
+ echo '# empty line 1'; \
+ echo '# empty line 2'; \
+ echo 'all:; @echo main-output'; \
+ echo '.include "dep-duplicate.inc"'
+
+ @exec > dep-duplicate.inc; \
+ echo 'all:; @echo inc-output'
+
+ # The main file must be specified using a relative path, just like the
+ # default 'makefile' or 'Makefile', to produce the same result when
+ # run via ATF or 'make test'.
+ @${MAKE} -r -f dep-duplicate.main
+
+ @rm -f dep-duplicate.main
+ @rm -f dep-duplicate.inc