Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add test for combining the ...



details:   https://anonhg.NetBSD.org/src/rev/9e93d99449fb
branches:  trunk
changeset: 959039:9e93d99449fb
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 30 12:46:38 2021 +0000

description:
make(1): add test for combining the options -j, -n, -t

This is a preparation for refactoring the complicated condition in
JobStart.

diffstat:

 distrib/sets/lists/tests/mi                     |   4 +-
 usr.bin/make/unit-tests/Makefile                |   3 +-
 usr.bin/make/unit-tests/jobs-empty-commands.mk  |   5 +-
 usr.bin/make/unit-tests/opt-no-action-touch.exp |  11 +++++
 usr.bin/make/unit-tests/opt-no-action-touch.mk  |  48 +++++++++++++++++++++++++
 5 files changed, 67 insertions(+), 4 deletions(-)

diffs (117 lines):

diff -r ae0146db06f4 -r 9e93d99449fb distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sat Jan 30 12:14:08 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Sat Jan 30 12:46:38 2021 +0000
@@ -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
diff -r ae0146db06f4 -r 9e93d99449fb usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Sat Jan 30 12:14:08 2021 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Sat Jan 30 12:46:38 2021 +0000
@@ -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-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
diff -r ae0146db06f4 -r 9e93d99449fb usr.bin/make/unit-tests/jobs-empty-commands.mk
--- a/usr.bin/make/unit-tests/jobs-empty-commands.mk    Sat Jan 30 12:14:08 2021 +0000
+++ b/usr.bin/make/unit-tests/jobs-empty-commands.mk    Sat Jan 30 12:46:38 2021 +0000
@@ -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
 
diff -r ae0146db06f4 -r 9e93d99449fb usr.bin/make/unit-tests/opt-no-action-touch.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/opt-no-action-touch.exp   Sat Jan 30 12:46:38 2021 +0000
@@ -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
diff -r ae0146db06f4 -r 9e93d99449fb usr.bin/make/unit-tests/opt-no-action-touch.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/opt-no-action-touch.mk    Sat Jan 30 12:46:38 2021 +0000
@@ -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; }



Home | Main Index | Thread Index | Old Index