diff options
author | sjg <sjg@FreeBSD.org> | 2015-04-21 04:40:38 +0000 |
---|---|---|
committer | sjg <sjg@FreeBSD.org> | 2015-04-21 04:40:38 +0000 |
commit | af117d16cb9971b98daadf0901466cbf38bd45b5 (patch) | |
tree | d4404a0b758eb6a0547daa01b5eec4d7df64362f /contrib/bmake/unit-tests | |
parent | 909d1933055072a88a7712a6e880c731d40fce75 (diff) | |
parent | bee1aeb88e274fb1036152cf5e1176049e2dc417 (diff) | |
download | FreeBSD-src-af117d16cb9971b98daadf0901466cbf38bd45b5.zip FreeBSD-src-af117d16cb9971b98daadf0901466cbf38bd45b5.tar.gz |
Merge bmake-20150418
PR: 199486
Diffstat (limited to 'contrib/bmake/unit-tests')
70 files changed, 1452 insertions, 440 deletions
diff --git a/contrib/bmake/unit-tests/Makefile.in b/contrib/bmake/unit-tests/Makefile.in index 3f70f8a..f5f528c 100644 --- a/contrib/bmake/unit-tests/Makefile.in +++ b/contrib/bmake/unit-tests/Makefile.in @@ -1,17 +1,18 @@ -# $Id: Makefile.in,v 1.44 2013/08/28 22:09:29 sjg Exp $ +# $Id: Makefile.in,v 1.46 2014/11/06 01:47:57 sjg Exp $ # -# $NetBSD: Makefile,v 1.38 2013/08/28 21:56:50 sjg Exp $ +# $NetBSD: Makefile,v 1.51 2014/10/20 23:21:11 sjg Exp $ # # Unit tests for make(1) # The main targets are: # # all: run all the tests -# test: run 'all', capture output and compare to expected results +# test: run 'all', and compare to expected results # accept: move generated output to expected results # # Adding a test case. # Each feature should get its own set of tests in its own suitably -# named makefile which should be added to SUBFILES to hook it in. +# named makefile (*.mk), with its own set of expected results (*.exp), +# and it should be added to the TESTNAMES list. # srcdir= @srcdir@ @@ -19,10 +20,11 @@ srcdir= @srcdir@ .MAIN: all UNIT_TESTS:= ${srcdir} +.PATH: ${UNIT_TESTS} -# Simple sub-makefiles - we run them as a black box -# keep the list sorted. -SUBFILES= \ +# Each test is in a sub-makefile. +# Keep the list sorted. +TESTNAMES= \ comment \ cond1 \ error \ @@ -42,7 +44,6 @@ SUBFILES= \ modts \ modword \ order \ - phony-end \ posix \ qequals \ sunshcmd \ @@ -50,23 +51,36 @@ SUBFILES= \ ternary \ unexport \ unexport-env \ - varcmd + varcmd \ + varmisc \ + varshell -all: ${SUBFILES} +# these tests were broken by referting POSIX chanegs +STRICT_POSIX_TESTS = \ + escape \ + impsrc \ + phony-end \ + posix1 \ + suffixes +# Override make flags for certain tests flags.doterror= flags.order=-j1 -# the tests are actually done with sub-makes. -.PHONY: ${SUBFILES} -.PRECIOUS: ${SUBFILES} -${SUBFILES}: - -@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@ +OUTFILES= ${TESTNAMES:S/$/.out/} -clean: - rm -f *.out *.fail *.core +all: ${OUTFILES} -.-include <obj.mk> +CLEANFILES += *.rawout *.out *.status *.tmp *.core *.tmp +CLEANFILES += obj*.[och] lib*.a # posix1.mk +CLEANFILES += issue* .[ab]* # suffixes.mk +CLEANRECURSIVE += dir dummy # posix1.mk + +clean: + rm -f ${CLEANFILES} +.if !empty(CLEANRECURSIVE) + rm -rf ${CLEANRECURSIVE} +.endif TEST_MAKE?= ${.MAKE} TOOL_SED?= sed @@ -81,22 +95,56 @@ LANG= C .export LANG LC_ALL .endif -# The driver. +# some tests need extra post-processing +SED_CMDS.varshell = -e 's,^[a-z]*sh: ,,' \ + -e '/command/s,No such.*,not found,' + +# the tests are actually done with sub-makes. +.SUFFIXES: .mk .rawout .out +.mk.rawout: + @echo ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} + -@cd ${.OBJDIR} && \ + { ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} \ + 2>&1 ; echo $$? >${.TARGET:R}.status ; } > ${.TARGET}.tmp + @mv ${.TARGET}.tmp ${.TARGET} + # We always pretend .MAKE was called 'make' # and strip ${.CURDIR}/ from the output # and replace anything after 'stopped in' with unit-tests # so the results can be compared. -test: - @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1" - @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \ - ${TOOL_TR} -d '\015' | \ - ${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[^:]*:,make:,' \ - -e '/stopped/s, /.*, unit-tests,' \ - -e 's,${.CURDIR:C/\./\\\./g}/,,g' \ - -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \ - tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; } - ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out +.rawout.out: + @echo postprocess ${.TARGET} + @${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[][0-9]*:,make:,' \ + -e 's,${TEST_MAKE:C/\./\\\./g},make,' \ + -e '/stopped/s, /.*, unit-tests,' \ + -e 's,${.CURDIR:C/\./\\\./g}/,,g' \ + -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' ${SED_CMDS.${.TARGET:T:R}} \ + < ${.IMPSRC} > ${.TARGET}.tmp + @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp + @mv ${.TARGET}.tmp ${.TARGET} + +# Compare all output files +test: ${OUTFILES} .PHONY + @failed= ; \ + for test in ${TESTNAMES}; do \ + ${TOOL_DIFF} -u ${UNIT_TESTS}/$${test}.exp $${test}.out \ + || failed="$${failed}$${failed:+ }$${test}" ; \ + done ; \ + if [ -n "$${failed}" ]; then \ + echo "Failed tests: $${failed}" ; false ; \ + else \ + echo "All tests passed" ; \ + fi accept: - mv test.out ${srcdir}/test.exp + @for test in ${TESTNAMES}; do \ + cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \ + || { echo "Replacing $${test}.exp" ; \ + cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \ + done +.if exists(${TEST_MAKE}) +${TESTNAMES:S/$/.rawout/}: ${TEST_MAKE} +.endif + +.-include <obj.mk> diff --git a/contrib/bmake/unit-tests/comment.exp b/contrib/bmake/unit-tests/comment.exp new file mode 100644 index 0000000..9a97df0 --- /dev/null +++ b/contrib/bmake/unit-tests/comment.exp @@ -0,0 +1,5 @@ +comment testing start +this is foo +This is how a comment looks: # comment +comment testing done +exit status 0 diff --git a/contrib/bmake/unit-tests/comment b/contrib/bmake/unit-tests/comment.mk index 7dd7dbb..7dd7dbb 100644 --- a/contrib/bmake/unit-tests/comment +++ b/contrib/bmake/unit-tests/comment.mk diff --git a/contrib/bmake/unit-tests/cond1.exp b/contrib/bmake/unit-tests/cond1.exp new file mode 100644 index 0000000..701d504 --- /dev/null +++ b/contrib/bmake/unit-tests/cond1.exp @@ -0,0 +1,23 @@ +make: "cond1.mk" line 75: warning: extra else +make: "cond1.mk" line 85: warning: extra else +2 is prime +A='other' B='unknown' C='clever' o='no,no' +Passed: + var + ("var") + (var != var) + var != var + !((var != var) && defined(name)) + var == quoted + +1 is not prime +2 is prime +3 is prime +4 is not prime +5 is prime + +make: warning: String comparison operator should be either == or != +make: Bad conditional expression `"0" > 0' in "0" > 0?OK:No + +OK +exit status 0 diff --git a/contrib/bmake/unit-tests/cond1 b/contrib/bmake/unit-tests/cond1.mk index c877c3d..2fc2c7c 100644 --- a/contrib/bmake/unit-tests/cond1 +++ b/contrib/bmake/unit-tests/cond1.mk @@ -1,4 +1,4 @@ -# $Id: cond1,v 1.1.1.3 2011/03/06 00:04:58 sjg Exp $ +# $Id: cond1.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ # hard code these! TEST_UNAME_S= NetBSD diff --git a/contrib/bmake/unit-tests/doterror.exp b/contrib/bmake/unit-tests/doterror.exp new file mode 100644 index 0000000..0447a51 --- /dev/null +++ b/contrib/bmake/unit-tests/doterror.exp @@ -0,0 +1,9 @@ +At first, I am +happy +and now: sad +.ERROR: Looks like 'sad' is upset. +*** Error code 1 + +Stop. +make: stopped in unit-tests +exit status 1 diff --git a/contrib/bmake/unit-tests/doterror b/contrib/bmake/unit-tests/doterror.mk index 75d8920..9030dce 100644 --- a/contrib/bmake/unit-tests/doterror +++ b/contrib/bmake/unit-tests/doterror.mk @@ -1,4 +1,4 @@ -# $Id: doterror,v 1.1.1.1 2010/04/08 17:43:00 sjg Exp $ +# $Id: doterror.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ .BEGIN: diff --git a/contrib/bmake/unit-tests/dotwait.exp b/contrib/bmake/unit-tests/dotwait.exp new file mode 100644 index 0000000..6bf96e3 --- /dev/null +++ b/contrib/bmake/unit-tests/dotwait.exp @@ -0,0 +1,30 @@ +simple.1 +simple.1 +simple.2 +simple.2 +recursive.1.1.* +recursive.1.1.* +recursive.1.1.* +recursive.1.1.* +recursive.1.99 +recursive.1.99 +recursive.2.1.* +recursive.2.1.* +recursive.2.1.* +recursive.2.1.* +recursive.2.99 +recursive.2.99 +shared.0 +shared.0 +shared.1.99 +shared.1.99 +shared.2.1 +shared.2.1 +shared.2.99 +shared.2.99 +make: Graph cycles through `cycle.2.99' +make: Graph cycles through `cycle.2.98' +make: Graph cycles through `cycle.2.97' +cycle.1.99 +cycle.1.99 +exit status 0 diff --git a/contrib/bmake/unit-tests/dotwait b/contrib/bmake/unit-tests/dotwait.mk index 43706af..9bdaaba 100644 --- a/contrib/bmake/unit-tests/dotwait +++ b/contrib/bmake/unit-tests/dotwait.mk @@ -1,4 +1,4 @@ -# $NetBSD: dotwait,v 1.1 2006/02/26 22:45:46 apb Exp $ +# $NetBSD: dotwait.mk,v 1.1 2014/08/21 13:44:51 apb Exp $ THISMAKEFILE:= ${.PARSEDIR}/${.PARSEFILE} diff --git a/contrib/bmake/unit-tests/error.exp b/contrib/bmake/unit-tests/error.exp new file mode 100644 index 0000000..a2bf71b --- /dev/null +++ b/contrib/bmake/unit-tests/error.exp @@ -0,0 +1,4 @@ +make: "error.mk" line 3: just FYI +make: "error.mk" line 4: warning: this could be serious +make: "error.mk" line 5: this is fatal +exit status 1 diff --git a/contrib/bmake/unit-tests/error b/contrib/bmake/unit-tests/error.mk index c0a1403..c6b553e 100644 --- a/contrib/bmake/unit-tests/error +++ b/contrib/bmake/unit-tests/error.mk @@ -1,4 +1,4 @@ -# $Id: error,v 1.1.1.2 2010/05/24 23:36:03 sjg Exp $ +# $Id: error.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ .info just FYI .warning this could be serious diff --git a/contrib/bmake/unit-tests/escape.exp b/contrib/bmake/unit-tests/escape.exp new file mode 100644 index 0000000..6238e27 --- /dev/null +++ b/contrib/bmake/unit-tests/escape.exp @@ -0,0 +1,104 @@ +var-1bs +printf "%s=:%s:\n" VAR1BS 111\\111; printf "%s=:%s:\n" VAR1BSa 111\\aaa; printf "%s=:%s:\n" VAR1BSA 111\\aaa; printf "%s=:%s:\n" VAR1BSda 111\\\$\{a\}; printf "%s=:%s:\n" VAR1BSdA 111\\\$\{A\}; printf "%s=:%s:\n" VAR1BSc 111\#\ backslash\ escapes\ comment\ char,\ so\ this\ is\ part\ of\ the\ value; printf "%s=:%s:\n" VAR1BSsc 111\\\ ; +VAR1BS=:111\111: +VAR1BSa=:111\aaa: +VAR1BSA=:111\aaa: +VAR1BSda=:111\${a}: +VAR1BSdA=:111\${A}: +VAR1BSc=:111# backslash escapes comment char, so this is part of the value: +VAR1BSsc=:111\ : +var-2bs +printf "%s=:%s:\n" VAR2BS 222\\\\222; printf "%s=:%s:\n" VAR2BSa 222\\\\aaa; printf "%s=:%s:\n" VAR2BSA 222\\\\aaa; printf "%s=:%s:\n" VAR2BSda 222\\\\\$\{a\}; printf "%s=:%s:\n" VAR2BSdA 222\\\\\$\{A\}; printf "%s=:%s:\n" VAR2BSc 222\\\\; printf "%s=:%s:\n" VAR2BSsc 222\\\\; +VAR2BS=:222\\222: +VAR2BSa=:222\\aaa: +VAR2BSA=:222\\aaa: +VAR2BSda=:222\\${a}: +VAR2BSdA=:222\\${A}: +VAR2BSc=:222\\: +VAR2BSsc=:222\\: +var-1bsnl +printf "%s=:%s:\n" VAR1BSNL 111\ 111; printf "%s=:%s:\n" VAR1BSNLa 111\ aaa; printf "%s=:%s:\n" VAR1BSNLA 111\ aaa; printf "%s=:%s:\n" VAR1BSNLda 111\ \$\{a\}; printf "%s=:%s:\n" VAR1BSNLdA 111\ \$\{A\}; printf "%s=:%s:\n" VAR1BSNLc 111; printf "%s=:%s:\n" VAR1BSNLsc 111; +VAR1BSNL=:111 111: +VAR1BSNLa=:111 aaa: +VAR1BSNLA=:111 aaa: +VAR1BSNLda=:111 ${a}: +VAR1BSNLdA=:111 ${A}: +VAR1BSNLc=:111: +VAR1BSNLsc=:111: +var-2bsnl +printf "%s=:%s:\n" VAR2BSNL 222\\\\; printf "%s=:%s:\n" VAR2BSNLa 222\\\\; printf "%s=:%s:\n" VAR2BSNLA 222\\\\; printf "%s=:%s:\n" VAR2BSNLda 222\\\\; printf "%s=:%s:\n" VAR2BSNLdA 222\\\\; printf "%s=:%s:\n" VAR2BSNLc 222\\\\; printf "%s=:%s:\n" VAR2BSNLsc 222\\\\; +VAR2BSNL=:222\\: +VAR2BSNLa=:222\\: +VAR2BSNLA=:222\\: +VAR2BSNLda=:222\\: +VAR2BSNLdA=:222\\: +VAR2BSNLc=:222\\: +VAR2BSNLsc=:222\\: +var-3bsnl +printf "%s=:%s:\n" VAR3BSNL 333\\\\\ 333=; printf "%s=:%s:\n" VAR3BSNLa 333\\\\\ aaa=; printf "%s=:%s:\n" VAR3BSNLA 333\\\\\ aaa=; printf "%s=:%s:\n" VAR3BSNLda 333\\\\\ \$\{a\}=; printf "%s=:%s:\n" VAR3BSNLdA 333\\\\\ \$\{A\}=; printf "%s=:%s:\n" VAR3BSNLc 333\\\\; printf "%s=:%s:\n" VAR3BSNLsc 333\\\\; +VAR3BSNL=:333\\ 333=: +VAR3BSNLa=:333\\ aaa=: +VAR3BSNLA=:333\\ aaa=: +VAR3BSNLda=:333\\ ${a}=: +VAR3BSNLdA=:333\\ ${A}=: +VAR3BSNLc=:333\\: +VAR3BSNLsc=:333\\: +var-1bsnl-space +printf "%s=:%s:\n" VAR1BSNL00 first\ line; printf "%s=:%s:\n" VAR1BSNL0 first\ line\ no\ space\ on\ second\ line; printf "%s=:%s:\n" VAR1BSNLs first\ line\ one\ space\ on\ second\ line; printf "%s=:%s:\n" VAR1BSNLss first\ line\ two\ spaces\ on\ second\ line; printf "%s=:%s:\n" VAR1BSNLt first\ line\ one\ tab\ on\ second\ line; printf "%s=:%s:\n" VAR1BSNLtt first\ line\ two\ tabs\ on\ second\ line; printf "%s=:%s:\n" VAR1BSNLxx first\ line\ many\ spaces\ and\ tabs\ \[\ \ \ \ \]\ on\ second\ line; +VAR1BSNL00=:first line: +VAR1BSNL0=:first line no space on second line: +VAR1BSNLs=:first line one space on second line: +VAR1BSNLss=:first line two spaces on second line: +VAR1BSNLt=:first line one tab on second line: +VAR1BSNLtt=:first line two tabs on second line: +VAR1BSNLxx=:first line many spaces and tabs [ ] on second line: +cmd-1bsnl +echo :'first line\ +#second line without space\ +third line': +:first line\ +#second line without space\ +third line: +echo :'first line\ + second line spaces should be retained': +:first line\ + second line spaces should be retained: +echo :'first line\ +second line tab should be elided': +:first line\ +second line tab should be elided: +echo :'first line\ + only one tab should be elided, second tab remains' +:first line\ + only one tab should be elided, second tab remains +cmd-1bsnl-eof +echo :'command ending with backslash-newline'; \ + +:command ending with backslash-newline +cmd-2bsnl +echo take one\\ +take one\ +echo take two\\ +take two\ +echo take three\\ +take three\ +cmd-3bsnl +echo :'first line\\\ +#second line without space\\\ +third line': +:first line\\\ +#second line without space\\\ +third line: +echo :'first line\\\ + second line spaces should be retained': +:first line\\\ + second line spaces should be retained: +echo :'first line\\\ +second line tab should be elided': +:first line\\\ +second line tab should be elided: +echo :'first line\\\ + only one tab should be elided, second tab remains' +:first line\\\ + only one tab should be elided, second tab remains +exit status 0 diff --git a/contrib/bmake/unit-tests/escape.mk b/contrib/bmake/unit-tests/escape.mk new file mode 100644 index 0000000..bb37c92 --- /dev/null +++ b/contrib/bmake/unit-tests/escape.mk @@ -0,0 +1,246 @@ +# $Id: escape.mk,v 1.1.1.2 2014/11/06 01:40:37 sjg Exp $ +# +# Test backslash escaping. + +# Extracts from the POSIX 2008 specification +# <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html>: +# +# Comments start with a <number-sign> ( '#' ) and continue until an +# unescaped <newline> is reached. +# +# When an escaped <newline> (one preceded by a <backslash>) is found +# anywhere in the makefile except in a command line, an include +# line, or a line immediately preceding an include line, it shall +# be replaced, along with any leading white space on the following +# line, with a single <space>. +# +# When an escaped <newline> is found in a command line in a +# makefile, the command line shall contain the <backslash>, the +# <newline>, and the next line, except that the first character of +# the next line shall not be included if it is a <tab>. +# +# When an escaped <newline> is found in an include line or in a +# line immediately preceding an include line, the behavior is +# unspecified. +# +# Notice that the behaviour of <backslash><backslash> or +# <backslash><anything other than newline> is not mentioned. I think +# this implies that <backslash> should be taken literally everywhere +# except before <newline>. +# +# Our practice, despite what POSIX might say, is that "\#" +# in a variable assignment stores "#" as part of the value. +# The "\" is not taken literally, and the "#" does not begin a comment. +# +# Also, our practice is that an even number of backslashes before a +# newline in a variable assignment simply stores the backslashes as part +# of the value, and treats the newline as though it was not escaped. +# Similarly, ann even number of backslashes before a newline in a +# command simply uses the backslashes as part of the command test, but +# does not escape the newline. This is compatible with GNU make. + +all: .PHONY +# We will add dependencies like "all: yet-another-test" later. + +# Some variables to be expanded in tests +# +a = aaa +A = ${a} + +# Backslash at end of line in a comment\ +should continue the comment. \ +# This is also tested in comment.mk. + +__printvars: .USE .MADE + @echo ${.TARGET} + ${.ALLSRC:@v@ printf "%s=:%s:\n" ${v:Q} ${${v}:Q}; @} + +# Embedded backslash in variable should be taken literally. +# +VAR1BS = 111\111 +VAR1BSa = 111\${a} +VAR1BSA = 111\${A} +VAR1BSda = 111\$${a} +VAR1BSdA = 111\$${A} +VAR1BSc = 111\# backslash escapes comment char, so this is part of the value +VAR1BSsc = 111\ # This is a comment. Value ends with <backslash><space> + +all: var-1bs +var-1bs: .PHONY __printvars VAR1BS VAR1BSa VAR1BSA VAR1BSda VAR1BSdA \ + VAR1BSc VAR1BSsc + +# Double backslash in variable should be taken as two literal backslashes. +# +VAR2BS = 222\\222 +VAR2BSa = 222\\${a} +VAR2BSA = 222\\${A} +VAR2BSda = 222\\$${a} +VAR2BSdA = 222\\$${A} +VAR2BSc = 222\\# backslash does not escape comment char, so this is a comment +VAR2BSsc = 222\\ # This is a comment. Value ends with <backslash><backslash> + +all: var-2bs +var-2bs: .PHONY __printvars VAR2BS VAR2BSa VAR2BSA VAR2BSda VAR2BSdA \ + VAR2BSc VAR2BSsc + +# Backslash-newline in a variable setting is replaced by a single space. +# +VAR1BSNL = 111\ +111 +VAR1BSNLa = 111\ +${a} +VAR1BSNLA = 111\ +${A} +VAR1BSNLda = 111\ +$${a} +VAR1BSNLdA = 111\ +$${A} +VAR1BSNLc = 111\ +# this should be processed as a comment +VAR1BSNLsc = 111\ + # this should be processed as a comment + +all: var-1bsnl +var-1bsnl: .PHONY +var-1bsnl: .PHONY __printvars \ + VAR1BSNL VAR1BSNLa VAR1BSNLA VAR1BSNLda VAR1BSNLdA \ + VAR1BSNLc VAR1BSNLsc + +# Double-backslash-newline in a variable setting. +# Both backslashes should be taken literally, and the newline is NOT escaped. +# +# The second lines below each end with '=' so that they will not +# generate syntax errors regardless of whether or not they are +# treated as part of the value. +# +VAR2BSNL = 222\\ +222= +VAR2BSNLa = 222\\ +${a}= +VAR2BSNLA = 222\\ +${A}= +VAR2BSNLda = 222\\ +$${a}= +VAR2BSNLdA = 222\\ +$${A}= +VAR2BSNLc = 222\\ +# this should be processed as a comment +VAR2BSNLsc = 222\\ + # this should be processed as a comment + +all: var-2bsnl +var-2bsnl: .PHONY __printvars \ + VAR2BSNL VAR2BSNLa VAR2BSNLA VAR2BSNLda VAR2BSNLdA \ + VAR2BSNLc VAR2BSNLsc + +# Triple-backslash-newline in a variable setting. +# First two should be taken literally, and last should escape the newline. +# +# The second lines below each end with '=' so that they will not +# generate syntax errors regardless of whether or not they are +# treated as part of the value. +# +VAR3BSNL = 333\\\ +333= +VAR3BSNLa = 333\\\ +${a}= +VAR3BSNLA = 333\\\ +${A}= +VAR3BSNLda = 333\\\ +$${a}= +VAR3BSNLdA = 333\\\ +$${A}= +VAR3BSNLc = 333\\\ +# this should be processed as a comment +VAR3BSNLsc = 333\\\ + # this should be processed as a comment + +all: var-3bsnl +var-3bsnl: .PHONY __printvars \ + VAR3BSNL VAR3BSNLa VAR3BSNLA VAR3BSNLda VAR3BSNLdA \ + VAR3BSNLc VAR3BSNLsc + +# Backslash-newline in a variable setting, plus any amount of white space +# on the next line, is replaced by a single space. +# +VAR1BSNL00= first line\ + +# above line is entirely empty, and this is a comment +VAR1BSNL0= first line\ +no space on second line +VAR1BSNLs= first line\ + one space on second line +VAR1BSNLss= first line\ + two spaces on second line +VAR1BSNLt= first line\ + one tab on second line +VAR1BSNLtt= first line\ + two tabs on second line +VAR1BSNLxx= first line\ + many spaces and tabs [ ] on second line + +all: var-1bsnl-space +var-1bsnl-space: .PHONY __printvars \ + VAR1BSNL00 VAR1BSNL0 VAR1BSNLs VAR1BSNLss VAR1BSNLt VAR1BSNLtt \ + VAR1BSNLxx + +# Backslash-newline in a command is retained. +# +# The "#" in "# second line without space" makes it a comment instead +# of a syntax error if the preceding line is parsed incorretly. +# The ":" in "third line':" makes it look like the start of a +# target instead of a syntax error if the first line is parsed incorrectly. +# +all: cmd-1bsnl +cmd-1bsnl: .PHONY + @echo ${.TARGET} + echo :'first line\ +#second line without space\ +third line': + echo :'first line\ + second line spaces should be retained': + echo :'first line\ + second line tab should be elided': + echo :'first line\ + only one tab should be elided, second tab remains' + +# When backslash-newline appears at the end of a command script, +# both the backslash and the newline should be passed to the shell. +# The shell should elide the backslash-newline. +# +all: cmd-1bsnl-eof +cmd-1bsnl-eof: + @echo ${.TARGET} + echo :'command ending with backslash-newline'; \ + +# above line must be blank + +# Double-backslash-newline in a command. +# Both backslashes are retained, but the newline is not escaped. +# XXX: This may differ from POSIX, but matches gmake. +# +# When make passes two backslashes to the shell, the shell will pass one +# backslash to the echo commant. +# +all: cmd-2bsnl +cmd-2bsnl: .PHONY + @echo ${.TARGET} + echo take one\\ +# this should be a comment + echo take two\\ + echo take three\\ + +# Triple-backslash-newline in a command is retained. +# +all: cmd-3bsnl +cmd-3bsnl: .PHONY + @echo ${.TARGET} + echo :'first line\\\ +#second line without space\\\ +third line': + echo :'first line\\\ + second line spaces should be retained': + echo :'first line\\\ + second line tab should be elided': + echo :'first line\\\ + only one tab should be elided, second tab remains' diff --git a/contrib/bmake/unit-tests/export-all.exp b/contrib/bmake/unit-tests/export-all.exp new file mode 100644 index 0000000..e3aefd4 --- /dev/null +++ b/contrib/bmake/unit-tests/export-all.exp @@ -0,0 +1,12 @@ +UT_ALL=even this gets exported +UT_BADDIR=unit-tests +UT_DOLLAR=This is $UT_FU +UT_F=fine +UT_FOO=foobar is fubar +UT_FU=fubar +UT_NO=all +UT_OK=good +UT_OKDIR=unit-tests +UT_TEST=export-all +UT_ZOO=hoopie +exit status 0 diff --git a/contrib/bmake/unit-tests/export-all b/contrib/bmake/unit-tests/export-all.mk index a243fe3..200412f 100644 --- a/contrib/bmake/unit-tests/export-all +++ b/contrib/bmake/unit-tests/export-all.mk @@ -1,4 +1,4 @@ -# $Id: export-all,v 1.1.1.2 2010/04/21 04:26:14 sjg Exp $ +# $Id: export-all.mk,v 1.1.1.2 2015/04/10 20:43:38 sjg Exp $ UT_OK=good UT_F=fine @@ -17,7 +17,7 @@ UT_OKDIR = ${${here}/../${here:T}:L:${M_tA}:T} .export -.include "export" +.include "export.mk" UT_TEST=export-all UT_ALL=even this gets exported diff --git a/contrib/bmake/unit-tests/export-env.exp b/contrib/bmake/unit-tests/export-env.exp new file mode 100644 index 0000000..6221232 --- /dev/null +++ b/contrib/bmake/unit-tests/export-env.exp @@ -0,0 +1,9 @@ +make: +UT_TEST=export-env.mk +UT_ENV=not-exported +UT_EXP=not-exported +env: +UT_TEST=export-env.mk +UT_ENV=exported +UT_EXP=exported +exit status 0 diff --git a/contrib/bmake/unit-tests/export-env b/contrib/bmake/unit-tests/export-env.mk index b6ce6a2..6b7cd4c 100644 --- a/contrib/bmake/unit-tests/export-env +++ b/contrib/bmake/unit-tests/export-env.mk @@ -1,4 +1,4 @@ -# $Id: export-env,v 1.1.1.1 2013/03/23 02:26:59 sjg Exp $ +# $Id: export-env.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ # our normal .export, subsequent changes affect the environment UT_TEST=this diff --git a/contrib/bmake/unit-tests/export.exp b/contrib/bmake/unit-tests/export.exp new file mode 100644 index 0000000..143771c --- /dev/null +++ b/contrib/bmake/unit-tests/export.exp @@ -0,0 +1,6 @@ +UT_DOLLAR=This is $UT_FU +UT_FOO=foobar is fubar +UT_FU=fubar +UT_TEST=export +UT_ZOO=hoopie +exit status 0 diff --git a/contrib/bmake/unit-tests/export b/contrib/bmake/unit-tests/export.mk index 3e2ad95..01f69f9 100644 --- a/contrib/bmake/unit-tests/export +++ b/contrib/bmake/unit-tests/export.mk @@ -1,4 +1,4 @@ -# $Id: export,v 1.1.1.1 2007/10/08 20:30:12 sjg Exp $ +# $Id: export.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ UT_TEST=export UT_FOO=foo${BAR} diff --git a/contrib/bmake/unit-tests/forloop.exp b/contrib/bmake/unit-tests/forloop.exp new file mode 100644 index 0000000..df14b75 --- /dev/null +++ b/contrib/bmake/unit-tests/forloop.exp @@ -0,0 +1,19 @@ +x=one +x="two and three" +x=four +x="five" +x=-I/this +x=-I"This or that" +x=-Ithat +x="-DTHIS=\"this and that\"" +cfl=-I/this -I"This or that" -Ithat "-DTHIS=\"this and that\"" +a=one b="two and three" +a=four b="five" +a=ONE b="TWO AND THREE" +a=FOUR b="FIVE" +We expect an error next: +make: "forloop.mk" line 38: Wrong number of words (9) in .for substitution list with 2 vars +make: Fatal errors encountered -- cannot continue +make: stopped in unit-tests +OK +exit status 0 diff --git a/contrib/bmake/unit-tests/forloop b/contrib/bmake/unit-tests/forloop.mk index 0b50e66..9aad7c6 100644 --- a/contrib/bmake/unit-tests/forloop +++ b/contrib/bmake/unit-tests/forloop.mk @@ -1,4 +1,4 @@ -# $Id: forloop,v 1.1.1.1 2012/06/19 23:30:49 sjg Exp $ +# $Id: forloop.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ all: for-loop diff --git a/contrib/bmake/unit-tests/forsubst.exp b/contrib/bmake/unit-tests/forsubst.exp new file mode 100644 index 0000000..0a98c00 --- /dev/null +++ b/contrib/bmake/unit-tests/forsubst.exp @@ -0,0 +1,2 @@ +.for with :S;... OK +exit status 0 diff --git a/contrib/bmake/unit-tests/forsubst b/contrib/bmake/unit-tests/forsubst.mk index d3a7de1..2923e4b 100644 --- a/contrib/bmake/unit-tests/forsubst +++ b/contrib/bmake/unit-tests/forsubst.mk @@ -1,4 +1,4 @@ -# $Id: forsubst,v 1.1.1.1 2009/10/07 18:53:35 sjg Exp $ +# $Id: forsubst.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ all: for-subst diff --git a/contrib/bmake/unit-tests/hash.exp b/contrib/bmake/unit-tests/hash.exp new file mode 100644 index 0000000..0a24234 --- /dev/null +++ b/contrib/bmake/unit-tests/hash.exp @@ -0,0 +1,9 @@ +b2af338b +3360ac65 +7747f046 +9ca87054 +880fe816 +208fcbd3 +d5d376eb +de41416c +exit status 0 diff --git a/contrib/bmake/unit-tests/hash b/contrib/bmake/unit-tests/hash.mk index 1ed84e7..1ed84e7 100644 --- a/contrib/bmake/unit-tests/hash +++ b/contrib/bmake/unit-tests/hash.mk diff --git a/contrib/bmake/unit-tests/impsrc.exp b/contrib/bmake/unit-tests/impsrc.exp new file mode 100644 index 0000000..23e8347 --- /dev/null +++ b/contrib/bmake/unit-tests/impsrc.exp @@ -0,0 +1,13 @@ +expected: source4 +actual: source4 +expected: target1.x +actual: target1.x +expected: target1.y +actual: target1.y +expected: source1 +actual: source1 +expected: source2 +actual: source2 +expected: source1 +actual: source1 +exit status 0 diff --git a/contrib/bmake/unit-tests/impsrc.mk b/contrib/bmake/unit-tests/impsrc.mk new file mode 100644 index 0000000..95ae0c3 --- /dev/null +++ b/contrib/bmake/unit-tests/impsrc.mk @@ -0,0 +1,43 @@ +# $NetBSD: impsrc.mk,v 1.2 2014/08/30 22:21:07 sjg Exp $ + +# Does ${.IMPSRC} work properly? +# It should be set, in order of precedence, to ${.TARGET} of: +# 1) the implied source of a transformation rule, +# 2) the first prerequisite from the dependency line of an explicit rule, or +# 3) the first prerequisite of an explicit rule. +# + +all: target1.z target2 target3 target4 + +.SUFFIXES: .x .y .z + +.x.y: source1 + @echo 'expected: target1.x' + @echo 'actual: $<' + +.y.z: source2 + @echo 'expected: target1.y' + @echo 'actual: $<' + +target1.y: source3 + +target1.x: source4 + @echo 'expected: source4' + @echo 'actual: $<' + +target2: source1 source2 + @echo 'expected: source1' + @echo 'actual: $<' + +target3: source1 +target3: source2 source3 + @echo 'expected: source2' + @echo 'actual: $<' + +target4: source1 +target4: + @echo 'expected: source1' + @echo 'actual: $<' + +source1 source2 source3 source4: + diff --git a/contrib/bmake/unit-tests/misc.exp b/contrib/bmake/unit-tests/misc.exp new file mode 100644 index 0000000..39a9383 --- /dev/null +++ b/contrib/bmake/unit-tests/misc.exp @@ -0,0 +1 @@ +exit status 0 diff --git a/contrib/bmake/unit-tests/misc b/contrib/bmake/unit-tests/misc.mk index 4ba3655..0301150 100644 --- a/contrib/bmake/unit-tests/misc +++ b/contrib/bmake/unit-tests/misc.mk @@ -1,4 +1,4 @@ -# $Id: misc,v 1.1.1.1 2011/03/06 00:04:58 sjg Exp $ +# $Id: misc.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ .if !exists(${.CURDIR}/) .warning ${.CURDIR}/ doesn't exist ? diff --git a/contrib/bmake/unit-tests/moderrs.exp b/contrib/bmake/unit-tests/moderrs.exp new file mode 100644 index 0000000..cb51aa0 --- /dev/null +++ b/contrib/bmake/unit-tests/moderrs.exp @@ -0,0 +1,16 @@ +Expect: Unknown modifier 'Z' +make: Unknown modifier 'Z' +VAR:Z= +Expect: Unknown modifier 'Z' +make: Unknown modifier 'Z' +VAR:Z= +Expect: Unclosed variable specification for VAR +make: Unclosed variable specification (expecting '}') for "VAR" (value "Thevariable") modifier S +VAR:S,V,v,=Thevariable +Expect: Unclosed variable specification for VAR +make: Unclosed variable specification after complex modifier (expecting '}') for VAR +VAR:S,V,v,=Thevariable +Expect: Unclosed substitution for VAR (, missing) +make: Unclosed substitution for VAR (, missing) +VAR:S,V,v= +exit status 0 diff --git a/contrib/bmake/unit-tests/moderrs b/contrib/bmake/unit-tests/moderrs.mk index b8f78ce..d0eb17f 100644 --- a/contrib/bmake/unit-tests/moderrs +++ b/contrib/bmake/unit-tests/moderrs.mk @@ -1,4 +1,4 @@ -# $Id: moderrs,v 1.2 2006/05/11 18:53:39 sjg Exp $ +# $Id: moderrs.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ # # various modifier error tests diff --git a/contrib/bmake/unit-tests/modmatch.exp b/contrib/bmake/unit-tests/modmatch.exp new file mode 100644 index 0000000..fcaf6c0 --- /dev/null +++ b/contrib/bmake/unit-tests/modmatch.exp @@ -0,0 +1,17 @@ +LIB=a X_LIBS:M${LIB${LIB:tu}} is "/tmp/liba.a" +LIB=a X_LIBS:M*/lib${LIB}.a is "/tmp/liba.a" +LIB=a X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBA.A" +LIB=b X_LIBS:M${LIB${LIB:tu}} is "" +LIB=b X_LIBS:M*/lib${LIB}.a is "" +LIB=b X_LIBS:M*/lib${LIB}.a:tu is "" +LIB=c X_LIBS:M${LIB${LIB:tu}} is "" +LIB=c X_LIBS:M*/lib${LIB}.a is "" +LIB=c X_LIBS:M*/lib${LIB}.a:tu is "" +LIB=d X_LIBS:M${LIB${LIB:tu}} is "/tmp/libd.a" +LIB=d X_LIBS:M*/lib${LIB}.a is "/tmp/libd.a" +LIB=d X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBD.A" +LIB=e X_LIBS:M${LIB${LIB:tu}} is "/tmp/libe.a" +LIB=e X_LIBS:M*/lib${LIB}.a is "/tmp/libe.a" +LIB=e X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBE.A" +Mscanner=OK +exit status 0 diff --git a/contrib/bmake/unit-tests/modmatch b/contrib/bmake/unit-tests/modmatch.mk index 48a1bef..48a1bef 100644 --- a/contrib/bmake/unit-tests/modmatch +++ b/contrib/bmake/unit-tests/modmatch.mk diff --git a/contrib/bmake/unit-tests/modmisc.exp b/contrib/bmake/unit-tests/modmisc.exp new file mode 100644 index 0000000..e406647 --- /dev/null +++ b/contrib/bmake/unit-tests/modmisc.exp @@ -0,0 +1,10 @@ +path=':/bin:/tmp::/:.:/no/such/dir:.' +path='/bin:/tmp:/:/no/such/dir' +path='/bin:/tmp:/:/no/such/dir' +path='/bin':'/tmp':'/':'/no/such/dir' +path='/bin':'/tmp':'/':'/no/such/dir' +path_/usr/xbin=/opt/xbin/ +paths=/bin /tmp / /no/such/dir /opt/xbin +PATHS=/BIN /TMP / /NO/SUCH/DIR /OPT/XBIN +The answer is 42 +exit status 0 diff --git a/contrib/bmake/unit-tests/modmisc b/contrib/bmake/unit-tests/modmisc.mk index d562e46..043498f 100644 --- a/contrib/bmake/unit-tests/modmisc +++ b/contrib/bmake/unit-tests/modmisc.mk @@ -1,4 +1,4 @@ -# $Id: modmisc,v 1.1.1.5 2011/04/11 15:10:32 sjg Exp $ +# $Id: modmisc.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ # # miscellaneous modifier tests diff --git a/contrib/bmake/unit-tests/modorder.exp b/contrib/bmake/unit-tests/modorder.exp new file mode 100644 index 0000000..4117427 --- /dev/null +++ b/contrib/bmake/unit-tests/modorder.exp @@ -0,0 +1,11 @@ +LIST = one two three four five six seven eight nine ten +LIST:O = eight five four nine one seven six ten three two +LIST:Ox = Ok +LIST:O:Ox = Ok +LISTX = Ok +LISTSX = Ok +make: Bad modifier `:OX' for LIST +BADMOD 1 = } +make: Bad modifier `:OxXX' for LIST +BADMOD 2 = XX} +exit status 0 diff --git a/contrib/bmake/unit-tests/modorder b/contrib/bmake/unit-tests/modorder.mk index 68b66fb..bc24d33 100644 --- a/contrib/bmake/unit-tests/modorder +++ b/contrib/bmake/unit-tests/modorder.mk @@ -1,4 +1,4 @@ -# $NetBSD: modorder,v 1.2 2007/10/05 15:27:46 sjg Exp $ +# $NetBSD: modorder.mk,v 1.1 2014/08/21 13:44:51 apb Exp $ LIST= one two three four five six seven eight nine ten LISTX= ${LIST:Ox} diff --git a/contrib/bmake/unit-tests/modts.exp b/contrib/bmake/unit-tests/modts.exp new file mode 100644 index 0000000..cf3c91d --- /dev/null +++ b/contrib/bmake/unit-tests/modts.exp @@ -0,0 +1,33 @@ +LIST="one two three four five six" +LIST:ts,="one,two,three,four,five,six" +LIST:ts/:tu="ONE/TWO/THREE/FOUR/FIVE/SIX" +LIST:ts::tu="ONE:TWO:THREE:FOUR:FIVE:SIX" +LIST:ts:tu="ONETWOTHREEFOURFIVESIX" +LIST:tu:ts/="ONE/TWO/THREE/FOUR/FIVE/SIX" +LIST:ts:="one:two:three:four:five:six" +LIST:ts="onetwothreefourfivesix" +LIST:ts:S/two/2/="one2threefourfivesix" +LIST:S/two/2/:ts="one2threefourfivesix" +LIST:ts/:S/two/2/="one/2/three/four/five/six" +Pretend the '/' in '/n' etc. below are back-slashes. +LIST:ts/n="one +two +three +four +five +six" +LIST:ts/t="one two three four five six" +LIST:ts/012:tu="ONE +TWO +THREE +FOUR +FIVE +SIX" +make: Bad modifier `:tx' for LIST +LIST:tx="}" +make: Bad modifier `:ts\x' for LIST +LIST:ts/x:tu="\x:tu}" +FU_mod-ts="a/b/cool" +FU_mod-ts:ts:T="cool" == cool? +B.${AAA:ts}="Baaa" == Baaa? +exit status 0 diff --git a/contrib/bmake/unit-tests/modts b/contrib/bmake/unit-tests/modts.mk index 616bd89..616bd89 100644 --- a/contrib/bmake/unit-tests/modts +++ b/contrib/bmake/unit-tests/modts.mk diff --git a/contrib/bmake/unit-tests/modword.exp b/contrib/bmake/unit-tests/modword.exp new file mode 100644 index 0000000..258d7ea --- /dev/null +++ b/contrib/bmake/unit-tests/modword.exp @@ -0,0 +1,122 @@ +make: Bad modifier `:[]' for LIST +LIST:[]="" is an error +LIST:[0]="one two three four five six" +LIST:[0x0]="one two three four five six" +LIST:[000]="one two three four five six" +LIST:[*]="one two three four five six" +LIST:[@]="one two three four five six" +LIST:[0]:C/ /,/="one,two three four five six" +LIST:[0]:C/ /,/g="one,two,three,four,five,six" +LIST:[0]:C/ /,/1g="one,two,three,four,five,six" +LIST:[*]:C/ /,/="one,two three four five six" +LIST:[*]:C/ /,/g="one,two,three,four,five,six" +LIST:[*]:C/ /,/1g="one,two,three,four,five,six" +LIST:[@]:C/ /,/="one two three four five six" +LIST:[@]:C/ /,/g="one two three four five six" +LIST:[@]:C/ /,/1g="one two three four five six" +LIST:[@]:[0]:C/ /,/="one,two three four five six" +LIST:[0]:[@]:C/ /,/="one two three four five six" +LIST:[@]:[*]:C/ /,/="one,two three four five six" +LIST:[*]:[@]:C/ /,/="one two three four five six" +EMPTY="" +EMPTY:[#]="1" == 1 ? +ESCAPEDSPACE="\ " +ESCAPEDSPACE:[#]="1" == 1 ? +REALLYSPACE=" " +REALLYSPACE:[#]="1" == 1 ? +LIST:[#]="6" +LIST:[0]:[#]="1" == 1 ? +LIST:[*]:[#]="1" == 1 ? +LIST:[@]:[#]="6" +LIST:[1]:[#]="1" +LIST:[1..3]:[#]="3" +EMPTY:[1]="" +ESCAPEDSPACE="\ " +ESCAPEDSPACE:[1]="\ " +REALLYSPACE=" " +REALLYSPACE:[1]="" == "" ? +REALLYSPACE:[*]:[1]=" " == " " ? +LIST:[1]="one" +make: Bad modifier `:[1.]' for LIST +LIST:[1.]="" is an error +make: Bad modifier `:[1].' for LIST +LIST:[1].="}" is an error +LIST:[2]="two" +LIST:[6]="six" +LIST:[7]="" +LIST:[999]="" +make: Bad modifier `:[-]' for LIST +LIST:[-]="" is an error +make: Bad modifier `:[--]' for LIST +LIST:[--]="" is an error +LIST:[-1]="six" +LIST:[-2]="five" +LIST:[-6]="one" +LIST:[-7]="" +LIST:[-999]="" +LONGLIST:[17]="17" +LONGLIST:[0x11]="17" +LONGLIST:[021]="17" +LIST:[0]:[1]="one two three four five six" +LIST:[*]:[1]="one two three four five six" +LIST:[@]:[1]="one" +LIST:[0]:[2]="" +LIST:[*]:[2]="" +LIST:[@]:[2]="two" +LIST:[*]:C/ /,/:[2]="" +LIST:[*]:C/ /,/:[*]:[2]="" +LIST:[*]:C/ /,/:[@]:[2]="three" +make: Bad modifier `:[1.]' for LIST +LIST:[1.]="" is an error +make: Bad modifier `:[1..]' for LIST +LIST:[1..]="" is an error +LIST:[1..1]="one" +make: Bad modifier `:[1..1.]' for LIST +LIST:[1..1.]="" is an error +LIST:[1..2]="one two" +LIST:[2..1]="two one" +LIST:[3..-2]="three four five" +LIST:[-4..4]="three four" +make: Bad modifier `:[0..1]' for LIST +LIST:[0..1]="" is an error +make: Bad modifier `:[-1..0]' for LIST +LIST:[-1..0]="" is an error +LIST:[-1..1]="six five four three two one" +LIST:[0..0]="one two three four five six" +LIST:[3..99]="three four five six" +LIST:[-3..-99]="four three two one" +LIST:[-99..-3]="one two three four" +HASH="#" == "#" ? +LIST:[${HASH}]="6" +LIST:[${ZERO}]="one two three four five six" +LIST:[${ZERO}x${ONE}]="one" +LIST:[${ONE}]="one" +LIST:[${MINUSONE}]="six" +LIST:[${STAR}]="one two three four five six" +LIST:[${AT}]="one two three four five six" +make: Bad modifier `:[${EMPTY' for LIST +LIST:[${EMPTY}]="" is an error +LIST:[${LONGLIST:[21]:S/2//}]="one" +LIST:[${LIST:[#]}]="six" +LIST:[${LIST:[${HASH}]}]="six" +LIST:S/ /,/="one two three four five six" +LIST:S/ /,/W="one,two three four five six" +LIST:S/ /,/gW="one,two,three,four,five,six" +EMPTY:S/^/,/="," +EMPTY:S/^/,/W="," +LIST:C/ /,/="one two three four five six" +LIST:C/ /,/W="one,two three four five six" +LIST:C/ /,/gW="one,two,three,four,five,six" +EMPTY:C/^/,/="," +EMPTY:C/^/,/W="," +LIST:tW="one two three four five six" +LIST:tw="one two three four five six" +LIST:tW:C/ /,/="one,two three four five six" +LIST:tW:C/ /,/g="one,two,three,four,five,six" +LIST:tW:C/ /,/1g="one,two,three,four,five,six" +LIST:tw:C/ /,/="one two three four five six" +LIST:tw:C/ /,/g="one two three four five six" +LIST:tw:C/ /,/1g="one two three four five six" +LIST:tw:tW:C/ /,/="one,two three four five six" +LIST:tW:tw:C/ /,/="one two three four five six" +exit status 0 diff --git a/contrib/bmake/unit-tests/modword b/contrib/bmake/unit-tests/modword.mk index 39355d7..1327624 100644 --- a/contrib/bmake/unit-tests/modword +++ b/contrib/bmake/unit-tests/modword.mk @@ -1,4 +1,4 @@ -# $Id: modword,v 1.1.1.1 2003/09/28 17:01:48 sjg Exp $ +# $Id: modword.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ # # Test behaviour of new :[] modifier diff --git a/contrib/bmake/unit-tests/order.exp b/contrib/bmake/unit-tests/order.exp new file mode 100644 index 0000000..d876914 --- /dev/null +++ b/contrib/bmake/unit-tests/order.exp @@ -0,0 +1,4 @@ +Making the.c +Making the.h +Making the.o from the.h the.c +exit status 0 diff --git a/contrib/bmake/unit-tests/order b/contrib/bmake/unit-tests/order.mk index 175da47..f90b627 100644 --- a/contrib/bmake/unit-tests/order +++ b/contrib/bmake/unit-tests/order.mk @@ -1,4 +1,4 @@ -# $NetBSD: order,v 1.1 2012/11/09 19:08:28 sjg Exp $ +# $NetBSD: order.mk,v 1.1 2014/08/21 13:44:51 apb Exp $ # Test that .ORDER is handled correctly. # The explicit dependency the.o: the.h will make us examine the.h diff --git a/contrib/bmake/unit-tests/phony-end.exp b/contrib/bmake/unit-tests/phony-end.exp new file mode 100644 index 0000000..c3c517c --- /dev/null +++ b/contrib/bmake/unit-tests/phony-end.exp @@ -0,0 +1,6 @@ +.TARGET="phony" .PREFIX="phony" .IMPSRC="" +.TARGET="all" .PREFIX="all" .IMPSRC="phony" +.TARGET="ok" .PREFIX="ok" .IMPSRC="" +.TARGET="also.ok" .PREFIX="also.ok" .IMPSRC="" +.TARGET="bug" .PREFIX="bug" .IMPSRC="" +exit status 0 diff --git a/contrib/bmake/unit-tests/phony-end b/contrib/bmake/unit-tests/phony-end.mk index d61884c..07f4b02 100644 --- a/contrib/bmake/unit-tests/phony-end +++ b/contrib/bmake/unit-tests/phony-end.mk @@ -1,4 +1,4 @@ -# $Id: phony-end,v 1.1.1.1 2011/10/01 17:19:39 sjg Exp $ +# $Id: phony-end.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ all ok also.ok bug phony: @echo '${.TARGET .PREFIX .IMPSRC:L:@v@$v="${$v}"@}' diff --git a/contrib/bmake/unit-tests/posix.exp b/contrib/bmake/unit-tests/posix.exp new file mode 100644 index 0000000..7e74cab --- /dev/null +++ b/contrib/bmake/unit-tests/posix.exp @@ -0,0 +1,23 @@ +Posix says we should execute the command as if run by system(3) +Expect 'Hello,' and 'World!' +Hello, +World! +a command +a command prefixed by '+' executes even with -n +another command +make -n +echo a command +echo "a command prefixed by '+' executes even with -n" +a command prefixed by '+' executes even with -n +echo another command +make -n -j1 +{ echo a command +} || exit $? +echo "a command prefixed by '+' executes even with -n" +a command prefixed by '+' executes even with -n +{ echo another command +} || exit $? +Now we expect an error... +*** Error code 1 (continuing) +`all' not remade because of errors. +exit status 0 diff --git a/contrib/bmake/unit-tests/posix b/contrib/bmake/unit-tests/posix.mk index 48ed7a3..608a24a 100644 --- a/contrib/bmake/unit-tests/posix +++ b/contrib/bmake/unit-tests/posix.mk @@ -1,4 +1,4 @@ -# $Id: posix,v 1.1.1.1 2004/05/08 16:45:39 sjg Exp $ +# $Id: posix.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ all: x plus subs err diff --git a/contrib/bmake/unit-tests/posix1.exp b/contrib/bmake/unit-tests/posix1.exp new file mode 100644 index 0000000..92809e6 --- /dev/null +++ b/contrib/bmake/unit-tests/posix1.exp @@ -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";\n' \ + >'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";\n' \ + >'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";\n' \ + >'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 --git a/contrib/bmake/unit-tests/posix1.mk b/contrib/bmake/unit-tests/posix1.mk new file mode 100644 index 0000000..50b0a63 --- /dev/null +++ b/contrib/bmake/unit-tests/posix1.mk @@ -0,0 +1,184 @@ +# $NetBSD: posix1.mk,v 1.3 2014/08/30 22:21:08 sjg Exp $ + +# Keep the default suffixes from interfering, just in case. +.SUFFIXES: + +all: line-continuations suffix-substitution localvars + +# we need to clean for repeatable results +.BEGIN: clean +clean: + @rm -f lib.a dir/* dummy obj* + +# +# 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" + +LOCAL_ALTERNATIVE_SUBSTITUTIONS = \ + "Target with suffix transformations\n\ + \$${@D:=append}=\"${@D:=append}\"\n\ + \$${@F:.o=.O}=\"${@F:.o=.O}\"\n\ + \n\ + Implied source with suffix transformations\n\ + \$${<D:r=rr}=\"${<D:r=rr}\"\n\ + \$${<F:.c=.C}=\"${<F:.c=.C}\"\n\ + \n\ + Suffixless target with suffix transformations\n\ + \$${*D:.=dot}=\"${*D:.=dot}\"\n\ + \$${*F:.a=}=\"${*F:.a=}\"\n\ + \n\ + Out-of-date dependencies with suffix transformations\n\ + \$${?D:ir=}=\"${?D:ir=}\"\n\ + \$${?F:.h=.H}=\"${?F:.h=.H}\"\n\ + \n\ + Member with suffix transformations\n\ + \$${%%D:.=}=\"${%D:.=}\"\n\ + \$${%%F:\$${VAR2}=\$${VAR}}=\"${%F:${VAR2}=${VAR}}\"\n\n" + +.SUFFIXES: .c .o .a + +# The system makefiles make the .c.a rule .PRECIOUS with a special source, +# but such a thing is not POSIX compatible. It's also somewhat useless +# in a test makefile. +.c.a: + @printf ${LOCALS} + @printf ${LOCAL_ALTERNATIVES} + @printf ${LOCAL_SUBSTITUTIONS} + @printf ${LOCAL_ALTERNATIVE_SUBSTITUTIONS} + cc -c -o '${%}' '${<}' + ar ${ARFLAGS} '${@}' '${%}' + rm -f '${%}' + +.c.o: + @printf ${LOCALS} + @printf ${LOCAL_ALTERNATIVES} + @printf ${LOCAL_SUBSTITUTIONS} + @printf ${LOCAL_ALTERNATIVE_SUBSTITUTIONS} + cc -c -o '${@}' '${<}' + +# Some of these rules are padded with useless extra dependencies just so +# that ${?} has more than one file. + +lib.a: lib.a(obj1.o) lib.a(obj2.o) lib.a(obj3.o) + @ar -s '${@}' + +# Explicit rule where the dependency is an inferred file. The dependency +# object's name differs from the member's because there was a bug which +# forced a dependency on member even when no such dependency was specified +# (PR 49086). +lib.a(obj1.o): dir/obj_1.o dummy + @printf ${LOCALS} + @printf ${LOCAL_ALTERNATIVES} + @printf ${LOCAL_SUBSTITUTIONS} + @printf ${LOCAL_ALTERNATIVE_SUBSTITUTIONS} + cp 'dir/obj_1.o' '$%' + ar ${ARFLAGS} '${@}' '$%' + rm -f '$%' + +# Excplicit rule where the dependency also has an explicit rule. +lib.a(obj2.o): obj2.o + ar ${ARFLAGS} '${@}' '${%}' + +# Use .c.a inference with an extra dependency. +lib.a(obj3.o): obj3.h dir/dummy + +# Use .c.o inference with an extra dependency. +dir/obj_1.o: dir/obj_1.h + +# According to POSIX, $* is only required for inference rules and $<'s +# value is unspecified outside of inference rules. Strictly speaking +# we shouldn't be expanding them here but who cares. At least we get +# to check that the program does nothing stupid (like crash) with them. +# The C file is named differently from the object file because there +# was a bug which forced dependencies based on inference rules on all +# applicable targets (PR 49086). +obj2.o: obj_2.c obj_2.h dir/obj_1.h + @printf ${LOCALS} + @printf ${LOCAL_ALTERNATIVES} + @printf ${LOCAL_SUBSTITUTIONS} + @printf ${LOCAL_ALTERNATIVE_SUBSTITUTIONS} + cc -c -o '${@}' 'obj_2.c' + +# Hey, this is make, we can make our own test data setup! obj1.c +# and obj2.c are not used, so they should not get created. They're here +# as a bait for a regression into the forced dependencies discussed earlier. +obj1.c dir/obj_1.c obj2.c obj_2.c obj3.c: + mkdir -p '${@D}' + printf '#include "${@F:.c=.h}"\nconst char* ${@F:.c=} = "${@}";\n' \ + >'${@}' + +dir/obj_1.h obj_2.h obj3.h dummy dir/dummy: + mkdir -p '${@D}' + touch '${@}' diff --git a/contrib/bmake/unit-tests/qequals.exp b/contrib/bmake/unit-tests/qequals.exp new file mode 100644 index 0000000..6b2f4dc --- /dev/null +++ b/contrib/bmake/unit-tests/qequals.exp @@ -0,0 +1,2 @@ +V.i386 ?= OK +exit status 0 diff --git a/contrib/bmake/unit-tests/qequals b/contrib/bmake/unit-tests/qequals.mk index e23078e..67a48ad 100644 --- a/contrib/bmake/unit-tests/qequals +++ b/contrib/bmake/unit-tests/qequals.mk @@ -1,4 +1,4 @@ -# $Id: qequals,v 1.1.1.1 2008/03/31 00:13:05 sjg Exp $ +# $Id: qequals.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ M= i386 V.i386= OK diff --git a/contrib/bmake/unit-tests/suffixes.exp b/contrib/bmake/unit-tests/suffixes.exp new file mode 100644 index 0000000..2a46e1c --- /dev/null +++ b/contrib/bmake/unit-tests/suffixes.exp @@ -0,0 +1,35 @@ +make: don't know how to make issue3 (continuing) +There should be no text after the colon: +touch .a +There should be no text after the colon: +touch .a.b +There should be no text after the colon: +touch .b.a +touch issue5a.c +first set +cp issue5a.c issue5a.d +touch issue5b.d +first set +cp issue5b.d issue5b.c +touch issue5c.d +first set +cp issue5c.d issue5c +touch issue5d.d +first set +cp issue5d.d issue5d.e +touch issue5e.e +first set +cp issue5e.e issue5e.d +make: don't know how to make issue6.f (continuing) +touch issue10.d +first set +cp issue10.d issue10.e +touch issue11.h +touch issue11.first +.ALLSRC: issue11.h issue11.first +cp issue11.h issue11.i +touch issue11.second +.ALLSRC: issue11.i issue11.second +cp issue11.i issue11.j +`all' not remade because of errors. +exit status 0 diff --git a/contrib/bmake/unit-tests/suffixes.mk b/contrib/bmake/unit-tests/suffixes.mk new file mode 100644 index 0000000..113484a --- /dev/null +++ b/contrib/bmake/unit-tests/suffixes.mk @@ -0,0 +1,89 @@ +# $NetBSD: suffixes.mk,v 1.3 2014/08/30 22:21:08 sjg Exp $ + +# Issues from PR 49086 + +# Issue 3: single suffix rules remain active after .SUFFIXES is cleared +# +# There's a rule for issue3.a, but .a is no longer a known suffix when +# targets are being made, so issue3 should not get made. +all: issue3 + +# Issue 4: suffix rules do not become regular rules when .SUFFIXES is cleared +# +# When the rules were encountered, .a and .b were known suffices, but later +# on they were forgotten. These should get created as regular targets. +all: .a .a.b .b.a + +# Issue 5: adding more suffixes does not make existing rules into suffix rules +# +# When the targets .c.d, .d.c, .d, .d.e, and .e.d were encountered, only .a, +# .b and .c were known suffixes, so all of them were regular rules. Later +# rest of the suffixes were made known, so they should all be suffix +# transformation rules. +all: issue5a.d issue5b.c issue5c issue5d.e issue5e.d + +# Issue 6: transformation search can end up in an infinite loop +# +# There is no file or target from which issue6.f could be made from so +# this should fail. The bug was that because rules .e.f, .d.e and .e.d +# exist, make would try to make .f from .e and then infinitely try +# to do .e from .d and vice versa. +all: issue6.f + +# Issue 10: explicit dependencies affect transformation rule selection +# +# If issue10.e is wanted and both issue10.d and issue10.f are available, +# make should choose the .d.e rule, because .d is before .f in .SUFFIXES. +# The bug was that if issue10.d had an explicit dependency on issue10.f, +# it would choose .f.e instead. +all: issue10.e + +# Issue 11: sources from transformation rules are expanded incorrectly +# +# issue11.j should depend on issue11.i and issue11.second and issue11.i +# should depend on issue11.h and issue11.first. The bug was that +# the dynamic sources were expanded before ${.PREFIX} and ${.TARGET} were +# available, so they would have expanded to a null string. +all: issue11.j + +# we need to clean for repeatable results +.BEGIN: clean +clean: + @rm -f issue* .[ab]* + +.SUFFIXES: .a .b .c + +.a .a.b .b.a: + @echo 'There should be no text after the colon: ${.IMPSRC}' + touch ${.TARGET} + +.c.d .d.c .d .d.e .e.d: + @echo 'first set' + cp ${.IMPSRC} ${.TARGET} + +.SUFFIXES: +.SUFFIXES: .c .d .e .f .g + +.e .e.f .f.e: + @echo 'second set' + cp ${.IMPSRC} ${.TARGET} + +issue3.a: + @echo 'There is a bug if you see this.' + touch ${.TARGET} + +issue5a.c issue5b.d issue5c.d issue5d.d issue5e.e issue10.d issue10.f: + touch ${.TARGET} + +.SUFFIXES: .h .i .j + +.h.i: ${.PREFIX}.first + @echo '.ALLSRC: ${.ALLSRC}' + cp ${.IMPSRC} ${.TARGET} + +.i.j: ${.PREFIX}.second + @echo '.ALLSRC: ${.ALLSRC}' + cp ${.IMPSRC} ${.TARGET} + +issue11.h issue11.first issue11.second: + touch ${.TARGET} diff --git a/contrib/bmake/unit-tests/sunshcmd.exp b/contrib/bmake/unit-tests/sunshcmd.exp new file mode 100644 index 0000000..b14f6b6 --- /dev/null +++ b/contrib/bmake/unit-tests/sunshcmd.exp @@ -0,0 +1,4 @@ +TEST1=hello +TEST2=bye +TEST3=later +exit status 0 diff --git a/contrib/bmake/unit-tests/sunshcmd b/contrib/bmake/unit-tests/sunshcmd.mk index e3baf90..e3baf90 100644 --- a/contrib/bmake/unit-tests/sunshcmd +++ b/contrib/bmake/unit-tests/sunshcmd.mk diff --git a/contrib/bmake/unit-tests/sysv.exp b/contrib/bmake/unit-tests/sysv.exp new file mode 100644 index 0000000..4cce2de --- /dev/null +++ b/contrib/bmake/unit-tests/sysv.exp @@ -0,0 +1,7 @@ +FOOBAR = +FOOBAR = foobar fubar +fun +fun +fun +In the Sun +exit status 0 diff --git a/contrib/bmake/unit-tests/sysv b/contrib/bmake/unit-tests/sysv.mk index 9eedacb..d5e99ff 100644 --- a/contrib/bmake/unit-tests/sysv +++ b/contrib/bmake/unit-tests/sysv.mk @@ -1,7 +1,7 @@ -# $Id: sysv,v 1.1.1.2 2011/06/05 04:23:49 sjg Exp $ +# $Id: sysv.mk,v 1.2 2014/08/30 22:25:14 sjg Exp $ FOO ?= -FOOBAR = $(FOO:=bar) +FOOBAR = ${FOO:=bar} _this := ${.PARSEDIR}/${.PARSEFILE} @@ -14,7 +14,7 @@ SUN = the Sun all: foo fun foo: - @echo FOOBAR = $(FOOBAR) + @echo FOOBAR = ${FOOBAR} .if empty(FOO) @FOO="foo fu" ${.MAKE} -f ${_this} foo .endif diff --git a/contrib/bmake/unit-tests/ternary.exp b/contrib/bmake/unit-tests/ternary.exp new file mode 100644 index 0000000..ed9c1bd --- /dev/null +++ b/contrib/bmake/unit-tests/ternary.exp @@ -0,0 +1,10 @@ +The answer is unknown +The answer is unknown +The answer is empty +The answer is known +The answer is +The answer is empty +The answer is known +The answer is 42 +The answer is 42 +exit status 0 diff --git a/contrib/bmake/unit-tests/ternary b/contrib/bmake/unit-tests/ternary.mk index 77f8349..77f8349 100644 --- a/contrib/bmake/unit-tests/ternary +++ b/contrib/bmake/unit-tests/ternary.mk diff --git a/contrib/bmake/unit-tests/test.exp b/contrib/bmake/unit-tests/test.exp deleted file mode 100644 index aaecb96..0000000 --- a/contrib/bmake/unit-tests/test.exp +++ /dev/null @@ -1,383 +0,0 @@ -comment testing start -this is foo -This is how a comment looks: # comment -comment testing done -make: "cond1" line 75: warning: extra else -make: "cond1" line 85: warning: extra else -2 is prime -A='other' B='unknown' C='clever' o='no,no' -Passed: - var - ("var") - (var != var) - var != var - !((var != var) && defined(name)) - var == quoted - -1 is not prime -2 is prime -3 is prime -4 is not prime -5 is prime - -make: warning: String comparison operator should be either == or != -make: Bad conditional expression `"0" > 0' in "0" > 0?OK:No - -OK -make: "error" line 3: just FYI -make: "error" line 4: warning: this could be serious -make: "error" line 5: this is fatal -UT_DOLLAR=This is $UT_FU -UT_FOO=foobar is fubar -UT_FU=fubar -UT_TEST=export -UT_ZOO=hoopie -UT_ALL=even this gets exported -UT_BADDIR=unit-tests -UT_DOLLAR=This is $UT_FU -UT_F=fine -UT_FOO=foobar is fubar -UT_FU=fubar -UT_NO=all -UT_OK=good -UT_OKDIR=unit-tests -UT_TEST=export-all -UT_ZOO=hoopie -make: -UT_TEST=export-env -UT_ENV=not-exported -UT_EXP=not-exported -env: -UT_TEST=export-env -UT_ENV=exported -UT_EXP=exported -At first, I am -happy -and now: sad -.ERROR: Looks like 'sad' is upset. -*** Error code 1 - -Stop. -make: stopped in unit-tests -simple.1 -simple.1 -simple.2 -simple.2 -recursive.1.1.* -recursive.1.1.* -recursive.1.1.* -recursive.1.1.* -recursive.1.99 -recursive.1.99 -recursive.2.1.* -recursive.2.1.* -recursive.2.1.* -recursive.2.1.* -recursive.2.99 -recursive.2.99 -shared.0 -shared.0 -shared.1.99 -shared.1.99 -shared.2.1 -shared.2.1 -shared.2.99 -shared.2.99 -make: Graph cycles through `cycle.2.99' -make: Graph cycles through `cycle.2.98' -make: Graph cycles through `cycle.2.97' -cycle.1.99 -cycle.1.99 -x=one -x="two and three" -x=four -x="five" -x=-I/this -x=-I"This or that" -x=-Ithat -x="-DTHIS=\"this and that\"" -cfl=-I/this -I"This or that" -Ithat "-DTHIS=\"this and that\"" -a=one b="two and three" -a=four b="five" -a=ONE b="TWO AND THREE" -a=FOUR b="FIVE" -We expect an error next: -make: "forloop" line 38: Wrong number of words (9) in .for substitution list with 2 vars -make: Fatal errors encountered -- cannot continue -make: stopped in unit-tests -OK -.for with :S;... OK -b2af338b -3360ac65 -7747f046 -9ca87054 -880fe816 -208fcbd3 -d5d376eb -de41416c -Expect: Unknown modifier 'Z' -make: Unknown modifier 'Z' -VAR:Z= -Expect: Unknown modifier 'Z' -make: Unknown modifier 'Z' -VAR:Z= -Expect: Unclosed variable specification for VAR -make: Unclosed variable specification (expecting '}') for "VAR" (value "Thevariable") modifier S -VAR:S,V,v,=Thevariable -Expect: Unclosed variable specification for VAR -make: Unclosed variable specification after complex modifier (expecting '}') for VAR -VAR:S,V,v,=Thevariable -Expect: Unclosed substitution for VAR (, missing) -make: Unclosed substitution for VAR (, missing) -VAR:S,V,v= -LIB=a X_LIBS:M${LIB${LIB:tu}} is "/tmp/liba.a" -LIB=a X_LIBS:M*/lib${LIB}.a is "/tmp/liba.a" -LIB=a X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBA.A" -LIB=b X_LIBS:M${LIB${LIB:tu}} is "" -LIB=b X_LIBS:M*/lib${LIB}.a is "" -LIB=b X_LIBS:M*/lib${LIB}.a:tu is "" -LIB=c X_LIBS:M${LIB${LIB:tu}} is "" -LIB=c X_LIBS:M*/lib${LIB}.a is "" -LIB=c X_LIBS:M*/lib${LIB}.a:tu is "" -LIB=d X_LIBS:M${LIB${LIB:tu}} is "/tmp/libd.a" -LIB=d X_LIBS:M*/lib${LIB}.a is "/tmp/libd.a" -LIB=d X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBD.A" -LIB=e X_LIBS:M${LIB${LIB:tu}} is "/tmp/libe.a" -LIB=e X_LIBS:M*/lib${LIB}.a is "/tmp/libe.a" -LIB=e X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBE.A" -Mscanner=OK -path=':/bin:/tmp::/:.:/no/such/dir:.' -path='/bin:/tmp:/:/no/such/dir' -path='/bin:/tmp:/:/no/such/dir' -path='/bin':'/tmp':'/':'/no/such/dir' -path='/bin':'/tmp':'/':'/no/such/dir' -path_/usr/xbin=/opt/xbin/ -paths=/bin /tmp / /no/such/dir /opt/xbin -PATHS=/BIN /TMP / /NO/SUCH/DIR /OPT/XBIN -The answer is 42 -LIST = one two three four five six seven eight nine ten -LIST:O = eight five four nine one seven six ten three two -LIST:Ox = Ok -LIST:O:Ox = Ok -LISTX = Ok -LISTSX = Ok -make: Bad modifier `:OX' for LIST -BADMOD 1 = } -make: Bad modifier `:OxXX' for LIST -BADMOD 2 = XX} -LIST="one two three four five six" -LIST:ts,="one,two,three,four,five,six" -LIST:ts/:tu="ONE/TWO/THREE/FOUR/FIVE/SIX" -LIST:ts::tu="ONE:TWO:THREE:FOUR:FIVE:SIX" -LIST:ts:tu="ONETWOTHREEFOURFIVESIX" -LIST:tu:ts/="ONE/TWO/THREE/FOUR/FIVE/SIX" -LIST:ts:="one:two:three:four:five:six" -LIST:ts="onetwothreefourfivesix" -LIST:ts:S/two/2/="one2threefourfivesix" -LIST:S/two/2/:ts="one2threefourfivesix" -LIST:ts/:S/two/2/="one/2/three/four/five/six" -Pretend the '/' in '/n' etc. below are back-slashes. -LIST:ts/n="one -two -three -four -five -six" -LIST:ts/t="one two three four five six" -LIST:ts/012:tu="ONE -TWO -THREE -FOUR -FIVE -SIX" -make: Bad modifier `:tx' for LIST -LIST:tx="}" -make: Bad modifier `:ts\x' for LIST -LIST:ts/x:tu="\x:tu}" -FU_mod-ts="a/b/cool" -FU_mod-ts:ts:T="cool" == cool? -B.${AAA:ts}="Baaa" == Baaa? -make: Bad modifier `:[]' for LIST -LIST:[]="" is an error -LIST:[0]="one two three four five six" -LIST:[0x0]="one two three four five six" -LIST:[000]="one two three four five six" -LIST:[*]="one two three four five six" -LIST:[@]="one two three four five six" -LIST:[0]:C/ /,/="one,two three four five six" -LIST:[0]:C/ /,/g="one,two,three,four,five,six" -LIST:[0]:C/ /,/1g="one,two,three,four,five,six" -LIST:[*]:C/ /,/="one,two three four five six" -LIST:[*]:C/ /,/g="one,two,three,four,five,six" -LIST:[*]:C/ /,/1g="one,two,three,four,five,six" -LIST:[@]:C/ /,/="one two three four five six" -LIST:[@]:C/ /,/g="one two three four five six" -LIST:[@]:C/ /,/1g="one two three four five six" -LIST:[@]:[0]:C/ /,/="one,two three four five six" -LIST:[0]:[@]:C/ /,/="one two three four five six" -LIST:[@]:[*]:C/ /,/="one,two three four five six" -LIST:[*]:[@]:C/ /,/="one two three four five six" -EMPTY="" -EMPTY:[#]="1" == 1 ? -ESCAPEDSPACE="\ " -ESCAPEDSPACE:[#]="1" == 1 ? -REALLYSPACE=" " -REALLYSPACE:[#]="1" == 1 ? -LIST:[#]="6" -LIST:[0]:[#]="1" == 1 ? -LIST:[*]:[#]="1" == 1 ? -LIST:[@]:[#]="6" -LIST:[1]:[#]="1" -LIST:[1..3]:[#]="3" -EMPTY:[1]="" -ESCAPEDSPACE="\ " -ESCAPEDSPACE:[1]="\ " -REALLYSPACE=" " -REALLYSPACE:[1]="" == "" ? -REALLYSPACE:[*]:[1]=" " == " " ? -LIST:[1]="one" -make: Bad modifier `:[1.]' for LIST -LIST:[1.]="" is an error -make: Bad modifier `:[1].' for LIST -LIST:[1].="}" is an error -LIST:[2]="two" -LIST:[6]="six" -LIST:[7]="" -LIST:[999]="" -make: Bad modifier `:[-]' for LIST -LIST:[-]="" is an error -make: Bad modifier `:[--]' for LIST -LIST:[--]="" is an error -LIST:[-1]="six" -LIST:[-2]="five" -LIST:[-6]="one" -LIST:[-7]="" -LIST:[-999]="" -LONGLIST:[17]="17" -LONGLIST:[0x11]="17" -LONGLIST:[021]="17" -LIST:[0]:[1]="one two three four five six" -LIST:[*]:[1]="one two three four five six" -LIST:[@]:[1]="one" -LIST:[0]:[2]="" -LIST:[*]:[2]="" -LIST:[@]:[2]="two" -LIST:[*]:C/ /,/:[2]="" -LIST:[*]:C/ /,/:[*]:[2]="" -LIST:[*]:C/ /,/:[@]:[2]="three" -make: Bad modifier `:[1.]' for LIST -LIST:[1.]="" is an error -make: Bad modifier `:[1..]' for LIST -LIST:[1..]="" is an error -LIST:[1..1]="one" -make: Bad modifier `:[1..1.]' for LIST -LIST:[1..1.]="" is an error -LIST:[1..2]="one two" -LIST:[2..1]="two one" -LIST:[3..-2]="three four five" -LIST:[-4..4]="three four" -make: Bad modifier `:[0..1]' for LIST -LIST:[0..1]="" is an error -make: Bad modifier `:[-1..0]' for LIST -LIST:[-1..0]="" is an error -LIST:[-1..1]="six five four three two one" -LIST:[0..0]="one two three four five six" -LIST:[3..99]="three four five six" -LIST:[-3..-99]="four three two one" -LIST:[-99..-3]="one two three four" -HASH="#" == "#" ? -LIST:[${HASH}]="6" -LIST:[${ZERO}]="one two three four five six" -LIST:[${ZERO}x${ONE}]="one" -LIST:[${ONE}]="one" -LIST:[${MINUSONE}]="six" -LIST:[${STAR}]="one two three four five six" -LIST:[${AT}]="one two three four five six" -make: Bad modifier `:[${EMPTY' for LIST -LIST:[${EMPTY}]="" is an error -LIST:[${LONGLIST:[21]:S/2//}]="one" -LIST:[${LIST:[#]}]="six" -LIST:[${LIST:[${HASH}]}]="six" -LIST:S/ /,/="one two three four five six" -LIST:S/ /,/W="one,two three four five six" -LIST:S/ /,/gW="one,two,three,four,five,six" -EMPTY:S/^/,/="," -EMPTY:S/^/,/W="," -LIST:C/ /,/="one two three four five six" -LIST:C/ /,/W="one,two three four five six" -LIST:C/ /,/gW="one,two,three,four,five,six" -EMPTY:C/^/,/="," -EMPTY:C/^/,/W="," -LIST:tW="one two three four five six" -LIST:tw="one two three four five six" -LIST:tW:C/ /,/="one,two three four five six" -LIST:tW:C/ /,/g="one,two,three,four,five,six" -LIST:tW:C/ /,/1g="one,two,three,four,five,six" -LIST:tw:C/ /,/="one two three four five six" -LIST:tw:C/ /,/g="one two three four five six" -LIST:tw:C/ /,/1g="one two three four five six" -LIST:tw:tW:C/ /,/="one,two three four five six" -LIST:tW:tw:C/ /,/="one two three four five six" -Making the.c -Making the.h -Making the.o from the.h the.c -.TARGET="phony" .PREFIX="phony" .IMPSRC="" -.TARGET="all" .PREFIX="all" .IMPSRC="" -.TARGET="ok" .PREFIX="ok" .IMPSRC="" -.TARGET="also.ok" .PREFIX="also.ok" .IMPSRC="" -.TARGET="bug" .PREFIX="bug" .IMPSRC="" -Posix says we should execute the command as if run by system(3) -Expect 'Hello,' and 'World!' -Hello, -World! -a command -a command prefixed by '+' executes even with -n -another command -make -n -echo a command -echo "a command prefixed by '+' executes even with -n" -a command prefixed by '+' executes even with -n -echo another command -make -n -j1 -{ echo a command -} || exit $? -echo "a command prefixed by '+' executes even with -n" -a command prefixed by '+' executes even with -n -{ echo another command -} || exit $? -Now we expect an error... -*** Error code 1 (continuing) -`all' not remade because of errors. -V.i386 ?= OK -TEST1=hello -TEST2=bye -TEST3=later -FOOBAR = -FOOBAR = foobar fubar -fun -fun -fun -In the Sun -The answer is unknown -The answer is unknown -The answer is empty -The answer is known -The answer is -The answer is empty -The answer is known -The answer is 42 -The answer is 42 -UT_DOLLAR=This is $UT_FU -UT_FU=fubar -UT_TEST=unexport -UT_TEST=unexport-env -default FU=<v>fu</v> FOO=<v>foo</v> VAR=<v></v> -two FU=<v>bar</v> FOO=<v>goo</v> VAR=<v></v> -three FU=<v>bar</v> FOO=<v>goo</v> VAR=<v></v> -four FU=<v>bar</v> FOO=<v>goo</v> VAR=<v>Internal</v> -five FU=<v>bar</v> FOO=<v>goo</v> VAR=<v>Internal</v> -five v=is x k=is x -six v=is y k=is y -show-v v=override k=override -*** Error code 1 (ignored) -*** Error code 1 (ignored) diff --git a/contrib/bmake/unit-tests/unexport-env.exp b/contrib/bmake/unit-tests/unexport-env.exp new file mode 100644 index 0000000..6d43cab --- /dev/null +++ b/contrib/bmake/unit-tests/unexport-env.exp @@ -0,0 +1,2 @@ +UT_TEST=unexport-env +exit status 0 diff --git a/contrib/bmake/unit-tests/unexport-env b/contrib/bmake/unit-tests/unexport-env.mk index f6a2ff9..aaabcd4 100644 --- a/contrib/bmake/unit-tests/unexport-env +++ b/contrib/bmake/unit-tests/unexport-env.mk @@ -1,7 +1,7 @@ -# $Id: unexport-env,v 1.1.1.1 2009/11/19 00:31:11 sjg Exp $ +# $Id: unexport-env.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ # pick up a bunch of exported vars -.include "export" +.include "export.mk" # an example of setting up a minimal environment. PATH = /bin:/usr/bin:/sbin:/usr/sbin diff --git a/contrib/bmake/unit-tests/unexport.exp b/contrib/bmake/unit-tests/unexport.exp new file mode 100644 index 0000000..7b16ea3 --- /dev/null +++ b/contrib/bmake/unit-tests/unexport.exp @@ -0,0 +1,4 @@ +UT_DOLLAR=This is $UT_FU +UT_FU=fubar +UT_TEST=unexport +exit status 0 diff --git a/contrib/bmake/unit-tests/unexport b/contrib/bmake/unit-tests/unexport.mk index fb40d0c..0f12452 100644 --- a/contrib/bmake/unit-tests/unexport +++ b/contrib/bmake/unit-tests/unexport.mk @@ -1,7 +1,7 @@ -# $Id: unexport,v 1.1.1.1 2009/11/19 00:31:11 sjg Exp $ +# $Id: unexport.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ # pick up a bunch of exported vars -.include "export" +.include "export.mk" .unexport UT_ZOO UT_FOO diff --git a/contrib/bmake/unit-tests/varcmd.exp b/contrib/bmake/unit-tests/varcmd.exp new file mode 100644 index 0000000..34dd637 --- /dev/null +++ b/contrib/bmake/unit-tests/varcmd.exp @@ -0,0 +1,9 @@ +default FU=<v>fu</v> FOO=<v>foo</v> VAR=<v></v> +two FU=<v>bar</v> FOO=<v>goo</v> VAR=<v></v> +three FU=<v>bar</v> FOO=<v>goo</v> VAR=<v></v> +four FU=<v>bar</v> FOO=<v>goo</v> VAR=<v>Internal</v> +five FU=<v>bar</v> FOO=<v>goo</v> VAR=<v>Internal</v> +five v=is x k=is x +six v=is y k=is y +show-v v=override k=override +exit status 0 diff --git a/contrib/bmake/unit-tests/varcmd b/contrib/bmake/unit-tests/varcmd.mk index a58e014..a5fd198 100644 --- a/contrib/bmake/unit-tests/varcmd +++ b/contrib/bmake/unit-tests/varcmd.mk @@ -1,4 +1,4 @@ -# $Id: varcmd,v 1.3 2008/05/15 04:30:47 sjg Exp $ +# $Id: varcmd.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ # # Test behaviour of recursive make and vars set on command line. diff --git a/contrib/bmake/unit-tests/varmisc.exp b/contrib/bmake/unit-tests/varmisc.exp new file mode 100644 index 0000000..1636aaf --- /dev/null +++ b/contrib/bmake/unit-tests/varmisc.exp @@ -0,0 +1,2 @@ + +exit status 0 diff --git a/contrib/bmake/unit-tests/varmisc.mk b/contrib/bmake/unit-tests/varmisc.mk new file mode 100644 index 0000000..4b4a931 --- /dev/null +++ b/contrib/bmake/unit-tests/varmisc.mk @@ -0,0 +1,8 @@ +# $Id: varmisc.mk,v 1.2 2014/08/30 22:25:14 sjg Exp $ +# +# Miscellaneous variable tests. + +all: unmatched_var_paren + +unmatched_var_paren: + @echo ${foo::=foo-text} diff --git a/contrib/bmake/unit-tests/varshell.exp b/contrib/bmake/unit-tests/varshell.exp new file mode 100644 index 0000000..dae2c6b --- /dev/null +++ b/contrib/bmake/unit-tests/varshell.exp @@ -0,0 +1,10 @@ +make: "varshell.mk" line 5: warning: "/bin/no/such/command 2> /dev/null" returned non-zero status +make: "varshell.mk" line 8: warning: "false" returned non-zero status +make: "varshell.mk" line 9: warning: "echo "output before the error"; false" returned non-zero status +EXEC_FAILED='' +TERMINATED_BY_SIGNAL='' +ERROR_NO_OUTPUT='' +ERROR_WITH_OUTPUT='output before the error' +NO_ERROR_NO_OUTPUT='' +NO_ERROR_WITH_OUTPUT='this is good' +exit status 0 diff --git a/contrib/bmake/unit-tests/varshell.mk b/contrib/bmake/unit-tests/varshell.mk new file mode 100644 index 0000000..9c8baac --- /dev/null +++ b/contrib/bmake/unit-tests/varshell.mk @@ -0,0 +1,19 @@ +# $Id: varshell.mk,v 1.4 2015/04/20 03:16:39 sjg Exp $ +# +# Test VAR != shell command + +EXEC_FAILED != /bin/no/such/command 2> /dev/null +# SunOS cannot handle this one +#TERMINATED_BY_SIGNAL != kill -14 $$$$ +ERROR_NO_OUTPUT != false +ERROR_WITH_OUTPUT != echo "output before the error"; false +NO_ERROR_NO_OUTPUT != true +NO_ERROR_WITH_OUTPUT != echo "this is good" + +allvars= EXEC_FAILED TERMINATED_BY_SIGNAL ERROR_NO_OUTPUT ERROR_WITH_OUTPUT \ + NO_ERROR_NO_OUTPUT NO_ERROR_WITH_OUTPUT + +all: +.for v in ${allvars} + @echo ${v}=\'${${v}}\' +.endfor |