git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@450239 13f79535-47bb-0310-9956-ffa450edef68master
@@ -1,470 +0,0 @@ | |||
<project name="apply-test" basedir="."> | |||
<target name="init"> | |||
<property environment="env"/> | |||
<!-- UNIX --> | |||
<available file="sh" filepath="${env.PATH}" property="sh.executable"/> | |||
<!-- CYGWIN --> | |||
<available file="sh.exe" filepath="${env.PATH}" property="sh.exe.executable"/> | |||
<condition property="test.can.run"> | |||
<or> | |||
<isset property="sh.executable"/> | |||
<isset property="sh.exe.executable"/> | |||
</or> | |||
</condition> | |||
<!-- UNIX --> | |||
<available file="sed" filepath="${env.PATH}" property="sed.executable"/> | |||
<!-- CYGWIN --> | |||
<available file="sed.exe" filepath="${env.PATH}" property="sed.exe.executable"/> | |||
<condition property="sed.can.run"> | |||
<or> | |||
<isset property="sed.executable"/> | |||
<isset property="sed.exe.executable"/> | |||
</or> | |||
</condition> | |||
<!-- UNIX --> | |||
<available file="echo" filepath="${env.PATH}" property="echo.executable"/> | |||
<!-- CYGWIN --> | |||
<available file="echo.exe" filepath="${env.PATH}" property="echo.exe.executable"/> | |||
<condition property="echo.can.run"> | |||
<or> | |||
<isset property="echo.executable"/> | |||
<isset property="echo.exe.executable"/> | |||
</or> | |||
</condition> | |||
<!-- UNIX --> | |||
<available file="ls" filepath="${env.PATH}" property="ls.executable"/> | |||
<!-- CYGWIN --> | |||
<available file="ls.exe" filepath="${env.PATH}" property="ls.exe.executable"/> | |||
<condition property="ls.can.run"> | |||
<or> | |||
<isset property="ls.executable"/> | |||
<isset property="ls.exe.executable"/> | |||
</or> | |||
</condition> | |||
</target> | |||
<target name="xyz"> | |||
<echo file="x">s/x/blah/g${line.separator}</echo> | |||
<echo file="y">s/y/blah/g${line.separator}</echo> | |||
<echo file="z">s/z/blah/g${line.separator}</echo> | |||
<fileset id="xyz" dir="${basedir}" includes="x,y,z" /> | |||
<filelist id="xyzlist" dir="${basedir}" files="x,y,z" /> | |||
</target> | |||
<target name="no-redirect" depends="init,xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<arg value="parrot.sh"/> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
</target> | |||
<target name="redirect1" depends="init,xyz" if="test.can.run"> | |||
<apply executable="sh" output="redirect.out" append="true"> | |||
<arg value="parrot.sh"/> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
</target> | |||
<target name="redirect2" depends="init,xyz" if="test.can.run"> | |||
<apply executable="sh" output="redirect.out" | |||
error="redirect.err" append="true"> | |||
<arg value="parrot.sh"/> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
</target> | |||
<target name="redirect3" depends="init,xyz" if="test.can.run"> | |||
<apply executable="sh" logerror="true" append="true" | |||
output="redirect.out" outputproperty="redirect.out"> | |||
<arg value="parrot.sh"/> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
</target> | |||
<target name="redirect4" depends="init,xyz" if="test.can.run"> | |||
<apply executable="sh" append="true" | |||
error="redirect.err" errorproperty="redirect.err" | |||
output="redirect.out" outputproperty="redirect.out"> | |||
<arg value="parrot.sh"/> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
</target> | |||
<target name="redirect5" depends="init,xyz" if="sed.can.run"> | |||
<apply executable="sed" inputstring="x y z${line.separator}" append="true" | |||
error="redirect.err" errorproperty="redirect.err" | |||
output="redirect.out" outputproperty="redirect.out"> | |||
<arg value="-f" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
</target> | |||
<target name="redirect6" depends="init,xyz" if="sed.can.run"> | |||
<echo file="redirect.in">x y z${line.separator}</echo> | |||
<apply executable="sed" input="redirect.in" append="true" | |||
error="redirect.err" errorproperty="redirect.err" | |||
output="redirect.out" outputproperty="redirect.out"> | |||
<arg value="-f" /> | |||
<filelist refid="xyzlist" /> | |||
</apply> | |||
</target> | |||
<target name="redirect7" depends="init,xyz" if="sed.can.run"> | |||
<apply executable="sed" inputstring="x y z${line.separator}" | |||
error="redirect.err" output="redirect.out" | |||
outputproperty="redirect.out"> | |||
<arg value="-f" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
</target> | |||
<target name="redirector1" description="fail" | |||
depends="init,xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<arg value="parrot.sh"/> | |||
<fileset refid="xyz" /> | |||
<redirector output="redirector.out" /> | |||
<redirector output="whocares" /> | |||
</apply> | |||
</target> | |||
<target name="redirector2" depends="init,xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<arg value="parrot.sh"/> | |||
<fileset refid="xyz" /> | |||
<redirector output="redirector.out" append="true" /> | |||
</apply> | |||
</target> | |||
<target name="redirector3" depends="init,xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<arg value="parrot.sh"/> | |||
<fileset refid="xyz" /> | |||
<redirector append="true" | |||
output="redirector.out" error="redirector.err" /> | |||
</apply> | |||
</target> | |||
<target name="redirector4" depends="init,xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<arg value="parrot.sh"/> | |||
<fileset refid="xyz" /> | |||
<redirector output="redirector.out" logerror="true" | |||
append="true" outputproperty="redirector.out" /> | |||
</apply> | |||
</target> | |||
<target name="redirector5" depends="init,xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<redirector error="redirector.err" errorproperty="redirector.err" | |||
output="redirector.out" outputproperty="redirector.out" | |||
append="true" /> | |||
<arg value="parrot.sh"/> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
</target> | |||
<target name="redirector6" depends="init,xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<redirector append="true" outputproperty="redirector.out" | |||
errorproperty="redirector.err"> | |||
<outputmapper type="merge" to="redirector.out" /> | |||
<errormapper type="merge" to="redirector.err" /> | |||
</redirector> | |||
<arg value="parrot.sh" /> | |||
<filelist refid="xyzlist" /> | |||
</apply> | |||
</target> | |||
<target name="redirector7" depends="init,xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<redirector append="true" outputproperty="redirector.out" | |||
errorproperty="redirector.err"> | |||
<outputmapper type="merge" to="redirector.out" /> | |||
<errormapper type="merge" to="redirector.err" /> | |||
<errorfilterchain> | |||
<replacestring from="err" to="ERROR!!!" /> | |||
</errorfilterchain> | |||
</redirector> | |||
<arg value="parrot.sh" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
</target> | |||
<target name="redirector8" depends="init,xyz" if="sed.can.run"> | |||
<echo file="redirector.in">x y z${line.separator}</echo> | |||
<apply executable="sed"> | |||
<redirector append="true" outputproperty="redirector.out" | |||
errorproperty="redirector.err"> | |||
<inputmapper type="merge" to="redirector.in" /> | |||
<outputmapper type="merge" to="redirector.out" /> | |||
<errormapper type="merge" to="redirector.err" /> | |||
</redirector> | |||
<arg value="-f" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
</target> | |||
<target name="redirector9" depends="init,xyz" if="sed.can.run"> | |||
<echo file="redirector.in">x before y before z${line.separator}</echo> | |||
<apply executable="sed"> | |||
<redirector outputproperty="redirector.out" | |||
errorproperty="redirector.err" append="true"> | |||
<inputfilterchain> | |||
<replacestring from="before" to="after" /> | |||
</inputfilterchain> | |||
<inputmapper type="merge" to="redirector.in" /> | |||
<outputmapper type="merge" to="redirector.out" /> | |||
<errormapper type="merge" to="redirector.err" /> | |||
</redirector> | |||
<arg value="-f" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
</target> | |||
<target name="redirector10" depends="init,xyz" if="sed.can.run"> | |||
<echo file="redirector.in">x before y before z${line.separator}</echo> | |||
<apply executable="sed"> | |||
<redirector outputproperty="redirector.out" | |||
errorproperty="redirector.err" append="true"> | |||
<outputfilterchain> | |||
<replacestring from="before" to="after" /> | |||
</outputfilterchain> | |||
<outputmapper type="merge" to="redirector.out" /> | |||
<errormapper type="merge" to="redirector.err" /> | |||
</redirector> | |||
<arg value="-f" /> | |||
<srcfile /> | |||
<arg value="redirector.in"/> | |||
<filelist refid="xyzlist" /> | |||
</apply> | |||
</target> | |||
<target name="redirector11" depends="init,xyz" if="sed.can.run"> | |||
<apply executable="sed"> | |||
<redirector outputproperty="redirector.out" | |||
errorproperty="redirector.err" | |||
inputstring="x before y before z${line.separator}" | |||
append="true"> | |||
<inputfilterchain> | |||
<replacestring from="before" to="after" /> | |||
</inputfilterchain> | |||
<outputmapper type="merge" to="redirector.out" /> | |||
<errormapper type="merge" to="redirector.err" /> | |||
</redirector> | |||
<arg value="-f" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
</target> | |||
<target name="redirector12" depends="init,xyz" if="sed.can.run"> | |||
<echo file="redirector.in">x before y before z${line.separator}</echo> | |||
<apply executable="sed" output="redirector.out" error="redirector.err"> | |||
<redirector outputproperty="redirector.out" | |||
errorproperty="redirector.err" append="true"> | |||
<outputfilterchain> | |||
<replacestring from="before" to="after" /> | |||
</outputfilterchain> | |||
<outputmapper type="glob" from="nomatch" to="nomatchout" /> | |||
<errormapper type="glob" from="nomatch" to="nomatcherr" /> | |||
</redirector> | |||
<arg value="-f" /> | |||
<srcfile /> | |||
<arg value="redirector.in"/> | |||
<filelist refid="xyzlist" /> | |||
</apply> | |||
</target> | |||
<target name="redirector13" depends="init,xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<redirector> | |||
<outputfilterchain> | |||
<replacestring from="out" to="OUTPUT???" /> | |||
</outputfilterchain> | |||
<errorfilterchain> | |||
<replacestring from="err" to="ERROR!!!" /> | |||
</errorfilterchain> | |||
</redirector> | |||
<arg value="parrot.sh" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
</target> | |||
<target name="redirector14" depends="init,xyz" if="sed.can.run"> | |||
<echo file="redirector.in">z before y before x${line.separator}</echo> | |||
<apply executable="sed"> | |||
<redirector append="true" | |||
inputstring="x before y before z${line.separator}"> | |||
<outputfilterchain> | |||
<replacestring from="before" to="after" /> | |||
</outputfilterchain> | |||
<inputmapper type="glob" from="x" to="redirector.in" /> | |||
<outputmapper type="glob" from="y" to="redirector.out" /> | |||
<errormapper type="glob" from="z" to="redirector.err" /> | |||
</redirector> | |||
<arg value="-f" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
</target> | |||
<target name="redirector14b" depends="init,xyz" if="sed.can.run"> | |||
<apply executable="sed"> | |||
<redirector append="true" | |||
inputstring="x before y before z${line.separator}"> | |||
<outputfilterchain> | |||
<replacestring from="before" to="after" /> | |||
</outputfilterchain> | |||
<inputmapper type="glob" from="x" to="redirector.in" /> | |||
<outputmapper type="glob" from="y" to="redirector.out" /> | |||
<errormapper type="glob" from="z" to="redirector.err" /> | |||
</redirector> | |||
<arg value="-f" /> | |||
<fileset file="y" /> | |||
</apply> | |||
</target> | |||
<target name="pad"> | |||
<condition property="pad" value=""> | |||
<or> | |||
<not> | |||
<os family="dos" /> | |||
</not> | |||
<not> | |||
<or> | |||
<equals arg1="${ant.java.version}" arg2="1.1" /> | |||
<equals arg1="${ant.java.version}" arg2="1.2" /> | |||
</or> | |||
</not> | |||
</or> | |||
</condition> | |||
<condition property="pad" value=" "> | |||
<and> | |||
<os family="dos" /> | |||
<or> | |||
<equals arg1="${ant.java.version}" arg2="1.1" /> | |||
<equals arg1="${ant.java.version}" arg2="1.2" /> | |||
</or> | |||
</and> | |||
</condition> | |||
</target> | |||
<target name="ignoremissing" depends="init,xyz,pad" if="echo.can.run"> | |||
<filelist id="xylist" dir="${basedir}" files="x,y" /> | |||
<delete file="z" /> | |||
<pathconvert property="xy" pathsep="${pad}${line.separator}"> | |||
<path> | |||
<filelist refid="xylist" /> | |||
</path> | |||
</pathconvert> | |||
<pathconvert property="xyz" pathsep="${pad}${line.separator}"> | |||
<path> | |||
<filelist refid="xyzlist" /> | |||
</path> | |||
</pathconvert> | |||
<apply executable="echo" ignoremissing="true" | |||
outputproperty="ignoretrue" append="true"> | |||
<filelist refid="xyzlist" /> | |||
</apply> | |||
<apply executable="echo" ignoremissing="false" | |||
outputproperty="ignorefalse" append="true"> | |||
<filelist refid="xyzlist" /> | |||
</apply> | |||
<fail> | |||
<condition> | |||
<not> | |||
<and> | |||
<equals arg1="${xy}${pad}" arg2="${ignoretrue}" /> | |||
<equals arg1="${xyz}${pad}" arg2="${ignorefalse}" /> | |||
</and> | |||
</not> | |||
</condition> | |||
</fail> | |||
</target> | |||
<target name="force" depends="init,xyz,pad" if="echo.can.run"> | |||
<presetdef name="ekko"> | |||
<apply executable="echo" append="true" dest="${basedir}"> | |||
<filelist refid="xyzlist" /> | |||
<mapper type="identity" /> | |||
</apply> | |||
</presetdef> | |||
<pathconvert property="xyz" pathsep="${pad}${line.separator}"> | |||
<path> | |||
<filelist refid="xyzlist" /> | |||
</path> | |||
</pathconvert> | |||
<ekko outputproperty="foo" /> | |||
<ekko outputproperty="bar" force="true" /> | |||
<fail> | |||
<condition> | |||
<not> | |||
<and> | |||
<equals arg1="${foo}" arg2="" /> | |||
<equals arg1="${bar}" arg2="${xyz}" /> | |||
</and> | |||
</not> | |||
</condition> | |||
</fail> | |||
</target> | |||
<target name="testNoDest" depends="init,xyz" if="echo.can.run"> | |||
<presetdef name="ekko"> | |||
<apply executable="echo" addsourcefile="false" force="true"> | |||
<filelist dir="${basedir}" files="x" /> | |||
<globmapper from="*" to="${basedir}/*" /> | |||
<targetfile /> | |||
</apply> | |||
</presetdef> | |||
<ekko outputproperty="dest" dest="${basedir}" /> | |||
<ekko outputproperty="nodest" /> | |||
<fail> | |||
<condition> | |||
<or> | |||
<available file="${dest}" /> | |||
<not> | |||
<available file="${nodest}" /> | |||
</not> | |||
</or> | |||
</condition> | |||
</fail> | |||
</target> | |||
<target name="lsPath" depends="init" if="ls.can.run"> | |||
<apply executable="ls" parallel="false" outputproperty="foo" | |||
force="true" dest="${basedir}" append="true" type="both"> | |||
<path> | |||
<pathelement path="${env.PATH}"/> | |||
</path> | |||
<identitymapper/> | |||
</apply> | |||
</target> | |||
<target name="lsPathParallel" depends="init" if="ls.can.run"> | |||
<apply executable="ls" parallel="true" outputproperty="foo" | |||
force="true" dest="${basedir}" append="true" type="both"> | |||
<path> | |||
<pathelement path="${env.PATH}"/> | |||
</path> | |||
<identitymapper/> | |||
</apply> | |||
</target> | |||
<target name="cleanup" depends="xyz"> | |||
<delete> | |||
<fileset refid="xyz" /> | |||
<fileset dir="${basedir}" includes="redirect.*" /> | |||
<fileset dir="${basedir}" includes="redirector.*" /> | |||
</delete> | |||
</target> | |||
</project> |
@@ -0,0 +1,724 @@ | |||
<project name="apply-test" xmlns:au="antlib:org.apache.ant.antunit"> | |||
<property environment="env" /> | |||
<!-- UNIX --> | |||
<available file="sh" filepath="${env.PATH}" property="sh.executable" /> | |||
<!-- CYGWIN --> | |||
<available file="sh.exe" filepath="${env.PATH}" property="sh.exe.executable" /> | |||
<condition property="test.can.run"> | |||
<or> | |||
<isset property="sh.executable" /> | |||
<isset property="sh.exe.executable" /> | |||
</or> | |||
</condition> | |||
<!-- UNIX --> | |||
<available file="sed" filepath="${env.PATH}" property="sed.executable" /> | |||
<!-- CYGWIN --> | |||
<available file="sed.exe" filepath="${env.PATH}" property="sed.exe.executable" /> | |||
<condition property="sed.can.run"> | |||
<or> | |||
<isset property="sed.executable" /> | |||
<isset property="sed.exe.executable" /> | |||
</or> | |||
</condition> | |||
<!-- UNIX --> | |||
<available file="echo" filepath="${env.PATH}" property="echo.executable" /> | |||
<!-- CYGWIN --> | |||
<available file="echo.exe" filepath="${env.PATH}" property="echo.exe.executable" /> | |||
<condition property="echo.can.run"> | |||
<or> | |||
<isset property="echo.executable" /> | |||
<isset property="echo.exe.executable" /> | |||
</or> | |||
</condition> | |||
<!-- UNIX --> | |||
<available file="ls" filepath="${env.PATH}" property="ls.executable" /> | |||
<!-- CYGWIN --> | |||
<available file="ls.exe" filepath="${env.PATH}" property="ls.exe.executable" /> | |||
<!-- piggyback the name of the executable here --> | |||
<condition property="ls.can.run" value="ls"> | |||
<isset property="ls.executable" /> | |||
</condition> | |||
<condition property="ls.can.run" value="ls.exe"> | |||
<isset property="ls.exe.executable" /> | |||
</condition> | |||
<property name="eol" value="${line.separator}" /> | |||
<macrodef name="rcat"> | |||
<attribute name="refid" /> | |||
<sequential> | |||
<echo>@@{refid}=@{refid}</echo> | |||
<concat><resources refid="@{refid}" /></concat> | |||
</sequential> | |||
</macrodef> | |||
<macrodef name="assertEmptyFile"> | |||
<attribute name="file" /> | |||
<sequential> | |||
<au:assertTrue> | |||
<and> | |||
<available file="@{file}" type="file" /> | |||
<length length="0" file="@{file}" /> | |||
</and> | |||
</au:assertTrue> | |||
</sequential> | |||
</macrodef> | |||
<target name="xyz"> | |||
<echo file="x">s/x/blah/g${eol}</echo> | |||
<echo file="y">s/y/blah/g${eol}</echo> | |||
<echo file="z">s/z/blah/g${eol}</echo> | |||
<fileset id="xyz" dir="${basedir}" includes="x,y,z" /> | |||
<filelist id="xyzlist" dir="${basedir}" files="x,y,z" /> | |||
<property name="x" location="x" /> | |||
<property name="y" location="y" /> | |||
<property name="z" location="z" /> | |||
</target> | |||
<target name="testNoRedirect" depends="xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<arg value="parrot.sh" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
<au:assertLogContains text="${x} out" /> | |||
<au:assertLogContains text="${y} out" /> | |||
<au:assertLogContains text="${z} out" /> | |||
<au:assertLogContains text="${x} err" /> | |||
<au:assertLogContains text="${y} err" /> | |||
<au:assertLogContains text="${z} err" /> | |||
<!-- | |||
The original junit test also verified that x out happened before | |||
y out, and y out happened before z out; likewise with err output. | |||
I added the antunit:logcontent resource hoping that would help, | |||
but I think we need a way to filter (copy) resources first. | |||
THAT necessitates the string-to-resource coding we are currently | |||
discussing on the dev list IMO. MJB, 9/22/2006 | |||
--> | |||
</target> | |||
<target name="testRedirect1" depends="xyz" if="test.can.run"> | |||
<apply executable="sh" output="redirect.out" append="true"> | |||
<arg value="parrot.sh" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
<au:assertTrue> | |||
<resourcecount count="1"> | |||
<restrict id="results"> | |||
<file file="redirect.out" /> | |||
<and xmlns="antlib:org.apache.tools.ant.types.resources.selectors"> | |||
<contains text="${x} out" /> | |||
<contains text="${y} out" /> | |||
<contains text="${z} out" /> | |||
<contains text="${x} err" /> | |||
<contains text="${y} err" /> | |||
<contains text="${z} err" /> | |||
</and> | |||
</restrict> | |||
</resourcecount> | |||
</au:assertTrue> | |||
</target> | |||
<target name="testRedirect2" depends="xyz" if="test.can.run"> | |||
<apply executable="sh" output="redirect.out" | |||
error="redirect.err" append="true"> | |||
<arg value="parrot.sh" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
<au:assertTrue> | |||
<and> | |||
<resourcesmatch astext="true"> | |||
<string value="${x} out${eol}${y} out${eol}${z} out" /> | |||
<file file="redirect.out" /> | |||
</resourcesmatch> | |||
<resourcesmatch astext="true"> | |||
<string value="${x} err${eol}${y} err${eol}${z} err" /> | |||
<file file="redirect.err" /> | |||
</resourcesmatch> | |||
</and> | |||
</au:assertTrue> | |||
</target> | |||
<target name="testRedirect3" depends="xyz" if="test.can.run"> | |||
<apply executable="sh" logerror="true" append="true" | |||
output="redirect.out" outputproperty="redirect3.out"> | |||
<arg value="parrot.sh" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
<au:assertTrue> | |||
<resourcesmatch astext="true"> | |||
<string value="${x} out${eol}${y} out${eol}${z} out" /> | |||
<file file="redirect.out" /> | |||
<propertyresource name="redirect3.out" /> | |||
</resourcesmatch> | |||
</au:assertTrue> | |||
<au:assertLogContains text="${x} err" /> | |||
<au:assertLogContains text="${y} err" /> | |||
<au:assertLogContains text="${z} err" /> | |||
</target> | |||
<target name="testRedirect4" depends="xyz" if="test.can.run"> | |||
<apply executable="sh" append="true" | |||
error="redirect.err" errorproperty="redirect4.err" | |||
output="redirect.out" outputproperty="redirect4.out"> | |||
<arg value="parrot.sh" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
<au:assertTrue> | |||
<and> | |||
<resourcesmatch astext="true"> | |||
<string value="${x} out${eol}${y} out${eol}${z} out" /> | |||
<file file="redirect.out" /> | |||
<propertyresource name="redirect4.out" /> | |||
</resourcesmatch> | |||
<resourcesmatch astext="true"> | |||
<string value="${x} err${eol}${y} err${eol}${z} err" /> | |||
<file file="redirect.err" /> | |||
<propertyresource name="redirect4.err" /> | |||
</resourcesmatch> | |||
</and> | |||
</au:assertTrue> | |||
</target> | |||
<target name="testRedirect5" depends="xyz" if="sed.can.run"> | |||
<apply executable="sed" inputstring="x y z${eol}" append="true" | |||
error="redirect.err" errorproperty="redirect5.err" | |||
output="redirect.out" outputproperty="redirect5.out"> | |||
<arg value="-f" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
<au:assertTrue> | |||
<and> | |||
<resourcesmatch astext="true"> | |||
<propertyresource name="redirect5.out" /> | |||
<string value="blah y z${eol}x blah z${eol}x y blah" /> | |||
<file file="redirect.out" /> | |||
</resourcesmatch> | |||
<equals arg1="${redirect5.err}" arg2="" /> | |||
</and> | |||
</au:assertTrue> | |||
<assertEmptyFile file="redirect.err" /> | |||
</target> | |||
<target name="testRedirect6" depends="xyz" if="sed.can.run"> | |||
<echo file="redirect.in">x y z${eol}</echo> | |||
<apply executable="sed" input="redirect.in" append="true" | |||
error="redirect.err" errorproperty="redirect6.err" | |||
output="redirect.out" outputproperty="redirect6.out"> | |||
<arg value="-f" /> | |||
<filelist refid="xyzlist" /> | |||
</apply> | |||
<au:assertTrue> | |||
<and> | |||
<resourcesmatch astext="true"> | |||
<propertyresource name="redirect6.out" /> | |||
<string value="blah y z${eol}x blah z${eol}x y blah" /> | |||
<file file="redirect.out" /> | |||
</resourcesmatch> | |||
<equals arg1="${redirect6.err}" arg2="" /> | |||
<length length="0"><file file="redirect.err" /></length> | |||
</and> | |||
</au:assertTrue> | |||
</target> | |||
<target name="testRedirect7" depends="xyz" if="sed.can.run"> | |||
<apply executable="sed" inputstring="x y z${eol}" | |||
error="redirect.err" output="redirect.out" | |||
outputproperty="redirect7.out"> | |||
<arg value="-f" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
<au:assertTrue> | |||
<and> | |||
<equals arg1="${redirect7.out}" arg2="blah y z" /> | |||
<resourcesmatch astext="true"> | |||
<file file="redirect.out" /> | |||
<string value="x y blah" /> | |||
</resourcesmatch> | |||
</and> | |||
</au:assertTrue> | |||
<assertEmptyFile file="redirect.err" /> | |||
</target> | |||
<target name="testRedirector1" description="fail" | |||
depends="xyz" if="test.can.run"> | |||
<au:expectfailure | |||
expectedmessage="cannot have > 1 nested <redirector>s"> | |||
<apply executable="sh"> | |||
<arg value="parrot.sh" /> | |||
<fileset refid="xyz" /> | |||
<redirector output="redirector.out" /> | |||
<redirector output="whocares" /> | |||
</apply> | |||
</au:expectfailure> | |||
</target> | |||
<target name="testRedirector2" depends="xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<arg value="parrot.sh" /> | |||
<fileset refid="xyz" /> | |||
<redirector output="redirector.out" append="true" /> | |||
</apply> | |||
<au:assertTrue> | |||
<resourcecount count="1"> | |||
<restrict id="results"> | |||
<file file="redirector.out" /> | |||
<and xmlns="antlib:org.apache.tools.ant.types.resources.selectors"> | |||
<contains text="${x} out" /> | |||
<contains text="${y} out" /> | |||
<contains text="${z} out" /> | |||
<contains text="${x} err" /> | |||
<contains text="${y} err" /> | |||
<contains text="${z} err" /> | |||
</and> | |||
</restrict> | |||
</resourcecount> | |||
</au:assertTrue> | |||
</target> | |||
<target name="testRedirector3" depends="xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<arg value="parrot.sh" /> | |||
<fileset refid="xyz" /> | |||
<redirector append="true" | |||
output="redirector.out" error="redirector.err" /> | |||
</apply> | |||
<au:assertTrue> | |||
<and> | |||
<resourcesmatch astext="true"> | |||
<string value="${x} out${eol}${y} out${eol}${z} out" /> | |||
<file file="redirector.out" /> | |||
</resourcesmatch> | |||
<resourcesmatch astext="true"> | |||
<string value="${x} err${eol}${y} err${eol}${z} err" /> | |||
<file file="redirector.err" /> | |||
</resourcesmatch> | |||
</and> | |||
</au:assertTrue> | |||
</target> | |||
<target name="testRedirector4" depends="xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<arg value="parrot.sh" /> | |||
<fileset refid="xyz" /> | |||
<redirector output="redirector.out" logerror="true" | |||
append="true" outputproperty="redirector4.out" /> | |||
</apply> | |||
<au:assertTrue> | |||
<resourcesmatch astext="true"> | |||
<string value="${x} out${eol}${y} out${eol}${z} out" /> | |||
<file file="redirector.out" /> | |||
<propertyresource name="redirector4.out" /> | |||
</resourcesmatch> | |||
</au:assertTrue> | |||
<au:assertLogContains text="${x} err" /> | |||
<au:assertLogContains text="${y} err" /> | |||
<au:assertLogContains text="${z} err" /> | |||
</target> | |||
<target name="testRedirector5" depends="xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<redirector error="redirector.err" errorproperty="redirector5.err" | |||
output="redirector.out" outputproperty="redirector5.out" | |||
append="true" /> | |||
<arg value="parrot.sh" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
<au:assertTrue> | |||
<and> | |||
<resourcesmatch astext="true"> | |||
<string value="${x} out${eol}${y} out${eol}${z} out" /> | |||
<file file="redirector.out" /> | |||
<propertyresource name="redirector5.out" /> | |||
</resourcesmatch> | |||
<resourcesmatch astext="true"> | |||
<string value="${x} err${eol}${y} err${eol}${z} err" /> | |||
<file file="redirector.err" /> | |||
<propertyresource name="redirector5.err" /> | |||
</resourcesmatch> | |||
</and> | |||
</au:assertTrue> | |||
</target> | |||
<target name="testRedirector6" depends="xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<redirector append="true" outputproperty="redirector6.out" | |||
errorproperty="redirector6.err"> | |||
<outputmapper type="merge" to="redirector.out" /> | |||
<errormapper type="merge" to="redirector.err" /> | |||
</redirector> | |||
<arg value="parrot.sh" /> | |||
<filelist refid="xyzlist" /> | |||
</apply> | |||
<au:assertTrue> | |||
<and> | |||
<resourcesmatch astext="true"> | |||
<string value="${x} out${eol}${y} out${eol}${z} out" /> | |||
<file file="redirector.out" /> | |||
<propertyresource name="redirector6.out" /> | |||
</resourcesmatch> | |||
<resourcesmatch astext="true"> | |||
<string value="${x} err${eol}${y} err${eol}${z} err" /> | |||
<file file="redirector.err" /> | |||
<propertyresource name="redirector6.err" /> | |||
</resourcesmatch> | |||
</and> | |||
</au:assertTrue> | |||
</target> | |||
<target name="testRedirector7" depends="xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<redirector append="true" outputproperty="redirector7.out" | |||
errorproperty="redirector7.err"> | |||
<outputmapper type="merge" to="redirector.out" /> | |||
<errormapper type="merge" to="redirector.err" /> | |||
<errorfilterchain> | |||
<replacestring from="err" to="ERROR!!!" /> | |||
</errorfilterchain> | |||
</redirector> | |||
<arg value="parrot.sh" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
<au:assertTrue> | |||
<and> | |||
<resourcesmatch astext="true"> | |||
<string value="${x} out${eol}${y} out${eol}${z} out" /> | |||
<file file="redirector.out" /> | |||
<propertyresource name="redirector7.out" /> | |||
</resourcesmatch> | |||
<resourcesmatch astext="true"> | |||
<string value="${x} ERROR!!!${eol}${y} ERROR!!!${eol}${z} ERROR!!!" /> | |||
<file file="redirector.err" /> | |||
<propertyresource name="redirector7.err" /> | |||
</resourcesmatch> | |||
</and> | |||
</au:assertTrue> | |||
</target> | |||
<target name="testRedirector8" depends="xyz" if="sed.can.run"> | |||
<echo file="redirector.in">x y z${eol}</echo> | |||
<apply executable="sed"> | |||
<redirector append="true" outputproperty="redirector8.out" | |||
errorproperty="redirector8.err"> | |||
<inputmapper type="merge" to="redirector.in" /> | |||
<outputmapper type="merge" to="redirector.out" /> | |||
<errormapper type="merge" to="redirector.err" /> | |||
</redirector> | |||
<arg value="-f" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
<au:assertTrue> | |||
<and> | |||
<resourcesmatch astext="true"> | |||
<propertyresource name="redirector8.out" /> | |||
<string value="blah y z${eol}x blah z${eol}x y blah" /> | |||
<file file="redirector.out" /> | |||
</resourcesmatch> | |||
<equals arg1="${redirector8.err}" arg2="" /> | |||
</and> | |||
</au:assertTrue> | |||
<assertEmptyFile file="redirector.err" /> | |||
</target> | |||
<macrodef name="valRor9-12"> | |||
<attribute name="n" /> | |||
<sequential> | |||
<au:assertTrue> | |||
<and> | |||
<equals arg1="" arg2="${redirector@{n}.err}" /> | |||
<resourcesmatch astext="true"> | |||
<string value="blah after y after z${eol}x after blah after z${eol}x after y after blah" /> | |||
<propertyresource name="redirector@{n}.out" /> | |||
<file file="redirector.out" /> | |||
</resourcesmatch> | |||
</and> | |||
</au:assertTrue> | |||
<assertEmptyFile file="redirector.err" /> | |||
</sequential> | |||
</macrodef> | |||
<target name="testRedirector9" depends="xyz" if="sed.can.run"> | |||
<echo file="redirector.in">x before y before z${eol}</echo> | |||
<apply executable="sed"> | |||
<redirector outputproperty="redirector9.out" | |||
errorproperty="redirector9.err" append="true"> | |||
<inputfilterchain> | |||
<replacestring from="before" to="after" /> | |||
</inputfilterchain> | |||
<inputmapper type="merge" to="redirector.in" /> | |||
<outputmapper type="merge" to="redirector.out" /> | |||
<errormapper type="merge" to="redirector.err" /> | |||
</redirector> | |||
<arg value="-f" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
<valRor9-12 n="9" /> | |||
</target> | |||
<target name="testRedirector10" depends="xyz" if="sed.can.run"> | |||
<echo file="redirector.in">x before y before z${eol}</echo> | |||
<apply executable="sed"> | |||
<redirector outputproperty="redirector10.out" | |||
errorproperty="redirector10.err" append="true"> | |||
<outputfilterchain> | |||
<replacestring from="before" to="after" /> | |||
</outputfilterchain> | |||
<outputmapper type="merge" to="redirector.out" /> | |||
<errormapper type="merge" to="redirector.err" /> | |||
</redirector> | |||
<arg value="-f" /> | |||
<srcfile /> | |||
<arg value="redirector.in" /> | |||
<filelist refid="xyzlist" /> | |||
</apply> | |||
<valRor9-12 n="10" /> | |||
</target> | |||
<target name="testRedirector11" depends="xyz" if="sed.can.run"> | |||
<apply executable="sed"> | |||
<redirector outputproperty="redirector11.out" | |||
errorproperty="redirector11.err" | |||
inputstring="x before y before z${eol}" | |||
append="true"> | |||
<inputfilterchain> | |||
<replacestring from="before" to="after" /> | |||
</inputfilterchain> | |||
<outputmapper type="merge" to="redirector.out" /> | |||
<errormapper type="merge" to="redirector.err" /> | |||
</redirector> | |||
<arg value="-f" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
<valRor9-12 n="11" /> | |||
</target> | |||
<target name="testRedirector12" depends="xyz" if="sed.can.run"> | |||
<echo file="redirector.in">x before y before z${eol}</echo> | |||
<apply executable="sed" output="redirector.out" error="redirector.err"> | |||
<redirector outputproperty="redirector12.out" | |||
errorproperty="redirector12.err" append="true"> | |||
<outputfilterchain> | |||
<replacestring from="before" to="after" /> | |||
</outputfilterchain> | |||
<outputmapper type="glob" from="nomatch" to="nomatchout" /> | |||
<errormapper type="glob" from="nomatch" to="nomatcherr" /> | |||
</redirector> | |||
<arg value="-f" /> | |||
<srcfile /> | |||
<arg value="redirector.in" /> | |||
<filelist refid="xyzlist" /> | |||
</apply> | |||
<valRor9-12 n="12" /> | |||
</target> | |||
<target name="testRedirector13" depends="xyz" if="test.can.run"> | |||
<apply executable="sh"> | |||
<redirector> | |||
<outputfilterchain> | |||
<replacestring from="out" to="OUTPUT???" /> | |||
</outputfilterchain> | |||
<errorfilterchain> | |||
<replacestring from="err" to="ERROR!!!" /> | |||
</errorfilterchain> | |||
</redirector> | |||
<arg value="parrot.sh" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
<au:assertLogContains text="${x} OUTPUT???" /> | |||
<au:assertLogContains text="${y} OUTPUT???" /> | |||
<au:assertLogContains text="${z} OUTPUT???" /> | |||
<au:assertLogContains text="${x} ERROR!!!" /> | |||
<au:assertLogContains text="${y} ERROR!!!" /> | |||
<au:assertLogContains text="${z} ERROR!!!" /> | |||
</target> | |||
<target name="testRedirector14" depends="xyz" if="sed.can.run"> | |||
<echo file="redirector.in">z before y before x${eol}</echo> | |||
<apply executable="sed"> | |||
<redirector append="true" | |||
inputstring="x before y before z${eol}"> | |||
<outputfilterchain> | |||
<replacestring from="before" to="after" /> | |||
</outputfilterchain> | |||
<inputmapper type="glob" from="x" to="redirector.in" /> | |||
<outputmapper type="glob" from="y" to="redirector.out" /> | |||
<errormapper type="glob" from="z" to="redirector.err" /> | |||
</redirector> | |||
<arg value="-f" /> | |||
<fileset refid="xyz" /> | |||
</apply> | |||
<assertEmptyFile file="redirector.err" /> | |||
<au:assertTrue> | |||
<and> | |||
<resourcesmatch astext="true"> | |||
<string value="z after y after blahx after y after blah" /> | |||
<au:logcontent /> | |||
</resourcesmatch> | |||
</and> | |||
</au:assertTrue> | |||
<au:assertTrue message="${logcontent}"> | |||
<and> | |||
<resourcesmatch astext="true"> | |||
<string value="x after blah after z" /> | |||
<file file="redirector.out" /> | |||
</resourcesmatch> | |||
</and> | |||
</au:assertTrue> | |||
</target> | |||
<target name="pad"> | |||
<condition property="pad" value=""> | |||
<or> | |||
<not> | |||
<os family="dos" /> | |||
</not> | |||
<not> | |||
<or> | |||
<equals arg1="${ant.java.version}" arg2="1.1" /> | |||
<equals arg1="${ant.java.version}" arg2="1.2" /> | |||
</or> | |||
</not> | |||
</or> | |||
</condition> | |||
<condition property="pad" value=" "> | |||
<and> | |||
<os family="dos" /> | |||
<or> | |||
<equals arg1="${ant.java.version}" arg2="1.2" /> | |||
</or> | |||
</and> | |||
</condition> | |||
</target> | |||
<target name="testIgnoreMissing" depends="xyz,pad" if="echo.can.run"> | |||
<filelist id="xylist" dir="${basedir}" files="x,y" /> | |||
<delete file="z" /> | |||
<pathconvert property="xy" pathsep="${pad}${eol}" refid="xylist" /> | |||
<pathconvert property="xyz" pathsep="${pad}${eol}" refid="xyzlist" /> | |||
<apply executable="echo" ignoremissing="true" | |||
outputproperty="ignoretrue" append="true"> | |||
<filelist refid="xyzlist" /> | |||
</apply> | |||
<apply executable="echo" ignoremissing="false" | |||
outputproperty="ignorefalse" append="true"> | |||
<filelist refid="xyzlist" /> | |||
</apply> | |||
<au:assertTrue> | |||
<and> | |||
<equals arg1="${xy}${pad}" arg2="${ignoretrue}" /> | |||
<equals arg1="${xyz}${pad}" arg2="${ignorefalse}" /> | |||
</and> | |||
</au:assertTrue> | |||
</target> | |||
<target name="testForce" depends="xyz,pad" if="echo.can.run"> | |||
<presetdef name="ekko"> | |||
<apply executable="echo" append="true" dest="${basedir}"> | |||
<filelist refid="xyzlist" /> | |||
<mapper type="identity" /> | |||
</apply> | |||
</presetdef> | |||
<pathconvert property="xyz" pathsep="${pad}${eol}" refid="xyzlist" /> | |||
<ekko outputproperty="foo" /> | |||
<ekko outputproperty="bar" force="true" /> | |||
<au:assertTrue> | |||
<and> | |||
<equals arg1="${foo}" arg2="" /> | |||
<equals arg1="${bar}" arg2="${xyz}" /> | |||
</and> | |||
</au:assertTrue> | |||
</target> | |||
<target name="testNoDest" depends="xyz" if="echo.can.run"> | |||
<presetdef name="ekko"> | |||
<apply executable="echo" addsourcefile="false" force="true"> | |||
<filelist dir="${basedir}" files="x" /> | |||
<globmapper from="*" to="${basedir}/*" /> | |||
<targetfile /> | |||
</apply> | |||
</presetdef> | |||
<ekko outputproperty="dest" dest="${basedir}" /> | |||
<ekko outputproperty="nodest" /> | |||
<au:assertFileDoesntExist file="${dest}" /> | |||
<au:assertFileExists file="${nodest}" /> | |||
</target> | |||
<target name="testLsPath" if="ls.can.run"> | |||
<apply executable="ls" parallel="false" outputproperty="lsPathOut" | |||
force="true" dest="${basedir}" append="true" type="both"> | |||
<path path="${env.PATH}" /> | |||
<identitymapper/> | |||
</apply> | |||
<au:assertTrue> | |||
<resourcecount count="1"> | |||
<restrict> | |||
<propertyresource name="lsPathOut" /> | |||
<containsregexp expression="^${ls.can.run}$" | |||
xmlns="antlib:org.apache.tools.ant.types.resources.selectors" /> | |||
</restrict> | |||
</resourcecount> | |||
</au:assertTrue> | |||
</target> | |||
<target name="testLsPathParallel" if="ls.can.run"> | |||
<apply executable="ls" parallel="true" outputproperty="lsPathParallelOut" | |||
force="true" dest="${basedir}" append="true" type="both"> | |||
<path path="${env.PATH}" /> | |||
<identitymapper/> | |||
</apply> | |||
<au:assertTrue> | |||
<resourcecount count="1"> | |||
<restrict> | |||
<propertyresource name="lsPathParallelOut" /> | |||
<containsregexp expression="^${ls.can.run}$" | |||
xmlns="antlib:org.apache.tools.ant.types.resources.selectors" /> | |||
</restrict> | |||
</resourcecount> | |||
</au:assertTrue> | |||
</target> | |||
<target name="tearDown"> | |||
<delete> | |||
<fileset refid="xyz" /> | |||
<fileset dir="${basedir}" includes="redirect.*" /> | |||
<fileset dir="${basedir}" includes="redirector.*" /> | |||
</delete> | |||
</target> | |||
</project> |
@@ -0,0 +1,19 @@ | |||
# Licensed to the Apache Software Foundation (ASF) under one or more | |||
# contributor license agreements. See the NOTICE file distributed with | |||
# this work for additional information regarding copyright ownership. | |||
# The ASF licenses this file to You under the Apache License, Version 2.0 | |||
# (the "License"); you may not use this file except in compliance with | |||
# the License. You may obtain a copy of the License at | |||
# | |||
# http://www.apache.org/licenses/LICENSE-2.0 | |||
# | |||
# Unless required by applicable law or agreed to in writing, software | |||
# distributed under the License is distributed on an "AS IS" BASIS, | |||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
for arg in "$@" ; do | |||
echo $arg out | |||
sleep 1 | |||
echo $arg err>&2 | |||
done |
@@ -1,599 +0,0 @@ | |||
/* | |||
* Licensed to the Apache Software Foundation (ASF) under one or more | |||
* contributor license agreements. See the NOTICE file distributed with | |||
* this work for additional information regarding copyright ownership. | |||
* The ASF licenses this file to You under the Apache License, Version 2.0 | |||
* (the "License"); you may not use this file except in compliance with | |||
* the License. You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
* | |||
*/ | |||
package org.apache.tools.ant.taskdefs; | |||
import java.io.File; | |||
import java.io.FileReader; | |||
import java.io.IOException; | |||
import org.apache.tools.ant.BuildFileTest; | |||
import org.apache.tools.ant.util.FileUtils; | |||
/** | |||
* Unit test for the <apply> task. | |||
*/ | |||
public class ExecuteOnTest extends BuildFileTest { | |||
private static final String BUILD_PATH = "src/etc/testcases/taskdefs/exec/"; | |||
private static final String BUILD_FILE = BUILD_PATH + "apply.xml"; | |||
private static final String LINE_SEP = System.getProperty("line.separator"); | |||
public ExecuteOnTest(String name) { | |||
super(name); | |||
} | |||
public void setUp() { | |||
configureProject(BUILD_FILE); | |||
} | |||
public void tearDown() { | |||
executeTarget("cleanup"); | |||
} | |||
public void testNoRedirect() { | |||
executeTarget("no-redirect"); | |||
if (getProject().getProperty("test.can.run") == null) { | |||
return; | |||
} | |||
String log = getLog(); | |||
File x = getProject().resolveFile("x"); | |||
File y = getProject().resolveFile("y"); | |||
File z = getProject().resolveFile("z"); | |||
int xout = log.indexOf(x + " out"); | |||
int yout = log.indexOf(y + " out"); | |||
int zout = log.indexOf(z + " out"); | |||
int xerr = log.indexOf(x + " err"); | |||
int yerr = log.indexOf(y + " err"); | |||
int zerr = log.indexOf(z + " err"); | |||
assertFalse("xout=" + xout, xout < 0); | |||
assertFalse("yout=" + yout, yout < 0); | |||
assertFalse("zout=" + zout, zout < 0); | |||
assertFalse("xerr=" + xerr, xerr < 0); | |||
assertFalse("yerr=" + yerr, yerr < 0); | |||
assertFalse("zerr=" + zerr, zerr < 0); | |||
assertFalse("yout < xout", yout < xout); | |||
assertFalse("zout < yout", zout < yout); | |||
assertFalse("yerr < xerr", yerr < xerr); | |||
assertFalse("zerr < yerr", zerr < yerr); | |||
} | |||
public void testRedirect1() throws IOException { | |||
executeTarget("redirect1"); | |||
if (getProject().getProperty("test.can.run") == null) { | |||
return; | |||
} | |||
String actualOut = getFileString("redirect.out"); | |||
File x = getProject().resolveFile("x"); | |||
File y = getProject().resolveFile("y"); | |||
File z = getProject().resolveFile("z"); | |||
int xout = actualOut.indexOf(x + " out"); | |||
int yout = actualOut.indexOf(y + " out"); | |||
int zout = actualOut.indexOf(z + " out"); | |||
int xerr = actualOut.indexOf(x + " err"); | |||
int yerr = actualOut.indexOf(y + " err"); | |||
int zerr = actualOut.indexOf(z + " err"); | |||
assertFalse("xout=" + xout, xout < 0); | |||
assertFalse("yout=" + yout, yout < 0); | |||
assertFalse("zout=" + zout, zout < 0); | |||
assertFalse("xerr=" + xerr, xerr < 0); | |||
assertFalse("yerr=" + yerr, yerr < 0); | |||
assertFalse("zerr=" + zerr, zerr < 0); | |||
assertFalse("yout < xout", yout < xout); | |||
assertFalse("zout < yout", zout < yout); | |||
assertFalse("yerr < xerr", yerr < xerr); | |||
assertFalse("zerr < yerr", zerr < yerr); | |||
} | |||
public void testRedirect2() throws IOException { | |||
executeTarget("redirect2"); | |||
if (getProject().getProperty("test.can.run") == null) { | |||
return; | |||
} | |||
String actualOut = getFileString("redirect.out"); | |||
String actualErr = getFileString("redirect.err"); | |||
File x = getProject().resolveFile("x"); | |||
File y = getProject().resolveFile("y"); | |||
File z = getProject().resolveFile("z"); | |||
int xout = actualOut.indexOf(x + " out"); | |||
int yout = actualOut.indexOf(y + " out"); | |||
int zout = actualOut.indexOf(z + " out"); | |||
int xerr = actualErr.indexOf(x + " err"); | |||
int yerr = actualErr.indexOf(y + " err"); | |||
int zerr = actualErr.indexOf(z + " err"); | |||
assertFalse("xout=" + xout, xout < 0); | |||
assertFalse("yout=" + yout, yout < 0); | |||
assertFalse("zout=" + zout, zout < 0); | |||
assertFalse("xerr=" + xerr, xerr < 0); | |||
assertFalse("yerr=" + yerr, yerr < 0); | |||
assertFalse("zerr=" + zerr, zerr < 0); | |||
assertFalse("yout < xout", yout < xout); | |||
assertFalse("zout < yout", zout < yout); | |||
assertFalse("yerr < xerr", yerr < xerr); | |||
assertFalse("zerr < yerr", zerr < yerr); | |||
} | |||
public void testRedirect3() throws IOException { | |||
executeTarget("redirect3"); | |||
if (getProject().getProperty("test.can.run") == null) { | |||
return; | |||
} | |||
String actualOut = getFileString("redirect.out"); | |||
File x = getProject().resolveFile("x"); | |||
File y = getProject().resolveFile("y"); | |||
File z = getProject().resolveFile("z"); | |||
int xout = actualOut.indexOf(x + " out"); | |||
int yout = actualOut.indexOf(y + " out"); | |||
int zout = actualOut.indexOf(z + " out"); | |||
int xerr = getLog().indexOf(x + " err"); | |||
int yerr = getLog().indexOf(y + " err"); | |||
int zerr = getLog().indexOf(z + " err"); | |||
assertFalse("xout=" + xout, xout < 0); | |||
assertFalse("yout=" + yout, yout < 0); | |||
assertFalse("zout=" + zout, zout < 0); | |||
assertFalse("xerr=" + xerr, xerr < 0); | |||
assertFalse("yerr=" + yerr, yerr < 0); | |||
assertFalse("zerr=" + zerr, zerr < 0); | |||
assertFalse("yout < xout", yout < xout); | |||
assertFalse("zout < yout", zout < yout); | |||
assertFalse("yerr < xerr", yerr < xerr); | |||
assertFalse("zerr < yerr", zerr < yerr); | |||
String outProperty = getProject().getProperty("redirect.out"); | |||
int pxout = outProperty.indexOf(x + " out"); | |||
int pyout = outProperty.indexOf(y + " out"); | |||
int pzout = outProperty.indexOf(z + " out"); | |||
assertFalse("pxout=" + pxout, pxout < 0); | |||
assertFalse("pyout=" + pyout, pyout < 0); | |||
assertFalse("pzout=" + pzout, pzout < 0); | |||
assertFalse("pyout < pxout", pyout < pxout); | |||
assertFalse("pzout < pyout", pzout < pyout); | |||
} | |||
public void testRedirect4() throws IOException { | |||
executeTarget("redirect4"); | |||
if (getProject().getProperty("test.can.run") == null) { | |||
return; | |||
} | |||
String actualOut = getFileString("redirect.out"); | |||
String actualErr = getFileString("redirect.err"); | |||
File x = getProject().resolveFile("x"); | |||
File y = getProject().resolveFile("y"); | |||
File z = getProject().resolveFile("z"); | |||
int xout = actualOut.indexOf(x + " out"); | |||
int yout = actualOut.indexOf(y + " out"); | |||
int zout = actualOut.indexOf(z + " out"); | |||
int xerr = actualErr.indexOf(x + " err"); | |||
int yerr = actualErr.indexOf(y + " err"); | |||
int zerr = actualErr.indexOf(z + " err"); | |||
assertFalse("xout=" + xout, xout < 0); | |||
assertFalse("yout=" + yout, yout < 0); | |||
assertFalse("zout=" + zout, zout < 0); | |||
assertFalse("xerr=" + xerr, xerr < 0); | |||
assertFalse("yerr=" + yerr, yerr < 0); | |||
assertFalse("zerr=" + zerr, zerr < 0); | |||
assertFalse("yout < xout", yout < xout); | |||
assertFalse("zout < yout", zout < yout); | |||
assertFalse("yerr < xerr", yerr < xerr); | |||
assertFalse("zerr < yerr", zerr < yerr); | |||
String outProperty = getProject().getProperty("redirect.out"); | |||
int pxout = outProperty.indexOf(x + " out"); | |||
int pyout = outProperty.indexOf(y + " out"); | |||
int pzout = outProperty.indexOf(z + " out"); | |||
assertFalse("pxout=" + pxout, pxout < 0); | |||
assertFalse("pyout=" + pyout, pyout < 0); | |||
assertFalse("pzout=" + pzout, pzout < 0); | |||
assertFalse("pyout < pxout", pyout < pxout); | |||
assertFalse("pzout < pyout", pzout < pyout); | |||
String errorProperty = getProject().getProperty("redirect.err"); | |||
int pxerr = errorProperty.indexOf(x + " err"); | |||
int pyerr = errorProperty.indexOf(y + " err"); | |||
int pzerr = errorProperty.indexOf(z + " err"); | |||
assertFalse("pxerr=" + pxerr, pxerr < 0); | |||
assertFalse("pyerr=" + pyerr, pyerr < 0); | |||
assertFalse("pzerr=" + pzerr, pzerr < 0); | |||
assertFalse("pyerr < pxerr", pyerr < pxerr); | |||
assertFalse("pzerr < pyerr", pzerr < pyerr); | |||
} | |||
public void testRedirect5() throws IOException { | |||
testRedirect5or6("redirect5"); | |||
} | |||
public void testRedirect6() throws IOException { | |||
testRedirect5or6("redirect6"); | |||
} | |||
private void testRedirect5or6(String target) throws IOException { | |||
executeTarget(target); | |||
if (getProject().getProperty("sed.can.run") == null) { | |||
return; | |||
} | |||
assertPropertyEquals("redirect.out", getProject().replaceProperties( | |||
"blah y z${line.separator}x blah z${line.separator}x y blah")); | |||
assertPropertyEquals("redirect.err", ""); | |||
assertEquals("unexpected output", | |||
"blah y z\nx blah z\nx y blah\n", getFileString("redirect.out")); | |||
assertNull("unexpected error output", getFileString("redirect.err")); | |||
} | |||
public void testRedirect7() throws IOException { | |||
executeTarget("redirect7"); | |||
if (getProject().getProperty("sed.can.run") == null) { | |||
return; | |||
} | |||
assertPropertyEquals("redirect.out", "blah y z"); | |||
assertPropertyUnset("redirect.err"); | |||
assertEquals("unexpected output", | |||
"x y blah\n", getFileString("redirect.out")); | |||
assertNull("unexpected error output", getFileString("redirect.err")); | |||
} | |||
public void testRedirector1() { | |||
executeTarget("init"); | |||
if (getProject().getProperty("test.can.run") == null) { | |||
return; | |||
} | |||
expectBuildException("redirector1", "cannot have > 1 nested <redirector>s"); | |||
} | |||
public void testRedirector2() throws IOException { | |||
executeTarget("redirector2"); | |||
if (getProject().getProperty("test.can.run") == null) { | |||
return; | |||
} | |||
String actualOut = getFileString("redirector.out"); | |||
File x = getProject().resolveFile("x"); | |||
File y = getProject().resolveFile("y"); | |||
File z = getProject().resolveFile("z"); | |||
int xout = actualOut.indexOf(x + " out"); | |||
int yout = actualOut.indexOf(y + " out"); | |||
int zout = actualOut.indexOf(z + " out"); | |||
int xerr = actualOut.indexOf(x + " err"); | |||
int yerr = actualOut.indexOf(y + " err"); | |||
int zerr = actualOut.indexOf(z + " err"); | |||
assertFalse("xout=" + xout, xout < 0); | |||
assertFalse("yout=" + yout, yout < 0); | |||
assertFalse("zout=" + zout, zout < 0); | |||
assertFalse("xerr=" + xerr, xerr < 0); | |||
assertFalse("yerr=" + yerr, yerr < 0); | |||
assertFalse("zerr=" + zerr, zerr < 0); | |||
assertFalse("yout < xout", yout < xout); | |||
assertFalse("zout < yout", zout < yout); | |||
assertFalse("yerr < xerr", yerr < xerr); | |||
assertFalse("zerr < yerr", zerr < yerr); | |||
} | |||
public void testRedirector3() throws IOException { | |||
executeTarget("redirector3"); | |||
if (getProject().getProperty("test.can.run") == null) { | |||
return; | |||
} | |||
String actualOut = getFileString("redirector.out"); | |||
String actualErr = getFileString("redirector.err"); | |||
File x = getProject().resolveFile("x"); | |||
File y = getProject().resolveFile("y"); | |||
File z = getProject().resolveFile("z"); | |||
int xout = actualOut.indexOf(x + " out"); | |||
int yout = actualOut.indexOf(y + " out"); | |||
int zout = actualOut.indexOf(z + " out"); | |||
int xerr = actualErr.indexOf(x + " err"); | |||
int yerr = actualErr.indexOf(y + " err"); | |||
int zerr = actualErr.indexOf(z + " err"); | |||
assertFalse("xout=" + xout, xout < 0); | |||
assertFalse("yout=" + yout, yout < 0); | |||
assertFalse("zout=" + zout, zout < 0); | |||
assertFalse("xerr=" + xerr, xerr < 0); | |||
assertFalse("yerr=" + yerr, yerr < 0); | |||
assertFalse("zerr=" + zerr, zerr < 0); | |||
assertFalse("yout < xout", yout < xout); | |||
assertFalse("zout < yout", zout < yout); | |||
assertFalse("yerr < xerr", yerr < xerr); | |||
assertFalse("zerr < yerr", zerr < yerr); | |||
} | |||
public void testRedirector4() throws IOException { | |||
executeTarget("redirector4"); | |||
if (getProject().getProperty("test.can.run") == null) { | |||
return; | |||
} | |||
String actualOut = getFileString("redirector.out"); | |||
File x = getProject().resolveFile("x"); | |||
File y = getProject().resolveFile("y"); | |||
File z = getProject().resolveFile("z"); | |||
int xout = actualOut.indexOf(x + " out"); | |||
int yout = actualOut.indexOf(y + " out"); | |||
int zout = actualOut.indexOf(z + " out"); | |||
int xerr = getLog().indexOf(x + " err"); | |||
int yerr = getLog().indexOf(y + " err"); | |||
int zerr = getLog().indexOf(z + " err"); | |||
assertFalse("xout=" + xout, xout < 0); | |||
assertFalse("yout=" + yout, yout < 0); | |||
assertFalse("zout=" + zout, zout < 0); | |||
assertFalse("xerr=" + xerr, xerr < 0); | |||
assertFalse("yerr=" + yerr, yerr < 0); | |||
assertFalse("zerr=" + zerr, zerr < 0); | |||
assertFalse("yout < xout", yout < xout); | |||
assertFalse("zout < yout", zout < yout); | |||
assertFalse("yerr < xerr", yerr < xerr); | |||
assertFalse("zerr < yerr", zerr < yerr); | |||
String outProperty = getProject().getProperty("redirector.out"); | |||
int pxout = outProperty.indexOf(x + " out"); | |||
int pyout = outProperty.indexOf(y + " out"); | |||
int pzout = outProperty.indexOf(z + " out"); | |||
assertFalse("pxout=" + pxout, pxout < 0); | |||
assertFalse("pyout=" + pyout, pyout < 0); | |||
assertFalse("pzout=" + pzout, pzout < 0); | |||
assertFalse("pyout < pxout", pyout < pxout); | |||
assertFalse("pzout < pyout", pzout < pyout); | |||
} | |||
public void testRedirector5() throws IOException { | |||
testRedirector5or6("redirector5"); | |||
} | |||
public void testRedirector6() throws IOException { | |||
testRedirector5or6("redirector6"); | |||
} | |||
private void testRedirector5or6(String target) throws IOException { | |||
executeTarget(target); | |||
if (getProject().getProperty("test.can.run") == null) { | |||
return; | |||
} | |||
String actualOut = getFileString("redirector.out"); | |||
String actualErr = getFileString("redirector.err"); | |||
File x = getProject().resolveFile("x"); | |||
File y = getProject().resolveFile("y"); | |||
File z = getProject().resolveFile("z"); | |||
int xout = actualOut.indexOf(x + " out"); | |||
int yout = actualOut.indexOf(y + " out"); | |||
int zout = actualOut.indexOf(z + " out"); | |||
int xerr = actualErr.indexOf(x + " err"); | |||
int yerr = actualErr.indexOf(y + " err"); | |||
int zerr = actualErr.indexOf(z + " err"); | |||
assertFalse("xout=" + xout, xout < 0); | |||
assertFalse("yout=" + yout, yout < 0); | |||
assertFalse("zout=" + zout, zout < 0); | |||
assertFalse("xerr=" + xerr, xerr < 0); | |||
assertFalse("yerr=" + yerr, yerr < 0); | |||
assertFalse("zerr=" + zerr, zerr < 0); | |||
assertFalse("yout < xout", yout < xout); | |||
assertFalse("zout < yout", zout < yout); | |||
assertFalse("yerr < xerr", yerr < xerr); | |||
assertFalse("zerr < yerr", zerr < yerr); | |||
String outProperty = getProject().getProperty("redirector.out"); | |||
int pxout = outProperty.indexOf(x + " out"); | |||
int pyout = outProperty.indexOf(y + " out"); | |||
int pzout = outProperty.indexOf(z + " out"); | |||
assertFalse("pxout=" + pxout, pxout < 0); | |||
assertFalse("pyout=" + pyout, pyout < 0); | |||
assertFalse("pzout=" + pzout, pzout < 0); | |||
assertFalse("pyout < pxout", pyout < pxout); | |||
assertFalse("pzout < pyout", pzout < pyout); | |||
String errorProperty = getProject().getProperty("redirector.err"); | |||
int pxerr = errorProperty.indexOf(x + " err"); | |||
int pyerr = errorProperty.indexOf(y + " err"); | |||
int pzerr = errorProperty.indexOf(z + " err"); | |||
assertFalse("pxerr=" + pxerr, pxerr < 0); | |||
assertFalse("pyerr=" + pyerr, pyerr < 0); | |||
assertFalse("pzerr=" + pzerr, pzerr < 0); | |||
assertFalse("pyerr < pxerr", pyerr < pxerr); | |||
assertFalse("pzerr < pyerr", pzerr < pyerr); | |||
} | |||
public void testRedirector7() throws IOException { | |||
executeTarget("redirector7"); | |||
if (getProject().getProperty("test.can.run") == null) { | |||
return; | |||
} | |||
String actualOut = getFileString("redirector.out"); | |||
String actualErr = getFileString("redirector.err"); | |||
File x = getProject().resolveFile("x"); | |||
File y = getProject().resolveFile("y"); | |||
File z = getProject().resolveFile("z"); | |||
int xout = actualOut.indexOf(x + " out"); | |||
int yout = actualOut.indexOf(y + " out"); | |||
int zout = actualOut.indexOf(z + " out"); | |||
int xerr = actualErr.indexOf(x + " ERROR!!!"); | |||
int yerr = actualErr.indexOf(y + " ERROR!!!"); | |||
int zerr = actualErr.indexOf(z + " ERROR!!!"); | |||
assertFalse("xout=" + xout, xout < 0); | |||
assertFalse("yout=" + yout, yout < 0); | |||
assertFalse("zout=" + zout, zout < 0); | |||
assertFalse("xerr=" + xerr, xerr < 0); | |||
assertFalse("yerr=" + yerr, yerr < 0); | |||
assertFalse("zerr=" + zerr, zerr < 0); | |||
assertFalse("yout < xout", yout < xout); | |||
assertFalse("zout < yout", zout < yout); | |||
assertFalse("yerr < xerr", yerr < xerr); | |||
assertFalse("zerr < yerr", zerr < yerr); | |||
String outProperty = getProject().getProperty("redirector.out"); | |||
int pxout = outProperty.indexOf(x + " out"); | |||
int pyout = outProperty.indexOf(y + " out"); | |||
int pzout = outProperty.indexOf(z + " out"); | |||
assertFalse("pxout=" + pxout, pxout < 0); | |||
assertFalse("pyout=" + pyout, pyout < 0); | |||
assertFalse("pzout=" + pzout, pzout < 0); | |||
assertFalse("pyout < pxout", pyout < pxout); | |||
assertFalse("pzout < pyout", pzout < pyout); | |||
String errorProperty = getProject().getProperty("redirector.err"); | |||
int pxerr = errorProperty.indexOf(x + " ERROR!!!"); | |||
int pyerr = errorProperty.indexOf(y + " ERROR!!!"); | |||
int pzerr = errorProperty.indexOf(z + " ERROR!!!"); | |||
assertFalse("pxerr=" + pxerr, pxerr < 0); | |||
assertFalse("pyerr=" + pyerr, pyerr < 0); | |||
assertFalse("pzerr=" + pzerr, pzerr < 0); | |||
assertFalse("pyerr < pxerr", pyerr < pxerr); | |||
assertFalse("pzerr < pyerr", pzerr < pyerr); | |||
} | |||
public void testRedirector8() throws IOException { | |||
executeTarget("redirector8"); | |||
if (getProject().getProperty("sed.can.run") == null) { | |||
return; | |||
} | |||
assertPropertyEquals("redirector.out", getProject().replaceProperties( | |||
"blah y z${line.separator}x blah z${line.separator}x y blah")); | |||
assertPropertyEquals("redirector.err", ""); | |||
assertEquals("unexpected output", | |||
"blah y z\nx blah z\nx y blah\n", getFileString("redirector.out")); | |||
assertNull("unexpected error output", getFileString("redirector.err")); | |||
} | |||
public void testRedirector9() throws IOException { | |||
testRedirector9Thru12("redirector9"); | |||
} | |||
public void testRedirector10() throws IOException { | |||
testRedirector9Thru12("redirector10"); | |||
} | |||
public void testRedirector11() throws IOException { | |||
testRedirector9Thru12("redirector11"); | |||
} | |||
public void testRedirector12() throws IOException { | |||
testRedirector9Thru12("redirector12"); | |||
} | |||
private void testRedirector9Thru12(String target) throws IOException { | |||
executeTarget(target); | |||
if (getProject().getProperty("sed.can.run") == null) { | |||
return; | |||
} | |||
assertNull("unexpected error output", getFileString("redirector.err")); | |||
assertPropertyEquals("redirector.out", getProject().replaceProperties( | |||
"blah after y after z${line.separator}x after blah after z" | |||
+ "${line.separator}x after y after blah")); | |||
assertPropertyEquals("redirector.err", ""); | |||
assertEquals("unexpected output", | |||
"blah after y after z\nx after blah after z" | |||
+ "\nx after y after blah\n", getFileString("redirector.out")); | |||
} | |||
public void testRedirector13() { | |||
executeTarget("redirector13"); | |||
if (getProject().getProperty("test.can.run") == null) { | |||
return; | |||
} | |||
String log = getLog(); | |||
File x = getProject().resolveFile("x"); | |||
File y = getProject().resolveFile("y"); | |||
File z = getProject().resolveFile("z"); | |||
int xout = log.indexOf(x + " OUTPUT???"); | |||
int yout = log.indexOf(y + " OUTPUT???"); | |||
int zout = log.indexOf(z + " OUTPUT???"); | |||
int xerr = log.indexOf(x + " ERROR!!!"); | |||
int yerr = log.indexOf(y + " ERROR!!!"); | |||
int zerr = log.indexOf(z + " ERROR!!!"); | |||
assertFalse("xout=" + xout, xout < 0); | |||
assertFalse("yout=" + yout, yout < 0); | |||
assertFalse("zout=" + zout, zout < 0); | |||
assertFalse("xerr=" + xerr, xerr < 0); | |||
assertFalse("yerr=" + yerr, yerr < 0); | |||
assertFalse("zerr=" + zerr, zerr < 0); | |||
assertFalse("yout < xout", yout < xout); | |||
assertFalse("zout < yout", zout < yout); | |||
assertFalse("yerr < xerr", yerr < xerr); | |||
assertFalse("zerr < yerr", zerr < yerr); | |||
} | |||
public void testRedirector14() throws IOException { | |||
executeTarget("redirector14"); | |||
if (getProject().getProperty("sed.can.run") == null) { | |||
return; | |||
} | |||
assertEquals("unexpected log content", | |||
"z after y after blahx after y after blah", getLog()); | |||
assertEquals("unexpected redirector.out content", | |||
"x after blah after z\n", getFileString("redirector.out")); | |||
assertNull("unexpected redirector.err content", getFileString("redirector.err")); | |||
} | |||
public void testIgnoreMissing() { | |||
executeTarget("ignoremissing"); | |||
} | |||
public void testForce() { | |||
executeTarget("force"); | |||
} | |||
public void testNoDest() { | |||
executeTarget("testNoDest"); | |||
} | |||
public void testLsPath() { | |||
testLsPath("lsPath"); | |||
} | |||
public void testLsPathParallel() { | |||
testLsPath("lsPathParallel"); | |||
} | |||
private void testLsPath(String target) { | |||
executeTarget(target); | |||
if (getProject().getProperty("ls.can.run") == null) { | |||
return; | |||
} | |||
String foo = getProject().getProperty("foo"); | |||
assertNotNull(foo); | |||
int indNoExt = foo.indexOf("ls" + LINE_SEP); | |||
int indExe = foo.indexOf("ls.exe" + LINE_SEP); | |||
assertTrue(indNoExt >= 0 || indExe >= 0); | |||
} | |||
//borrowed from TokenFilterTest | |||
private String getFileString(String filename) throws IOException { | |||
String result = null; | |||
FileReader reader = null; | |||
try { | |||
reader = new FileReader(getProject().resolveFile(filename)); | |||
result = FileUtils.readFully(reader); | |||
} finally { | |||
FileUtils.close(reader); | |||
} | |||
return result; | |||
} | |||
} |