Module Name: src
Committed By: rillig
Date: Sat Jan 30 12:46:38 UTC 2021
Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile jobs-empty-commands.mk
Added Files:
src/usr.bin/make/unit-tests: opt-no-action-touch.exp
opt-no-action-touch.mk
Log Message:
make(1): add test for combining the options -j, -n, -t
This is a preparation for refactoring the complicated condition in
JobStart.
To generate a diff of this commit:
cvs rdiff -u -r1.1013 -r1.1014 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.263 -r1.264 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/jobs-empty-commands.mk
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/opt-no-action-touch.exp \
src/usr.bin/make/unit-tests/opt-no-action-touch.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1013 src/distrib/sets/lists/tests/mi:1.1014
--- src/distrib/sets/lists/tests/mi:1.1013 Fri Jan 29 22:38:17 2021
+++ src/distrib/sets/lists/tests/mi Sat Jan 30 12:46:38 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1013 2021/01/29 22:38:17 rillig Exp $
+# $NetBSD: mi,v 1.1014 2021/01/30 12:46:38 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -5258,6 +5258,8 @@
./usr/tests/usr.bin/make/unit-tests/opt-no-action-at-all.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/opt-no-action-runflags.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/opt-no-action-runflags.mk tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/opt-no-action-touch.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/opt-no-action-touch.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/opt-no-action.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/opt-no-action.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/opt-query.exp tests-usr.bin-tests compattestfile,atf
Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.263 src/usr.bin/make/unit-tests/Makefile:1.264
--- src/usr.bin/make/unit-tests/Makefile:1.263 Fri Jan 29 22:38:17 2021
+++ src/usr.bin/make/unit-tests/Makefile Sat Jan 30 12:46:38 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.263 2021/01/29 22:38:17 rillig Exp $
+# $NetBSD: Makefile,v 1.264 2021/01/30 12:46:38 rillig Exp $
#
# Unit tests for make(1)
#
@@ -258,6 +258,7 @@ TESTS+= opt-m-include-dir
TESTS+= opt-no-action
TESTS+= opt-no-action-at-all
TESTS+= opt-no-action-runflags
+TESTS+= opt-no-action-touch
TESTS+= opt-query
TESTS+= opt-raw
TESTS+= opt-silent
Index: src/usr.bin/make/unit-tests/jobs-empty-commands.mk
diff -u src/usr.bin/make/unit-tests/jobs-empty-commands.mk:1.1 src/usr.bin/make/unit-tests/jobs-empty-commands.mk:1.2
--- src/usr.bin/make/unit-tests/jobs-empty-commands.mk:1.1 Fri Jan 29 22:38:17 2021
+++ src/usr.bin/make/unit-tests/jobs-empty-commands.mk Sat Jan 30 12:46:38 2021
@@ -1,8 +1,9 @@
-# $NetBSD: jobs-empty-commands.mk,v 1.1 2021/01/29 22:38:17 rillig Exp $
+# $NetBSD: jobs-empty-commands.mk,v 1.2 2021/01/30 12:46:38 rillig Exp $
#
# In jobs mode, the shell commands for creating a target are written to a
# temporary file first, which is then run by the shell. In chains of
-# dependencies, these files would end up empty. This can be avoided easily.
+# dependencies, these files would end up empty. Since job.c 1.399 from
+# 2021-01-29, these empty files are no longer created.
#
# https://mail-index.netbsd.org/current-users/2021/01/26/msg040215.html
Added files:
Index: src/usr.bin/make/unit-tests/opt-no-action-touch.exp
diff -u /dev/null src/usr.bin/make/unit-tests/opt-no-action-touch.exp:1.1
--- /dev/null Sat Jan 30 12:46:38 2021
+++ src/usr.bin/make/unit-tests/opt-no-action-touch.exp Sat Jan 30 12:46:38 2021
@@ -0,0 +1,11 @@
+echo ": Making opt-touch-phony."
+{ : Making opt-touch-phony.
+} || exit $?
+echo 'Making opt-touch-make.'
+Making opt-touch-make.
+echo ": Making opt-touch-regular."
+{ : Making opt-touch-regular.
+} || exit $?
+`opt-touch-join' is up to date.
+`opt-touch-use' is up to date.
+exit status 0
Index: src/usr.bin/make/unit-tests/opt-no-action-touch.mk
diff -u /dev/null src/usr.bin/make/unit-tests/opt-no-action-touch.mk:1.1
--- /dev/null Sat Jan 30 12:46:38 2021
+++ src/usr.bin/make/unit-tests/opt-no-action-touch.mk Sat Jan 30 12:46:38 2021
@@ -0,0 +1,48 @@
+# $NetBSD: opt-no-action-touch.mk,v 1.1 2021/01/30 12:46:38 rillig Exp $
+#
+# Tests for combining the command line options -n (no action) and -t (touch).
+# This combination is unusual and probably doesn't ever happen in practice,
+# but still make needs to behave as expected. The option -n is stronger than
+# -t, so instead of being touched, the commands of the targets are printed.
+#
+# See also:
+# opt-touch-jobs.mk contains the same test without the option -n.
+
+.MAKEFLAGS: -j1 -n -t
+.MAKEFLAGS: opt-touch-phony
+.MAKEFLAGS: opt-touch-join
+.MAKEFLAGS: opt-touch-use
+.MAKEFLAGS: opt-touch-make
+.MAKEFLAGS: opt-touch-regular
+
+# .PHONY targets are not touched since they do not represent actual files.
+# See Job_Touch.
+opt-touch-phony: .PHONY
+ : Making $@.
+
+# .JOIN targets are not touched since they do not represent actual files.
+# See Job_Touch.
+opt-touch-join: .JOIN
+ : Making $@.
+
+# .USE targets are not touched since they do not represent actual files.
+# See Job_Touch.
+opt-touch-use: .USE
+ : Making use of $@.
+
+# The attribute .MAKE is stronger than the command line option -n. Therefore
+# this target is run as usual. It is not prefixed by '@', therefore it is
+# printed before being run.
+opt-touch-make: .MAKE
+ echo 'Making $@.'
+
+# Since the option -n is stronger than the option -t, this target is not
+# touched either. Without the -n, it would be touched.
+opt-touch-regular:
+ : Making $@.
+
+# Since none of the above targets are actually touched, the following command
+# does not output anything.
+.END:
+ @files=$$(ls opt-touch-* 2>/dev/null | grep -v -e '\.'); \
+ [ -z "$$files" ] || { echo "created files: $$files" 1>&2; exit 1; }