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 another unit test for s...



details:   https://anonhg.NetBSD.org/src/rev/14236cc5bc17
branches:  trunk
changeset: 957270:14236cc5bc17
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 22 20:36:17 2020 +0000

description:
make(1): add another unit test for suffix handling

diffstat:

 distrib/sets/lists/tests/mi                   |    4 +-
 usr.bin/make/parse.c                          |    9 +-
 usr.bin/make/unit-tests/Makefile              |    6 +-
 usr.bin/make/unit-tests/suff-main-several.exp |  131 ++++++++++++++++++++++++++
 usr.bin/make/unit-tests/suff-main-several.mk  |   42 ++++++++
 5 files changed, 186 insertions(+), 6 deletions(-)

diffs (264 lines):

diff -r 097ca60d30c5 -r 14236cc5bc17 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun Nov 22 20:29:53 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Nov 22 20:36:17 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.972 2020/11/22 19:37:27 rillig Exp $
+# $NetBSD: mi,v 1.973 2020/11/22 20:36:17 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5285,6 +5285,8 @@
 ./usr/tests/usr.bin/make/unit-tests/suff-incomplete.mk                         tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/suff-lookup.exp                            tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/suff-lookup.mk                             tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-main-several.exp                      tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/suff-main-several.mk                       tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/suff-main.exp                              tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/suff-main.mk                               tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/suff-rebuild.exp                           tests-usr.bin-tests     compattestfile,atf
diff -r 097ca60d30c5 -r 14236cc5bc17 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sun Nov 22 20:29:53 2020 +0000
+++ b/usr.bin/make/parse.c      Sun Nov 22 20:36:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.447 2020/11/22 20:29:53 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.448 2020/11/22 20:36:17 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.447 2020/11/22 20:29:53 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.448 2020/11/22 20:36:17 rillig Exp $");
 
 /* types and constants */
 
@@ -902,9 +902,10 @@
      * the sources of said target to the list of things to create.
      *
      * Note that this will only be invoked if the user didn't specify a
-     * target on the command line. This is to allow .ifmake to succeed.
+     * target on the command line and the .MAIN occurs for the first time.
      *
