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.

replaceregexp.xml 1.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <project name="test" default="def" basedir=".">
  2. <property name="tmpregexp" value="tmpregexp"/>
  3. <target name="def">
  4. <fail>This build file should only be run from within the testcase</fail>
  5. </target>
  6. <target name="setup">
  7. <copy file="replaceregexp.properties" tofile="test.properties" />
  8. </target>
  9. <target name="setup-nl">
  10. <copy file="replaceregexp2.properties" tofile="test.properties" />
  11. </target>
  12. <target name="testReplace" depends="setup">
  13. <replaceregexp file="test.properties" byline="true">
  14. <regexp pattern="Old(.*)=(.*)" />
  15. <substitution expression="NewProp=\1\2" />
  16. </replaceregexp>
  17. </target>
  18. <!-- use in conjunction with testDirectoryDateDoesNotChange to make sure something will happen -->
  19. <target name="touchDirectory">
  20. <mkdir dir="${tmpregexp}"/>
  21. <copy file="replaceregexp.properties" tofile="${tmpregexp}/test.properties" />
  22. <sleep seconds="2"/>
  23. </target>
  24. <target name="testDirectoryDateDoesNotChange">
  25. <replaceregexp file="${tmpregexp}/test.properties" byline="true">
  26. <regexp pattern="foo" />
  27. <substitution expression="bar"/>
  28. </replaceregexp>
  29. </target>
  30. <target name="testDontAddNewline1" depends="setup-nl">
  31. <replaceregexp file="test.properties" byline="false">
  32. <regexp pattern="Old(.*)=(.*)" />
  33. <substitution expression="NewProp=\1\2" />
  34. </replaceregexp>
  35. </target>
  36. <target name="testDontAddNewline2" depends="setup-nl">
  37. <replaceregexp file="test.properties" byline="true">
  38. <regexp pattern="Old(.*)=(.*)" />
  39. <substitution expression="NewProp=\1\2" />
  40. </replaceregexp>
  41. </target>
  42. <target name="cleanup">
  43. <delete file="test.properties" />
  44. <delete dir="${tmpregexp}" quiet="true"/>
  45. </target>
  46. </project>