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 Convert test in PR/49085
details: https://anonhg.NetBSD.org/src/rev/47626711b03e
branches: trunk
changeset: 331761:47626711b03e
user: christos <christos%NetBSD.org@localhost>
date: Sat Aug 23 15:02:04 2014 +0000
description:
Convert test in PR/49085
diffstat:
usr.bin/make/unit-tests/Makefile | 4 +-
usr.bin/make/unit-tests/posix1.exp | 185 +++++++++++++++++++++++++++++++++++++
usr.bin/make/unit-tests/posix1.mk | 179 +++++++++++++++++++++++++++++++++++
3 files changed, 367 insertions(+), 1 deletions(-)
diffs (truncated from 397 to 300 lines):
diff -r 25cf428e5a4a -r 47626711b03e usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Sat Aug 23 14:50:24 2014 +0000
+++ b/usr.bin/make/unit-tests/Makefile Sat Aug 23 15:02:04 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.44 2014/08/21 22:00:30 apb Exp $
+# $NetBSD: Makefile,v 1.45 2014/08/23 15:02:04 christos Exp $
#
# Unit tests for make(1)
# The main targets are:
@@ -32,6 +32,7 @@
forloop \
forsubst \
hash \
+ impsrc \
misc \
moderrs \
modmatch \
@@ -43,6 +44,7 @@
phony-end \
posix \
qequals \
+ suffixes \
sunshcmd \
sysv \
ternary \
diff -r 25cf428e5a4a -r 47626711b03e usr.bin/make/unit-tests/posix1.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/posix1.exp Sat Aug 23 15:02:04 2014 +0000
@@ -0,0 +1,185 @@
+$(VAR) = "foo bar baz"
+a
+b
+c
+foo baR baz, bar baz, foo bar baz, fooadd baradd bazadd
+mkdir -p 'dir'
+touch 'dir/obj_1.h'
+mkdir -p 'dir'
+printf '#include "obj_1.h"\nconst char* obj_1 = "dir/obj_1.c";' \
+ >'dir/obj_1.c'
+Local variables
+ $(@)="dir/obj_1.o" $(<)="dir/obj_1.c"
+ $(*)="dir/obj_1" $(?)="dir/obj_1.h dir/obj_1.c"
+ $(%)=""
+
+Directory and filename parts of local variables
+ $(@D)="dir" $(@F)="obj_1.o"
+ $(<D)="dir" $(<F)="obj_1.c"
+ $(*D)="dir" $(*F)="obj_1"
+ $(?D)="dir dir" $(?F)="obj_1.h obj_1.c"
+ $(%D)="" $(%F)=""
+
+Local variable substitutions
+ $(@:.o=)="dir/obj_1" $(<:.c=.C)="dir/obj_1.C"
+ $(*:=.h)="dir/obj_1.h" $(?:.h=.H)="dir/obj_1.H dir/obj_1.c"
+ $(%:=)=""
+
+Target with suffix transformations
+ $(@D:=append)="dirappend"
+ $(@F:.o=.O)="obj_1.O"
+
+ Implied source with suffix transformations
+ $(<D:r=rr)="dirr"
+ $(<F:.c=.C)="obj_1.C"
+
+ Suffixless target with suffix transformations
+ $(*D:.=dot)="dir"
+ $(*F:.a=)="obj_1"
+
+ Out-of-date dependencies with suffix transformations
+ $(?D:ir=)="d d"
+ $(?F:.h=.H)="obj_1.H obj_1.c"
+
+ Member with suffix transformations
+ $(%D:.=)=""
+ $(%F:$(VAR2)=$(VAR))=""
+
+cc -c -o 'dir/obj_1.o' 'dir/obj_1.c'
+mkdir -p '.'
+touch 'dummy'
+Local variables
+ $(@)="lib.a" $(<)="dir/obj_1.o"
+ $(*)="obj1" $(?)="dir/obj_1.o dummy"
+ $(%)="obj1.o"
+
+Directory and filename parts of local variables
+ $(@D)="." $(@F)="lib.a"
+ $(<D)="dir" $(<F)="obj_1.o"
+ $(*D)="." $(*F)="obj1"
+ $(?D)="dir ." $(?F)="obj_1.o dummy"
+ $(%D)="." $(%F)="obj1.o"
+
+Local variable substitutions
+ $(@:.o=)="lib.a" $(<:.c=.C)="dir/obj_1.o"
+ $(*:=.h)="obj1.h" $(?:.h=.H)="dir/obj_1.o dummy"
+ $(%:=)="obj1.o"
+
+Target with suffix transformations
+ $(@D:=append)=".append"
+ $(@F:.o=.O)="lib.a"
+
+ Implied source with suffix transformations
+ $(<D:r=rr)="dirr"
+ $(<F:.c=.C)="obj_1.o"
+
+ Suffixless target with suffix transformations
+ $(*D:.=dot)="dot"
+ $(*F:.a=)="obj1"
+
+ Out-of-date dependencies with suffix transformations
+ $(?D:ir=)="d ."
+ $(?F:.h=.H)="obj_1.o dummy"
+
+ Member with suffix transformations
+ $(%D:.=)=""
+ $(%F:$(VAR2)=$(VAR))="obj1foo bar baz"
+
+cp 'dir/obj_1.o' 'obj1.o'
+ar -rcv 'lib.a' 'obj1.o'
+a - obj1.o
+rm -f 'obj1.o'
+mkdir -p '.'
+printf '#include "obj_2.h"\nconst char* obj_2 = "obj_2.c";' \
+ >'obj_2.c'
+mkdir -p '.'
+touch 'obj_2.h'
+Local variables
+ $(@)="obj2.o" $(<)="obj_2.c"
+ $(*)="obj2" $(?)="obj_2.c obj_2.h dir/obj_1.h"
+ $(%)=""
+
+Directory and filename parts of local variables
+ $(@D)="." $(@F)="obj2.o"
+ $(<D)="." $(<F)="obj_2.c"
+ $(*D)="." $(*F)="obj2"
+ $(?D)=". . dir" $(?F)="obj_2.c obj_2.h obj_1.h"
+ $(%D)="" $(%F)=""
+
+Local variable substitutions
+ $(@:.o=)="obj2" $(<:.c=.C)="obj_2.C"
+ $(*:=.h)="obj2.h" $(?:.h=.H)="obj_2.c obj_2.H dir/obj_1.H"
+ $(%:=)=""
+
+Target with suffix transformations
+ $(@D:=append)=".append"
+ $(@F:.o=.O)="obj2.O"
+
+ Implied source with suffix transformations
+ $(<D:r=rr)="."
+ $(<F:.c=.C)="obj_2.C"
+
+ Suffixless target with suffix transformations
+ $(*D:.=dot)="dot"
+ $(*F:.a=)="obj2"
+
+ Out-of-date dependencies with suffix transformations
+ $(?D:ir=)=". . d"
+ $(?F:.h=.H)="obj_2.c obj_2.H obj_1.H"
+
+ Member with suffix transformations
+ $(%D:.=)=""
+ $(%F:$(VAR2)=$(VAR))=""
+
+cc -c -o 'obj2.o' 'obj_2.c'
+ar -rcv 'lib.a' 'obj2.o'
+a - obj2.o
+mkdir -p '.'
+touch 'obj3.h'
+mkdir -p 'dir'
+touch 'dir/dummy'
+mkdir -p '.'
+printf '#include "obj3.h"\nconst char* obj3 = "obj3.c";' \
+ >'obj3.c'
+Local variables
+ $(@)="lib.a" $(<)="obj3.c"
+ $(*)="obj3" $(?)="obj3.h dir/dummy obj3.c"
+ $(%)="obj3.o"
+
+Directory and filename parts of local variables
+ $(@D)="." $(@F)="lib.a"
+ $(<D)="." $(<F)="obj3.c"
+ $(*D)="." $(*F)="obj3"
+ $(?D)=". dir ." $(?F)="obj3.h dummy obj3.c"
+ $(%D)="." $(%F)="obj3.o"
+
+Local variable substitutions
+ $(@:.o=)="lib.a" $(<:.c=.C)="obj3.C"
+ $(*:=.h)="obj3.h" $(?:.h=.H)="obj3.H dir/dummy obj3.c"
+ $(%:=)="obj3.o"
+
+Target with suffix transformations
+ $(@D:=append)=".append"
+ $(@F:.o=.O)="lib.a"
+
+ Implied source with suffix transformations
+ $(<D:r=rr)="."
+ $(<F:.c=.C)="obj3.C"
+
+ Suffixless target with suffix transformations
+ $(*D:.=dot)="dot"
+ $(*F:.a=)="obj3"
+
+ Out-of-date dependencies with suffix transformations
+ $(?D:ir=)=". d ."
+ $(?F:.h=.H)="obj3.H dummy obj3.c"
+
+ Member with suffix transformations
+ $(%D:.=)=""
+ $(%F:$(VAR2)=$(VAR))="obj3foo bar baz"
+
+cc -c -o 'obj3.o' 'obj3.c'
+ar -rcv 'lib.a' 'obj3.o'
+a - obj3.o
+rm -f 'obj3.o'
+exit status 0
diff -r 25cf428e5a4a -r 47626711b03e usr.bin/make/unit-tests/posix1.mk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/posix1.mk Sat Aug 23 15:02:04 2014 +0000
@@ -0,0 +1,179 @@
+# $NetBSD: posix1.mk,v 1.1 2014/08/23 15:02:04 christos Exp $
+
+# Keep the default suffixes from interfering, just in case.
+.SUFFIXES:
+
+all: line-continuations suffix-substitution localvars
+
+#
+# Line continuations
+#
+
+# Escaped newlines and leading whitespace from the next line are replaced
+# with single space, except in commands, where the escape and the newline
+# are retained, but a single leading tab (if any) from the next line is
+# removed. (PR 49085)
+# Expect:
+# $(VAR) = "foo bar baz"
+# a
+# b
+# c
+VAR = foo\
+\
+ bar\
+ baz
+
+line-continuations:
+ @echo '$$(VAR) = "$(VAR)"'
+ @echo 'aXbXc' | sed -e 's/X/\
+ /g'
+
+
+#
+# Suffix substitution
+#
+
+# The only variable modifier accepted by POSIX.
+# $(VAR:s1=s2): replace s1, if found, with s2 at end of each word in
+# $(VAR). s1 and s2 may contain macro expansions.
+# Expect: foo baR baz, bar baz, foo bar baz, fooadd baradd bazadd
+suffix-substitution:
+ @echo '$(VAR:r=R), $(VAR:foo=), $(VAR:not_there=wrong), $(VAR:=add)'
+
+
+#
+# Local variables: regular forms, D/F forms and suffix substitution.
+#
+
+# In the past substitutions did not work with the D/F forms and those
+# forms were not available for $?. (PR 49085)
+
+ARFLAGS = -rcv
+
+localvars: lib.a
+
+# $@ = target or archive name $< = implied source
+# $* = target without suffix $? = sources newer than target
+# $% = archive member name
+LOCALS = \
+ "Local variables\n\
+ \$$(@)=\"$(@)\" \$$(<)=\"$(<)\"\n\
+ \$$(*)=\"$(*)\" \$$(?)=\"$(?)\"\n\
+ \$$(%%)=\"$(%)\"\n\n"
+
+# $XD = directory part of X $XF = file part of X
+# X is one of the local variables.
+LOCAL_ALTERNATIVES = \
+ "Directory and filename parts of local variables\n\
+ \$$(@D)=\"$(@D)\" \$$(@F)=\"$(@F)\"\n\
+ \$$(<D)=\"$(<D)\" \$$(<F)=\"$(<F)\"\n\
+ \$$(*D)=\"$(*D)\" \$$(*F)=\"$(*F)\"\n\
+ \$$(?D)=\"$(?D)\" \$$(?F)=\"$(?F)\"\n\
+ \$$(%%D)=\"$(%D)\" \$$(%%F)=\"$(%F)\"\n\n"
+
+# Do all kinds of meaningless substitutions on local variables to see
+# if they work. Add, remove and replace things.
+VAR2 = .o
+VAR3 = foo
+LOCAL_SUBSTITUTIONS = \
+ "Local variable substitutions\n\
+ \$$(@:.o=)=\"$(@:.o=)\" \$$(<:.c=.C)=\"$(<:.c=.C)\"\n\
+ \$$(*:=.h)=\"$(*:=.h)\" \$$(?:.h=.H)=\"$(?:.h=.H)\"\n\
+ \$$(%%:=)=\"$(%:=)\"\n\n"
Home |
Main Index |
Thread Index |
Old Index