-     * XXX: Double-check all of the above comment.
+     * See ParseDoDependencyTargetSpecial, branch SP_MAIN.
+     * See unit-tests/cond-func-make-main.mk.
      */
     Lst_Append(opts.create, bmake_strdup(src));
     /*
diff -r 097ca60d30c5 -r 14236cc5bc17 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Sun Nov 22 20:29:53 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Sun Nov 22 20:36:17 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.217 2020/11/22 19:37:27 rillig Exp $
+# $NetBSD: Makefile,v 1.218 2020/11/22 20:36:17 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -267,6 +267,7 @@
 TESTS+=                suff-incomplete
 TESTS+=                suff-lookup
 TESTS+=                suff-main
+TESTS+=                suff-main-several
 TESTS+=                suff-rebuild
 TESTS+=                suff-self
 TESTS+=                suff-transform-endless
@@ -454,6 +455,7 @@
 # The "-q" may be there or not, see jobs.c, variable shells.
 SED_CMDS.opt-debug-jobs+=      -e 's,^\(.Command: <shell>\) -q,\1,'
 SED_CMDS.suff-main+=           ${STD_SED_CMDS.dg1}
+SED_CMDS.suff-main-several+=   ${STD_SED_CMDS.dg1}
 SED_CMDS.var-op-shell+=        \
        -e 's,^${.SHELL:T}: [ 0-9:]*,,' \
        -e '/command/s,No such.*,not found,'
@@ -471,6 +473,8 @@
 POSTPROC.deptgt-suffixes= awk '/^\#\*\*\* Suffixes/,/^never-stop/'
 POSTPROC.gnode-submake=        awk '/Input graph/, /^$$/'
 POSTPROC.varname-empty=        ${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p'
+# The directory cache contains the hard-coded '/usr/share/mk'.
+POSTPROC.suff-main-several=    awk '/Directory Cache/,/^$$/ { next } { print }'
 
 # Some tests reuse other tests, which makes them unnecessarily fragile.
 export-all.rawout: export.mk
diff -r 097ca60d30c5 -r 14236cc5bc17 usr.bin/make/unit-tests/suff-main-several.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-main-several.exp     Sun Nov 22 20:36:17 2020 +0000
@@ -0,0 +1,131 @@
+ParseReadLine (8): '.1.2 .1.3 .1.4:'
+ParseDoDependency(.1.2 .1.3 .1.4:)
+Setting main node to ".1.2"
+ParseReadLine (9): '   : Making ${.TARGET} from ${.IMPSRC}.'
+ParseReadLine (14): 'next-main:'
+ParseDoDependency(next-main:)
+ParseReadLine (15): '  : Making ${.TARGET}'
+ParseReadLine (19): '.SUFFIXES: .1 .2 .3 .4'
+ParseDoDependency(.SUFFIXES: .1 .2 .3 .4)
+Adding suffix ".1"
+Adding suffix ".2"
+Setting main node from ".1.2" back to null
+defining transformation from `.1' to `.2'
+inserting ".1" (1) at end of list
+inserting ".2" (2) at end of list
+Setting main node to ".1.3"
+Adding suffix ".3"
+Setting main node from ".1.3" back to null
+defining transformation from `.1' to `.3'
+inserting ".1" (1) at end of list
+inserting ".3" (3) at end of list
+Setting main node to ".1.4"
+Adding suffix ".4"
+Setting main node from ".1.4" back to null
+defining transformation from `.1' to `.4'
+inserting ".1" (1) at end of list
+inserting ".4" (4) at end of list
+Setting main node to "next-main"
+ParseReadLine (24): '.SUFFIXES:'
+ParseDoDependency(.SUFFIXES:)
+Clearing all suffixes
+ParseReadLine (32): '.SUFFIXES: .4 .3 .2 .1'
+ParseDoDependency(.SUFFIXES: .4 .3 .2 .1)
+Adding suffix ".4"
+Adding suffix ".3"
+Adding suffix ".2"
+Adding suffix ".1"
+ParseReadLine (33): '.SUFFIXES:'
+ParseDoDependency(.SUFFIXES:)
+Clearing all suffixes
+ParseReadLine (34): '.SUFFIXES: .1 .2 .3 .4'
+ParseDoDependency(.SUFFIXES: .1 .2 .3 .4)
+Adding suffix ".1"
+Adding suffix ".2"
+Adding suffix ".3"
+Adding suffix ".4"
+ParseReadLine (35): '.SUFFIXES:'
+ParseDoDependency(.SUFFIXES:)
+Clearing all suffixes
+ParseReadLine (36): '.SUFFIXES: .4 .3 .2 .1'
+ParseDoDependency(.SUFFIXES: .4 .3 .2 .1)
+Adding suffix ".4"
+Adding suffix ".3"
+Adding suffix ".2"
+Adding suffix ".1"
+ParseReadLine (38): 'suff-main-several.1:'
+ParseDoDependency(suff-main-several.1:)
+ParseReadLine (39): '  : Making ${.TARGET} out of nothing.'
+ParseReadLine (40): 'next-main: suff-main-several.{2,3,4}'
+ParseDoDependency(next-main: suff-main-several.{2,3,4})
+# LinkSource: added child next-main - suff-main-several.{2,3,4}
+# next-main, made UNMADE, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
+# suff-main-several.{2,3,4}, made UNMADE, type none, flags none
+ParseReadLine (42): '.MAKEFLAGS: -d0 -dg1'
+ParseDoDependency(.MAKEFLAGS: -d0 -dg1)
+#*** Input graph:
+# .1.2, made UNMADE, type OP_TRANSFORM, flags none
+# .1.3, made UNMADE, type OP_TRANSFORM, flags none
+# .1.4, made UNMADE, type OP_TRANSFORM, flags none
+# next-main, made UNMADE, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
+# suff-main-several.1, made UNMADE, type OP_DEPENDS|OP_HAS_COMMANDS, flags none
+# suff-main-several.{2,3,4}, made UNMADE, type none, flags none
+
+
+#
+#   Files that are only sources:
+#      .1.2 [.1.2]
+#      .1.3 [.1.3]
+#      .1.4 [.1.4]
+#      suff-main-several.{2,3,4} [suff-main-several.{2,3,4}]
+#*** Global Variables:
+.ALLTARGETS      =  .1.2 .1.3 .1.4 next-main suff-main-several.1 suff-main-several.{2,3,4}
+.CURDIR          = <curdir>
+.INCLUDES        = 
+.LIBS            = 
+.MAKE            = <details omitted>
+.MAKE.DEPENDFILE = <details omitted>
+.MAKE.LEVEL      = <details omitted>
+.MAKE.MAKEFILES  = <details omitted>
+.MAKE.MAKEFILE_PREFERENCE = <details omitted>
+.MAKE.OS         = <details omitted>
+.MAKE.PATH_FILEMON = <details omitted>
+.MAKE.PID        = <details omitted>
+.MAKE.PPID       = <details omitted>
+.MAKEFLAGS       =  -r -k -d mps -d 0 -d g1
+.MAKEOVERRIDES   = 
+.OBJDIR          = <curdir>
+.PATH            = . <curdir>
+.TARGETS         = 
+.newline         = 
+
+MACHINE          = <details omitted>
+MACHINE_ARCH     = <details omitted>
+MAKE             = <details omitted>
+MFLAGS           =   -r -k -d mps -d 0 -d g1
+#*** Command-line Variables:
+.MAKE.LEVEL.ENV  = MAKELEVEL
+
+#*** Suffixes:
+# ".4" (num 1, ref 1)
+#      To: 
+#      From: 
+#      Search Path: 
+# ".3" (num 2, ref 1)
+#      To: 
+#      From: 
+#      Search Path: 
+# ".2" (num 3, ref 1)
+#      To: 
+#      From: 
+#      Search Path: 
+# ".1" (num 4, ref 1)
+#      To: 
+#      From: 
+#      Search Path: 
+#*** Transformations:
+make: don't know how to make suff-main-several.2 (continuing)
+make: don't know how to make suff-main-several.3 (continuing)
+make: don't know how to make suff-main-several.4 (continuing)
+`next-main' not remade because of errors.
+exit status 0
diff -r 097ca60d30c5 -r 14236cc5bc17 usr.bin/make/unit-tests/suff-main-several.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/suff-main-several.mk      Sun Nov 22 20:36:17 2020 +0000
@@ -0,0 +1,42 @@
+# $NetBSD: suff-main-several.mk,v 1.1 2020/11/22 20:36:17 rillig Exp $
+#
+# Demonstrate that an inference rule is considered the main target if its
+# suffixes are not known at the point of declaration.
+
+.MAKEFLAGS: -dmps
+
+.1.2 .1.3 .1.4:
+       : Making ${.TARGET} from ${.IMPSRC}.
+
+# At this point, the above targets are normal targets.
+# The target '.1.2' is now the default main target.
+
+next-main:
+       : Making ${.TARGET}
+
+# At this point, 'next-main' is just a regular target.
+
+.SUFFIXES: .1 .2 .3 .4
+
+# Since the targets '.1.2', '.1.3' and '.1.4' have now been turned into
+# transformation rules, 'next-main' is the default main target now.
+
+.SUFFIXES: # clear all
+
+# At this point, 'next-main' is still the default main target, even though
+# it is not the first regular target anymore.
+
+# Define and undefine the suffixes, changing their order.
+# XXX: This should have no effect, but as of 2020-11-22, it does.
+# For some reason, mentioning the suffixes in reverse order disables them.
+.SUFFIXES: .4 .3 .2 .1
+.SUFFIXES: # none
+.SUFFIXES: .1 .2 .3 .4
+.SUFFIXES: # none
+.SUFFIXES: .4 .3 .2 .1
+
+suff-main-several.1:
+       : Making ${.TARGET} out of nothing.
+next-main: suff-main-several.{2,3,4}
+
+.MAKEFLAGS: -d0 -dg1



Home | Main Index | Thread Index | Old Index