You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

exec.xml 3.1 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?xml version="1.0"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <project name="exec-test" default="spawn" basedir=".">
  17. <property name="output" location="${java.io.tmpdir}/testoutput"/>
  18. <target name="init">
  19. <!-- this property can be overriden programatically in the Java test case -->
  20. <property name="timeToWait" value="10"/>
  21. <!-- this property can be overriden programatically in the Java test case -->
  22. <mkdir dir="${output}"/>
  23. <property name="logFile" value="${output}/spawn.log"/>
  24. <property environment="env"/>
  25. <!-- UNIX -->
  26. <available file="sh" filepath="${env.PATH}" property="sh.executable"/>
  27. <!-- CYGWIN -->
  28. <available file="sh.exe" filepath="${env.PATH}" property="sh.exe.executable"/>
  29. <condition property="test.can.run">
  30. <or>
  31. <isset property="sh.executable"/>
  32. <isset property="sh.exe.executable"/>
  33. </or>
  34. </condition>
  35. </target>
  36. <target name="spawn" depends="init" if="test.can.run">
  37. <exec executable="sh" spawn="true">
  38. <arg value="spawn.sh"/>
  39. <arg value="${timeToWait}" />
  40. <arg value="${logFile}" />
  41. </exec>
  42. </target>
  43. <target name="test-out-and-err" description="see https://issues.apache.org/bugzilla/show_bug.cgi?id=50507" depends="init" if="test.can.run">
  44. <mkdir dir="${output}" />
  45. <ant antfile="blabla.xml" output="${output}/test-out-and-err.txt">
  46. </ant>
  47. <loadfile srcfile="${output}/test-out-and-err.txt" property="test-out-and-err">
  48. <filterchain>
  49. <replaceregex pattern="^\s*\[exec\] some blablablablablablablablablablablabla error message err$" flags="m" />
  50. <replaceregex pattern="^\s*\[exec\] some blablablablablablablablablablablabla info message out$" flags="m" />
  51. </filterchain>
  52. </loadfile>
  53. <echo>${test-out-and-err}</echo>
  54. <fail message="output indicates a mixup of out and err">
  55. <condition>
  56. <contains string="${test-out-and-err}" substring="[exec]" />
  57. </condition>
  58. </fail>
  59. </target>
  60. <target name="cleanup">
  61. <delete file="${logFile}"/>
  62. <delete dir="${output}"/>
  63. </target>
  64. </project>