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 .INCLUDEDFILE ...



details:   https://anonhg.NetBSD.org/src/rev/6b411c43d851
branches:  trunk
changeset: 943538:6b411c43d851
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Sep 05 18:13:47 2020 +0000

description:
make(1): add test for .INCLUDEDFILE combined with .for loops

The .for loops are implemented as a special kind of .include, therefore
they affect the .INCLUDEDFROM variable.

diffstat:

 usr.bin/make/unit-tests/include-main.exp  |   8 ++++++--
 usr.bin/make/unit-tests/include-main.mk   |  18 +++++++++++++++++-
 usr.bin/make/unit-tests/include-sub.mk    |  23 +++++++++++++++++++++--
 usr.bin/make/unit-tests/include-subsub.mk |   6 +++---
 4 files changed, 47 insertions(+), 8 deletions(-)

diffs (107 lines):

diff -r 96c4ba0de2ed -r 6b411c43d851 usr.bin/make/unit-tests/include-main.exp
--- a/usr.bin/make/unit-tests/include-main.exp  Sat Sep 05 18:01:42 2020 +0000
+++ b/usr.bin/make/unit-tests/include-main.exp  Sat Sep 05 18:13:47 2020 +0000
@@ -1,6 +1,10 @@
 make: "include-main.mk" line 12: main-before-ok
+make: "include-main.mk" line 19: main-before-for-ok
 make: "include-sub.mk" line 4: sub-before-ok
+make: "include-sub.mk" line 14: sub-before-for-ok
 make: "include-subsub.mk" line 4: subsub-ok
-make: "include-sub.mk" line 14: warning: sub-after-fail(include-sub.mk)
-make: "include-main.mk" line 22: warning: main-after-fail(include-sub.mk)
+make: "include-sub.mk" line 25: warning: sub-after-fail(include-sub.mk)
+make: "include-sub.mk" line 32: warning: sub-after-for-fail(include-sub.mk)
+make: "include-main.mk" line 30: warning: main-after-fail(include-sub.mk)
+make: "include-main.mk" line 35: main-after-for-ok
 exit status 0
diff -r 96c4ba0de2ed -r 6b411c43d851 usr.bin/make/unit-tests/include-main.mk
--- a/usr.bin/make/unit-tests/include-main.mk   Sat Sep 05 18:01:42 2020 +0000
+++ b/usr.bin/make/unit-tests/include-main.mk   Sat Sep 05 18:13:47 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: include-main.mk,v 1.3 2020/09/05 16:59:19 rillig Exp $
+# $NetBSD: include-main.mk,v 1.4 2020/09/05 18:13:47 rillig Exp $
 #
 # Demonstrates that the .INCLUDEDFROMFILE magic variable does not behave
 # as described in the manual page.
@@ -14,6 +14,14 @@
 .  warning main-before-fail(${.INCLUDEDFROMFILE})
 .endif
 
+.for i in once
+.  if !defined(${.INCLUDEDFROMFILE})
+.    info main-before-for-ok
+.  else
+.    warning main-before-for-fail(${.INCLUDEDFROMFILE})
+.  endif
+.endfor
+
 .include "include-sub.mk"
 
 .if !defined(.INCLUDEDFROMFILE)
@@ -22,4 +30,12 @@
 .  warning main-after-fail(${.INCLUDEDFROMFILE})
 .endif
 
+.for i in once
+.  if !defined(${.INCLUDEDFROMFILE})
+.    info main-after-for-ok
+.  else
+.    warning main-after-for-fail(${.INCLUDEDFROMFILE})
+.  endif
+.endfor
+
 all:   # nothing
diff -r 96c4ba0de2ed -r 6b411c43d851 usr.bin/make/unit-tests/include-sub.mk
--- a/usr.bin/make/unit-tests/include-sub.mk    Sat Sep 05 18:01:42 2020 +0000
+++ b/usr.bin/make/unit-tests/include-sub.mk    Sat Sep 05 18:13:47 2020 +0000
@@ -1,11 +1,22 @@
-# $NetBSD: include-sub.mk,v 1.2 2020/09/05 16:59:19 rillig Exp $
+# $NetBSD: include-sub.mk,v 1.3 2020/09/05 18:13:47 rillig Exp $
 
 .if ${.INCLUDEDFROMFILE} == "include-main.mk"
 .  info sub-before-ok
 .else
-.  warning sub-before-fail
+.  warning sub-before-fail(${.INCLUDEDFROMFILE})
 .endif
 
+# As of 2020-09-05, the .for loop is implemented as "including a file"
+# with a custom buffer.  Therefore this loop has side effects on these
+# variables.
+.for i in once
+.  if ${.INCLUDEDFROMFILE} == "include-main.mk"
+.    info sub-before-for-ok
+.  else
+.    warning sub-before-for-fail(${.INCLUDEDFROMFILE})
+.  endif
+.endfor
+
 .include "include-subsub.mk"
 
 .if ${.INCLUDEDFROMFILE} == "include-main.mk"
@@ -13,3 +24,11 @@
 .else
 .  warning sub-after-fail(${.INCLUDEDFROMFILE})
 .endif
+
+.for i in once
+.  if ${.INCLUDEDFROMFILE} == "include-main.mk"
+.    info sub-after-for-ok
+.  else
+.    warning sub-after-for-fail(${.INCLUDEDFROMFILE})
+.  endif
+.endfor
diff -r 96c4ba0de2ed -r 6b411c43d851 usr.bin/make/unit-tests/include-subsub.mk
--- a/usr.bin/make/unit-tests/include-subsub.mk Sat Sep 05 18:01:42 2020 +0000
+++ b/usr.bin/make/unit-tests/include-subsub.mk Sat Sep 05 18:13:47 2020 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: include-subsub.mk,v 1.2 2020/09/05 16:59:19 rillig Exp $
+# $NetBSD: include-subsub.mk,v 1.3 2020/09/05 18:13:47 rillig Exp $
 
-.if ${.INCLUDEDFROMFILE:T} == "include-sub.mk"
+.if ${.INCLUDEDFROMFILE} == "include-sub.mk"
 .  info subsub-ok
 .else
-.  warning subsub-fail
+.  warning subsub-fail(${.INCLUDEDFROMFILE})
 .endif



Home | Main Index | Thread Index | Old Index