Module Name: src
Committed By: rillig
Date: Sat Sep 5 15:57:13 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: depsrc-exec.exp depsrc-exec.mk
depsrc-made.exp depsrc-made.mk depsrc-make.exp depsrc-make.mk
depsrc-notmain.exp depsrc-notmain.mk depsrc-optional.exp
depsrc-optional.mk depsrc-phony.exp depsrc-phony.mk
depsrc-recursive.exp depsrc-recursive.mk
Log Message:
make(1): add tests for some of the special sources
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/depsrc-exec.exp \
src/usr.bin/make/unit-tests/depsrc-made.exp \
src/usr.bin/make/unit-tests/depsrc-make.exp \
src/usr.bin/make/unit-tests/depsrc-notmain.exp \
src/usr.bin/make/unit-tests/depsrc-optional.exp \
src/usr.bin/make/unit-tests/depsrc-phony.exp \
src/usr.bin/make/unit-tests/depsrc-recursive.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/depsrc-exec.mk \
src/usr.bin/make/unit-tests/depsrc-made.mk \
src/usr.bin/make/unit-tests/depsrc-make.mk \
src/usr.bin/make/unit-tests/depsrc-notmain.mk \
src/usr.bin/make/unit-tests/depsrc-optional.mk \
src/usr.bin/make/unit-tests/depsrc-phony.mk \
src/usr.bin/make/unit-tests/depsrc-recursive.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/unit-tests/depsrc-exec.exp
diff -u src/usr.bin/make/unit-tests/depsrc-exec.exp:1.1 src/usr.bin/make/unit-tests/depsrc-exec.exp:1.2
--- src/usr.bin/make/unit-tests/depsrc-exec.exp:1.1 Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/depsrc-exec.exp Sat Sep 5 15:57:12 2020
@@ -1 +1,2 @@
+: depsrc-exec.mk: This is always executed.
exit status 0
Index: src/usr.bin/make/unit-tests/depsrc-made.exp
diff -u src/usr.bin/make/unit-tests/depsrc-made.exp:1.1 src/usr.bin/make/unit-tests/depsrc-made.exp:1.2
--- src/usr.bin/make/unit-tests/depsrc-made.exp:1.1 Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/depsrc-made.exp Sat Sep 5 15:57:12 2020
@@ -1 +1,3 @@
+: Making chapter21
+: Making chapter22
exit status 0
Index: src/usr.bin/make/unit-tests/depsrc-make.exp
diff -u src/usr.bin/make/unit-tests/depsrc-make.exp:1.1 src/usr.bin/make/unit-tests/depsrc-make.exp:1.2
--- src/usr.bin/make/unit-tests/depsrc-make.exp:1.1 Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/depsrc-make.exp Sat Sep 5 15:57:12 2020
@@ -1 +1,3 @@
+this-is-made is made.
+echo this-is-not-made is just echoed.
exit status 0
Index: src/usr.bin/make/unit-tests/depsrc-notmain.exp
diff -u src/usr.bin/make/unit-tests/depsrc-notmain.exp:1.1 src/usr.bin/make/unit-tests/depsrc-notmain.exp:1.2
--- src/usr.bin/make/unit-tests/depsrc-notmain.exp:1.1 Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/depsrc-notmain.exp Sat Sep 5 15:57:12 2020
@@ -1 +1,2 @@
+: all
exit status 0
Index: src/usr.bin/make/unit-tests/depsrc-optional.exp
diff -u src/usr.bin/make/unit-tests/depsrc-optional.exp:1.1 src/usr.bin/make/unit-tests/depsrc-optional.exp:1.2
--- src/usr.bin/make/unit-tests/depsrc-optional.exp:1.1 Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/depsrc-optional.exp Sat Sep 5 15:57:12 2020
@@ -1 +1,2 @@
+`all' is up to date.
exit status 0
Index: src/usr.bin/make/unit-tests/depsrc-phony.exp
diff -u src/usr.bin/make/unit-tests/depsrc-phony.exp:1.1 src/usr.bin/make/unit-tests/depsrc-phony.exp:1.2
--- src/usr.bin/make/unit-tests/depsrc-phony.exp:1.1 Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/depsrc-phony.exp Sat Sep 5 15:57:12 2020
@@ -1 +1,2 @@
+: depsrc-phony.mk is made.
exit status 0
Index: src/usr.bin/make/unit-tests/depsrc-recursive.exp
diff -u src/usr.bin/make/unit-tests/depsrc-recursive.exp:1.1 src/usr.bin/make/unit-tests/depsrc-recursive.exp:1.2
--- src/usr.bin/make/unit-tests/depsrc-recursive.exp:1.1 Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/depsrc-recursive.exp Sat Sep 5 15:57:12 2020
@@ -1 +1,3 @@
+this-is-made is made.
+echo this-is-not-made is just echoed.
exit status 0
Index: src/usr.bin/make/unit-tests/depsrc-exec.mk
diff -u src/usr.bin/make/unit-tests/depsrc-exec.mk:1.2 src/usr.bin/make/unit-tests/depsrc-exec.mk:1.3
--- src/usr.bin/make/unit-tests/depsrc-exec.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/depsrc-exec.mk Sat Sep 5 15:57:12 2020
@@ -1,8 +1,16 @@
-# $NetBSD: depsrc-exec.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: depsrc-exec.mk,v 1.3 2020/09/05 15:57:12 rillig Exp $
#
-# Tests for the special source .EXEC in dependency declarations.
+# Tests for the special source .EXEC in dependency declarations,
+# which always executes the commands, even if the target is up to date.
+# The target itself is considered up to date.
+#
+# TODO: Describe possible use cases for .EXEC.
+
+all: ${MAKEFILE} ${MAKEFILE:H}/depsrc.mk
-# TODO: Implementation
+${MAKEFILE}: .EXEC
+ : ${.TARGET:T}: This is always executed.
-all:
- @:;
+${MAKEFILE:H}/depsrc.mk:
+ : This is not executed.
+ +: ${.TARGET:T}: This is not executed as well.
Index: src/usr.bin/make/unit-tests/depsrc-made.mk
diff -u src/usr.bin/make/unit-tests/depsrc-made.mk:1.2 src/usr.bin/make/unit-tests/depsrc-made.mk:1.3
--- src/usr.bin/make/unit-tests/depsrc-made.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/depsrc-made.mk Sat Sep 5 15:57:12 2020
@@ -1,8 +1,15 @@
-# $NetBSD: depsrc-made.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: depsrc-made.mk,v 1.3 2020/09/05 15:57:12 rillig Exp $
#
-# Tests for the special source .MADE in dependency declarations.
+# Tests for the special source .MADE in dependency declarations,
+# which marks all its dependencies as already made, so their commands
+# don't need to be executed.
+#
+# TODO: Describe a possible use case for .MADE.
+
+all: part1 part2
-# TODO: Implementation
+part1: chapter11 chapter12 .MADE
+part2: chapter21 chapter22
-all:
- @:;
+chapter11 chapter12 chapter21 chapter22:
+ : Making ${.TARGET}
Index: src/usr.bin/make/unit-tests/depsrc-make.mk
diff -u src/usr.bin/make/unit-tests/depsrc-make.mk:1.2 src/usr.bin/make/unit-tests/depsrc-make.mk:1.3
--- src/usr.bin/make/unit-tests/depsrc-make.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/depsrc-make.mk Sat Sep 5 15:57:12 2020
@@ -1,8 +1,16 @@
-# $NetBSD: depsrc-make.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: depsrc-make.mk,v 1.3 2020/09/05 15:57:12 rillig Exp $
#
-# Tests for the special source .MAKE in dependency declarations.
+# Tests for the special source .MAKE in dependency declarations, which
+# executes the commands of the target even if the -n or -t command line
+# options are given.
-# TODO: Implementation
+.MAKEFLAGS: -n
-all:
- @:;
+all: this-is-made
+all: this-is-not-made
+
+this-is-made: .MAKE
+ @echo ${.TARGET} is made.
+
+this-is-not-made:
+ @echo ${.TARGET} is just echoed.
Index: src/usr.bin/make/unit-tests/depsrc-notmain.mk
diff -u src/usr.bin/make/unit-tests/depsrc-notmain.mk:1.2 src/usr.bin/make/unit-tests/depsrc-notmain.mk:1.3
--- src/usr.bin/make/unit-tests/depsrc-notmain.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/depsrc-notmain.mk Sat Sep 5 15:57:12 2020
@@ -1,8 +1,11 @@
-# $NetBSD: depsrc-notmain.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: depsrc-notmain.mk,v 1.3 2020/09/05 15:57:12 rillig Exp $
#
-# Tests for the special source .NOTMAIN in dependency declarations.
+# Tests for the special source .NOTMAIN in dependency declarations,
+# which prevents the associated target from becoming the default target
+# to be made.
-# TODO: Implementation
+ignored: .NOTMAIN
+ : ${.TARGET}
all:
- @:;
+ : ${.TARGET}
Index: src/usr.bin/make/unit-tests/depsrc-optional.mk
diff -u src/usr.bin/make/unit-tests/depsrc-optional.mk:1.2 src/usr.bin/make/unit-tests/depsrc-optional.mk:1.3
--- src/usr.bin/make/unit-tests/depsrc-optional.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/depsrc-optional.mk Sat Sep 5 15:57:12 2020
@@ -1,8 +1,18 @@
-# $NetBSD: depsrc-optional.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: depsrc-optional.mk,v 1.3 2020/09/05 15:57:12 rillig Exp $
#
-# Tests for the special source .OPTIONAL in dependency declarations.
+# Tests for the special source .OPTIONAL in dependency declarations,
+# which ignores the target if make cannot find out how to create it.
+#
+# TODO: Describe practical use cases for this feature.
+
+# TODO: Explain why the commands for "important" are not executed.
+# I had thought that only the "optional" commands were skipped.
+
+all: important
+ : ${.TARGET} is made.
-# TODO: Implementation
+important: optional
+ : ${.TARGET} is made.
-all:
- @:;
+optional: .OPTIONAL
+ : This is not executed.
Index: src/usr.bin/make/unit-tests/depsrc-phony.mk
diff -u src/usr.bin/make/unit-tests/depsrc-phony.mk:1.2 src/usr.bin/make/unit-tests/depsrc-phony.mk:1.3
--- src/usr.bin/make/unit-tests/depsrc-phony.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/depsrc-phony.mk Sat Sep 5 15:57:12 2020
@@ -1,8 +1,9 @@
-# $NetBSD: depsrc-phony.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: depsrc-phony.mk,v 1.3 2020/09/05 15:57:12 rillig Exp $
#
-# Tests for the special source .PHONY in dependency declarations.
+# Tests for the special source .PHONY in dependency declarations,
+# which executes the commands for the target even if a file of the same
+# name exists and would be considered up to date.
-# TODO: Implementation
-
-all:
- @:;
+# Without the .PHONY, this target would be "up to date".
+${MAKEFILE}: .PHONY
+ : ${.TARGET:T} is made.
Index: src/usr.bin/make/unit-tests/depsrc-recursive.mk
diff -u src/usr.bin/make/unit-tests/depsrc-recursive.mk:1.2 src/usr.bin/make/unit-tests/depsrc-recursive.mk:1.3
--- src/usr.bin/make/unit-tests/depsrc-recursive.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/depsrc-recursive.mk Sat Sep 5 15:57:12 2020
@@ -1,8 +1,16 @@
-# $NetBSD: depsrc-recursive.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: depsrc-recursive.mk,v 1.3 2020/09/05 15:57:12 rillig Exp $
#
-# Tests for the special source .RECURSIVE in dependency declarations.
+# Tests for the special source .RECURSIVE in dependency declarations,
+# which executes the commands of the target even if the -n or -t command
+# line options are given.
-# TODO: Implementation
+.MAKEFLAGS: -n
-all:
- @:;
+all: this-is-made
+all: this-is-not-made
+
+this-is-made: .RECURSIVE
+ @echo ${.TARGET} is made.
+
+this-is-not-made:
+ @echo ${.TARGET} is just echoed.