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

test-taskdefs.xml 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <!-- -*- Mode: SGML; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -->
  2. <!-- -->
  3. <!-- This file is part of the compiler and core tools for the AspectJ(tm) -->
  4. <!-- programming language; see http://aspectj.org -->
  5. <!-- -->
  6. <!-- The contents of this file are subject to the Mozilla Public License -->
  7. <!-- Version 1.1 (the "License"); you may not use this file except in -->
  8. <!-- compliance with the License. You may obtain a copy of the License at -->
  9. <!-- either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. -->
  10. <!-- -->
  11. <!-- Software distributed under the License is distributed on an "AS IS" basis, -->
  12. <!-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -->
  13. <!-- for the specific language governing rights and limitations under the -->
  14. <!-- License. -->
  15. <!-- -->
  16. <!-- The Original Code is AspectJ. -->
  17. <!-- -->
  18. <!-- The Initial Developer of the Original Code is Xerox Corporation. Portions -->
  19. <!-- created by Xerox Corporation are Copyright (C) 1999, 2000 Xerox Corporation. -->
  20. <!-- All Rights Reserved. -->
  21. <!-- ============================================================================== -->
  22. <!-- To build, define JAVA_HOME,place in examples/ and run from examples/.. -->
  23. <!-- ============================================================================== -->
  24. <!-- todo: non-distribution license?? -->
  25. <project name="test-taskdefs" default="test">
  26. <!-- ========================================================================== -->
  27. <!-- Init -->
  28. <!-- ========================================================================== -->
  29. <target name="init"
  30. description="caller must define jdk.tools.jar and product.dir or run from product.examples.dir">
  31. <echo message="init test-taskdefs.xml"/>
  32. <property name="PS" value="${path.separator}"/>
  33. <property name="knownFail"
  34. value=" - known failure"/>
  35. <!-- define product.dir or run from it -->
  36. <property name="product.dir"
  37. location=".."/>
  38. <!-- expected from install -->
  39. <property name="ex.dir"
  40. location="${product.dir}/examples"/>
  41. <property name="product.examples.dir"
  42. location="${ex.dir}"/>
  43. <!-- created after install -->
  44. <property name="test.dir"
  45. location="${product.dir}/test"/>
  46. <property name="expect.file"
  47. location="${test.dir}/expect.out"/>
  48. <property name="actual.file"
  49. location="${test.dir}/actual.out"/>
  50. <property name="empty.dir"
  51. location="${test.dir}/emptydir"/>
  52. <property name="temp.dir"
  53. location="${test.dir}/temp"/>
  54. <property name="classes.dir"
  55. location="${test.dir}/classes"/>
  56. <property name="expected.classes.dir"
  57. location="${test.dir}/expectedClasses"/>
  58. <property name="working.dir"
  59. location="${product.dir}/workingdir"/>
  60. <property name="expected.working.dir"
  61. location="${test.dir}/expectedWorkingdir"/>
  62. <mkdir dir="${empty.dir}"/>
  63. <mkdir dir="${temp.dir}"/>
  64. <mkdir dir="${classes.dir}"/>
  65. <mkdir dir="${expected.classes.dir}"/>
  66. <mkdir dir="${working.dir}"/>
  67. <mkdir dir="${expected.working.dir}"/>
  68. <property name="aspectj-ant.jar"
  69. location="${product.dir}/lib/aspectj-ant.jar"/>
  70. <property name="aspectjrt.jar"
  71. location="${product.dir}/lib/aspectjrt.jar"/>
  72. <property name="aspectjtools.jar"
  73. location="${product.dir}/lib/aspectjtools.jar"/>
  74. <!-- alltesting.jar required for comparefiles -->
  75. <property name="alltesting.jar"
  76. location="${product.dir}/lib/alltesting.jar"/>
  77. <available file="${aspectj-ant.jar}"
  78. property="aspectj-ant.jar.available"/>
  79. <available file="${aspectjrt.jar}"
  80. property="aspectjrt.jar.available"/>
  81. <available file="${aspectjtools.jar}"
  82. property="aspectjtools.jar.available"/>
  83. <property name="run.classpath"
  84. location="${classes.dir}${PS}${aspectjrt.jar}"/>
  85. <property name="simple.run.classpath"
  86. location="${product.dir}${PS}${aspectjrt.jar}"/>
  87. </target>
  88. <target name="init.taskdefs"
  89. depends="init,jars.available"
  90. description="initialize taskdefs without ant.home/lib" >
  91. <taskdef name="ajc"
  92. classname="org.aspectj.tools.ant.taskdefs.Ajc" >
  93. <classpath>
  94. <pathelement path="${aspectjrt.jar}"/>
  95. <pathelement path="${aspectj-ant.jar}"/>
  96. <pathelement path="${aspectjtools.jar}"/>
  97. <pathelement path="${jdk.tools.jar}"/>
  98. </classpath>
  99. </taskdef>
  100. <taskdef name="ajdoc"
  101. classname="org.aspectj.tools.ant.taskdefs.Ajdoc" >
  102. <classpath>
  103. <pathelement path="${aspectjrt.jar}"/>
  104. <pathelement path="${aspectj-ant.jar}"/>
  105. <pathelement path="${aspectjtools.jar}"/>
  106. <pathelement path="${jdk.tools.jar}"/>
  107. </classpath>
  108. </taskdef>
  109. <taskdef name="comparefiles"
  110. classname="org.aspectj.testing.taskdefs.CompareFiles">
  111. <classpath> <!-- todo: setup -->
  112. <pathelement path="${alltesting.jar}"/>
  113. </classpath>
  114. </taskdef>
  115. </target>
  116. <target name="jars.available"
  117. depends="aspectjtools.jar.available,aspectj-ant.jar.available"/>
  118. <target name="aspectjtools.jar.available" depends="init" unless="aspectjtools.jar.available" >
  119. <fail message="expecting aspectjtools.jar at ${aspectjtools.jar}"/>
  120. </target>
  121. <target name="aspectj-ant.jar.available" depends="init" unless="aspectj-ant.jar.available" >
  122. <fail message="expecting aspectj-ant.jar at ${aspectj-ant.jar}"/>
  123. </target>
  124. <target name="clean" depends="init"
  125. description="todo clean output created by this script">
  126. </target>
  127. <target name="test" depends="test.ajc,test.ajdoc"/>
  128. <target name="clear.test.dir" depends="init">
  129. <mkdir dir="${test.dir}"/>
  130. <delete dir="${test.dir}"/>
  131. <mkdir dir="${test.dir}"/>
  132. </target>
  133. <target name="test.ajdoc" depends="init,init.taskdefs,clear.test.dir"
  134. description="run variants of ajdoc taskdef on bean, other examples">
  135. <mkdir dir="${expected.classes.dir}"/>
  136. <delete quiet="on" dir="${expected.classes.dir}"/>
  137. <mkdir dir="${expected.classes.dir}"/>
  138. <mkdir dir="${classes.dir}"/>
  139. <delete quiet="on" dir="${classes.dir}"/>
  140. <mkdir dir="${classes.dir}"/>
  141. <antcall target="cleanajc"/>
  142. <echo message="## ajdoc setup classes dir" />
  143. <ajdoc classpath="${aspectjrt.jar}" destdir="${expected.classes.dir}"
  144. srcdir="${ex.dir}/bean" packagenames="bean"
  145. argfile="${ex.dir}/bean/files.lst"
  146. private="on" />
  147. <echo message="## @testcase ajdoc same as setup" />
  148. <antcall target="cleanajc"/>
  149. <ajdoc classpath="${aspectjrt.jar}" destdir="${classes.dir}"
  150. srcdir="${ex.dir}/bean" packagenames="bean"
  151. argfile="${ex.dir}/bean/files.lst"
  152. private="on" />
  153. <antcall target="verifyAndCleanup.ajdoc"/>
  154. <echo message="## @testcase ajdoc argfile only with nested classpath" />
  155. <ajdoc destdir="${classes.dir}"
  156. argfile="${ex.dir}/bean/files.lst"
  157. private="on" >
  158. <classpath> <pathelement path="${aspectjrt.jar}"/> </classpath>
  159. </ajdoc>
  160. <antcall target="verifyAndCleanup.ajdoc"/>
  161. <!-- omitted until fixed
  162. <echo message="## @testcase ajdoc srcdir with include argument - getting fail" />
  163. <ajdoc classpath="${aspectjrt.jar}" destdir="${classes.dir}"
  164. srcdir="${ex.dir}/bean" includes="*.java"
  165. private="on" />
  166. <antcall target="verifyAndCleanup.ajdoc"/>
  167. <echo message="## ajdoc need @testcase ajdoc nested src with kitchen sink" />
  168. <echo message="## @testcase ajdoc argfile todo " />
  169. <echo message="## @testcase ajdoc Vincent Massol bug" />
  170. <ajdoc destdir="${classes.dir}"
  171. srcdir="${ex.dir}/bean"
  172. private="on" >
  173. <include name="*.java"/>
  174. <include name="**.java"/>
  175. <classpath> <pathelement path="${aspectjrt.jar}"/> </classpath>
  176. </ajdoc>
  177. <antcall target="verifyAndCleanup.ajdoc"/>
  178. todo bug ajdoc taskdef not handling any includes or nested src or
  179. includes argument
  180. -->
  181. <!-- todo: version bootclasspath, extdirs
  182. Xporting="on" # todo: after Jim updates compiler for Xporting
  183. todo: nested src n/a
  184. -->
  185. </target>
  186. <target name="test.ajc" depends="test.ajc1"/> <!-- ,test.ajc2 -->
  187. <target name="test.ajc1" depends="init,init.taskdefs,clear.test.dir"
  188. description="run variants of ajc taskdef on bean, other examples">
  189. <echo message="## setup expected working dir, classes dir, and output file" />
  190. <antcall target="cleanajc"/>
  191. <ajc srcdir="${ex.dir}/bean" classpath="${aspectjrt.jar}"
  192. destDir="${expected.classes.dir}"
  193. usejavac="yes"
  194. workingdir="${expected.working.dir}"/>
  195. <java classname="bean.Demo"
  196. classpath="${expected.classes.dir}${PS}${aspectjrt.jar}"
  197. dir="${ex.dir}" fork="yes"
  198. output="${expect.file}"/>
  199. <echo message="## @testcase ajc simple srcdir example" />
  200. <antcall target="cleanajc"/>
  201. <ajc srcdir="${ex.dir}/bean" classpath="${aspectjrt.jar}" />
  202. <!-- todo: fix b/c returning 1 as result -->
  203. <echo message="## simple.run.classpath: ${simple.run.classpath} - getting fail" />
  204. <java classname="bean.Demo"
  205. classpath="${simple.run.classpath}"
  206. dir="${ex.dir}" fork="yes"
  207. output="${actual.file}"/>
  208. <antcall target="cleanajc"/>
  209. <echo message="## @testcase ajc srcdir with include arg and (unverified) -source 1.4 and -XaddSafePrefix${knownFail}" />
  210. <ajc srcdir="${ex.dir}/bean" classpath="${aspectjrt.jar}" includes="*.java"/>
  211. <java classname="bean.Demo"
  212. classpath="${simple.run.classpath}"
  213. dir="${ex.dir}" fork="yes"
  214. output="${actual.file}"/>
  215. <antcall target="verifyAndCleanup.noworkingdir.noclassesdir"/>
  216. <echo message="## @testcase ajc srcdir with include argument${knownFail}" />
  217. <ajc srcdir="${ex.dir}/bean" classpath="${aspectjrt.jar}" includes="*.java"/>
  218. <java classname="bean.Demo"
  219. classpath="${simple.run.classpath}"
  220. dir="${ex.dir}" fork="yes"
  221. output="${actual.file}"/>
  222. <antcall target="verifyAndCleanup.noworkingdir.noclassesdir"/>
  223. <echo message="## @testcase ajc srcdir with destDir and working workingdir argument" />
  224. <ajc srcdir="${ex.dir}/bean" classpath="${aspectjrt.jar}"
  225. destDir="${classes.dir}"
  226. usejavac="yes"
  227. workingdir="${working.dir}"/>
  228. <java classname="bean.Demo"
  229. classpath="${run.classpath}"
  230. dir="${ex.dir}" fork="yes"
  231. output="${actual.file}"/>
  232. <antcall target="verifyAndCleanup.workingdir.classesdir"/>
  233. <echo message="## @testcase ajc simple srcdir with nested include and nested classpath${knownFail}" />
  234. <ajc srcdir="${ex.dir}/bean">
  235. <include name="**.java"/>
  236. <classpath> <pathelement path="${aspectjrt.jar}"/> </classpath>
  237. </ajc>
  238. <java classname="bean.Demo"
  239. classpath="${simple.run.classpath}"
  240. dir="${ex.dir}" fork="yes"
  241. output="${actual.file}"/>
  242. <antcall target="verifyAndCleanup.noworkingdir.noclassesdir"/>
  243. <echo message="## @testcase ajc nested src with kitchen sink" />
  244. <antcall target="cleanajc"/>
  245. <ajc
  246. destDir="${classes.dir}"
  247. workingdir="${working.dir}"
  248. usejavac="on"
  249. preprocess="no"
  250. verbose="on"
  251. deprecation="on"
  252. optimize="on"
  253. encoding="encodingIgnored"
  254. target="targetIgnored"
  255. depend="dependIgnored"
  256. includeantruntime="includeantruntimeIgnored"
  257. includejavaruntime="includejavaruntimeIgnored"
  258. failonerror="on"
  259. nocomments="on"
  260. nosymbols="on"
  261. emacssym="on"
  262. strict="on"
  263. >
  264. <src path="${ex.dir}/bean"/>
  265. <include name="**.java"/>
  266. <classpath> <pathelement path="${aspectjrt.jar}"/> </classpath>
  267. </ajc>
  268. <java classname="bean.Demo"
  269. classpath="${run.classpath}"
  270. dir="${ex.dir}" fork="yes"
  271. output="${actual.file}"/>
  272. <antcall target="verifyAndCleanup.workingdir.classesdir"/>
  273. <echo message="## @testcase ajc srcdir in preprocess mode" />
  274. <ajc srcdir="${ex.dir}/bean" classpath="${aspectjrt.jar}"
  275. lenient="on"
  276. workingdir="${working.dir}" usejavac="on" preprocess="yes"/>
  277. <antcall target="verifyAndCleanup.workingdir.noclassesdir.nooutput"/>
  278. <echo message="## @testcase ajc argfile in preprocess mode" />
  279. <ajc argfile="${ex.dir}/bean/files.lst" classpath="${aspectjrt.jar}"
  280. workingdir="${working.dir}" usejavac="on" preprocess="yes"/>
  281. <antcall target="verifyAndCleanup.workingdir.noclassesdir.nooutput"/>
  282. <echo message="## @testcase ajc argfile in normal mode" />
  283. <ajc argfile="${ex.dir}/bean/files.lst" classpath="${aspectjrt.jar}"
  284. destdir="${classes.dir}" usejavac="off" preprocess="no" verbose="yes"/>
  285. <java classname="bean.Demo"
  286. classpath="${run.classpath}"
  287. dir="${ex.dir}" fork="yes"
  288. output="${actual.file}"/>
  289. <antcall target="verifyAndCleanup.noworkingdir.classesdir"/>
  290. <echo message="## @testcase ajc multiple argfile todo restore" />
  291. <ajc argfiles="${ex.dir}/bean/files.lst,${ex.dir}/introduction/files.lst"
  292. classpath="${aspectjrt.jar}" destdir="${classes.dir}" >
  293. </ajc>
  294. <java classname="bean.Demo"
  295. classpath="${run.classpath}"
  296. dir="${ex.dir}" fork="yes"
  297. output="${actual.file}"/>
  298. <copy todir="${expected.classes.dir}" >
  299. <fileset dir="${classes.dir}" includes="**.class" />
  300. </copy>
  301. <antcall target="cleanajc"/> <!-- too many classes -->
  302. </target>
  303. <target name="test.ajc2" depends="init,init.taskdefs"
  304. description="run variants of ajc taskdef on bean, other examples">
  305. <!-- failing here -->
  306. <echo message="## @testcase ajc Vincent Massol bug" />
  307. <ajc classpath="${aspectjrt.jar}" fork="yes"
  308. workingdir="${working.dir}" > <!-- preprocess="yes" -->
  309. <src path="${ex.dir}/bean"/>
  310. <src path="${ex.dir}/introduction"/>
  311. <include name="*.java"/>
  312. <include name="**.java"/>
  313. </ajc>
  314. <antcall target="verifyAndCleanup.workingdir.noclassesdir.nooutput"/>
  315. <echo message="## @testcase ajc warning when no source files specified but have srcdir # " />
  316. <ajc srcdir="${ex.dir}/bean" classpath="${aspectjrt.jar}" />
  317. <antcall target="cleanajc"/>
  318. <!-- @testcase ajc -preprocess javac is failing todo -->
  319. <echo message="## @testcase ajc -preprocess srcdir no destDir, post-javac compile (-preprocess ignored) # " />
  320. <ajc srcdir="${ex.dir}/bean" includes="**.java" classpath="${aspectjrt.jar}"
  321. usejavac="no" preprocess="yes" workingdir="${working.dir}"/>
  322. <echo message="## @testcase ajc -preprocess list ${working.dir}" />
  323. <comparefiles lhsFile="${empty.dir}" rhsFile="${working.dir}"/>
  324. <echo message="## @testcase ajc -preprocess before comparefiles ${working.dir}" />
  325. <comparefiles lhsFile="${expected.working.dir}" rhsFile="${working.dir}"/>
  326. <echo message="## @testcase ajc -preprocess before delete classes.dir" />
  327. <mkdir dir="${classes.dir}"/>
  328. <delete quiet="on" dir="${classes.dir}"/>
  329. <mkdir dir="${classes.dir}"/>
  330. <mkdir dir="${classes.dir}"/>
  331. <echo message="## @testcase ajc -preprocess doing javac" />
  332. <!-- todo: unable to invoke javac though .java files in working.dir -never invoked?? -->
  333. <javac srcdir="${working.dir}" includes="**.java"
  334. destdir="${classes.dir}" verbose="on"
  335. classpath="${aspectjrt.jar}" />
  336. <echo message="## @testcase ajc -preprocess after javac, list classes" />
  337. <comparefiles lhsFile="${empty.dir}" rhsFile="${classes.dir}"/>
  338. <echo message="## @testcase ajc -preprocess after javac, compare classes" />
  339. <comparefiles lhsFile="${expected.classes.dir}" rhsFile="${classes.dir}"/>
  340. <echo message="## @testcase ajc -preprocess after javac, run classes" />
  341. <java classname="bean.Demo"
  342. classpath="${run.classpath}"
  343. dir="${ex.dir}" fork="yes"
  344. output="${actual.file}"/>
  345. <antcall target="verifyAndCleanup.workingdir.classesdir"/>
  346. <!-- todo: version bootclasspath, extdirs
  347. Xporting="on" # todo: after Jim updates compiler for Xporting
  348. -->
  349. </target>
  350. <target name="verifyAndCleanup.ajdoc" depends="verifyAndCleanup.noworkingdir.classesdir.nooutput" />
  351. <target name="verifyAndCleanup.noworkingdir.noclassesdir">
  352. <antcall target="expectfile"/>
  353. <antcall target="noworkingdir"/>
  354. <antcall target="noclassesdir"/>
  355. <antcall target="cleanajc"/>
  356. </target>
  357. <target name="verifyAndCleanup.workingdir.noclassesdir">
  358. <antcall target="expectfile"/>
  359. <antcall target="workingdir"/>
  360. <antcall target="noclassesdir"/>
  361. <antcall target="cleanajc"/>
  362. </target>
  363. <target name="verifyAndCleanup.workingdir.noclassesdir.nooutput">
  364. <antcall target="workingdir"/>
  365. <antcall target="noclassesdir"/>
  366. <antcall target="cleanajc"/>
  367. </target>
  368. <target name="verifyAndCleanup.noworkingdir.classesdir.nooutput">
  369. <antcall target="noworkingdir"/>
  370. <antcall target="classesdir"/>
  371. <antcall target="cleanajc"/>
  372. </target>
  373. <target name="verifyAndCleanup.noworkingdir.classesdir" >
  374. <antcall target="noworkingdir"/>
  375. <antcall target="classesdir"/>
  376. <antcall target="expectfile"/>
  377. <antcall target="cleanajc"/>
  378. </target>
  379. <target name="verifyAndCleanup.workingdir.classesdir">
  380. <antcall target="expectfile"/>
  381. <antcall target="workingdir"/>
  382. <antcall target="classesdir"/>
  383. <antcall target="cleanajc"/>
  384. </target>
  385. <target name="expectfile" depends="init">
  386. <comparefiles lhsFile="${expect.file}" rhsFile="${actual.file}"/>
  387. <delete quiet="on" file="${actual.file}"/>
  388. </target>
  389. <target name="noworkingdir" depends="init">
  390. <comparefiles lhsFile="${empty.dir}" rhsFile="${working.dir}"/>
  391. </target>
  392. <target name="workingdir" depends="init">
  393. <comparefiles lhsFile="${expected.working.dir}" rhsFile="${working.dir}"/>
  394. </target>
  395. <target name="noclassesdir" depends="init">
  396. <comparefiles lhsFile="${empty.dir}" rhsFile="${classes.dir}"/>
  397. </target>
  398. <target name="classesdir" depends="init">
  399. <comparefiles lhsFile="${expected.classes.dir}" rhsFile="${classes.dir}"/>
  400. </target>
  401. <target name="cleanajc" depends="init">
  402. <mkdir dir="${classes.dir}"/>
  403. <delete quiet="on" dir="${classes.dir}"/>
  404. <mkdir dir="${classes.dir}"/>
  405. <mkdir dir="${working.dir}"/>
  406. <delete quiet="on" dir="${working.dir}"/>
  407. <mkdir dir="${working.dir}"/>
  408. <delete quiet="on" >
  409. <fileset dir="${product.examples.dir}" includes="**.class,**.ajesym"/>
  410. </delete>
  411. </target>
  412. </project>