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.

readme-writing-compiler-tests.html 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <html>
  2. <!-- <![CDATA[ putDataHere ]]> -->
  3. <head>
  4. <title>Writing tests for the AspectJ compiler
  5. </title>
  6. </head>
  7. <body>
  8. <h2>Writing tests for the AspectJ compiler
  9. </h2>
  10. The AspectJ project has a harness
  11. which reads test specification files and run tests.
  12. The tests are usually simple scenarios like
  13. "compile and run" or "compile expecting error",
  14. but may involve multiple files, incremental compilation,
  15. classpath or aspectpath entries, etc.
  16. This document shows how to write tests that can be run
  17. by the harness and suggests some patterns to use in
  18. test code, discussing
  19. <ul>
  20. <li><a href="#simple">Simple test definitions</a></li>
  21. <li><a href="#sourceFiles">Test source files</a></li>
  22. <li><a href="#incremental">Incremental tests</a></li>
  23. <li><a href="#verifying">Verifying test steps</a>
  24. <ul>
  25. <li><a href="#messages">Messages</a></li>
  26. <li><a href="#dirchanges">Changes in an output directory</a></li>
  27. <li><a href="#tester">Testing runtime behavior</a></li>
  28. </ul></li>
  29. <li><a href="#forking">Forking at runtime</a></li>
  30. <li><a href="#compilerOptions">Compiler Options</a></li>
  31. <li><a href="#background">Harness background</a></li>
  32. </ul>
  33. Most people just writing a test case need to know only the
  34. information in
  35. <a href="#simple">Simple test definitions</a> and
  36. <a href="#sourceFiles">Test source files</a>.
  37. <p>Related documents:</p>
  38. <ul>
  39. <li>For information on running the harness, see
  40. <a href="readme-tests-module.html">
  41. readme-tests-module.html</a>
  42. </li>
  43. <li>For example test definition files, see
  44. <a href="ajcTests.xml">ajcTests.xml</a> and
  45. <a href="ajcTestsFailing.xml">ajcTestsFailing.xml</a>.
  46. </li>
  47. </ul>
  48. <a name="simple"></a>
  49. <h4>Simple Test definitions</h4>
  50. Test definitions are specified in XML files.
  51. Here is a simple example to compile <code>Main.java</code>
  52. and expect an error on line 10 in a file <code>ajcSample.xml</code>:
  53. <pre>
  54. &lt;!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd">
  55. &lt;suite>
  56. &lt;ajc-test dir="new" title="simple error test">
  57. &lt;compile files="Main.java">
  58. &lt;message kind="error" line="10"/>
  59. &lt;/compile>
  60. &lt;/ajc-test>
  61. &lt;/suite>
  62. </pre>
  63. <p>Here is an example to compile
  64. <code>pack/Aspect.java</code> and
  65. <code>pack2/Main.java</code> and
  66. run the main class:
  67. </p>
  68. <pre>
  69. &lt;ajc-test dir="new" title="simple run test">
  70. &lt;compile files="pack/Aspect.java,pack1/Main.java"/>
  71. &lt;run class="pack1.Main"/>
  72. &lt;/ajc-test>
  73. </pre>
  74. The compile and run steps of a given ajc-test share a common
  75. sandbox, so (e.g.,) the run step knows to set its classpath using
  76. the classes directory generated by the compile step.
  77. <p>More complex compilations are discussed in
  78. <a href="#compilerOptions">Compiler Options</a> below.
  79. </p>
  80. <a name="sourceFiles"></a>
  81. <h4>Test source files</h4>
  82. The <code>dir</code> attribute in the <code>ajc-test</code>
  83. element specifies a base test directory
  84. relative to the directory of the test specification file.
  85. All paths are specified relative to this base test directory.
  86. E.g., the last example used <code>dir="new"</code> and
  87. presumed the following directory structure:
  88. <pre>
  89. {some dir} # test specification directory
  90. {testDefinition}.xml
  91. new/ # test base directory
  92. pack/Aspect.java
  93. pack2/Main.java
  94. </pre>
  95. Test cases with only one file in the default package can often
  96. share directories (e.g., see the many files in <a href="new">new/</a>),
  97. but usually a test case has its own directory.
  98. <a name="incremental"></a>
  99. <h4>Incremental tests</h4>
  100. Incremental tests are more complex because they involve
  101. updating source files before recompiling.
  102. Here's an example that
  103. <ul>
  104. <li>compiles Main.java,
  105. </li><li>runs it,
  106. </li><li>updates the source to introduce an error,
  107. </li><li>incrementally compile it (and detect the error)
  108. </li><li>updates the source to fix the error,
  109. </li><li>incrementally compile it (successfully), and
  110. </li><li>runs it again.
  111. </li>
  112. </ul>
  113. <pre>
  114. &lt;ajc-test dir="new/incremental1" title="incremental test">
  115. &lt;compile staging="true"
  116. sourceroots="."
  117. options="-incremental" />
  118. &lt;run class="Main"/>
  119. &lt;inc-compile tag="20">
  120. &lt;message kind="error" line="15">
  121. &lt;/inc-compile>
  122. &lt;inc-compile tag="30"/>
  123. &lt;run class="Main"/>
  124. &lt;/ajc-test>
  125. </pre>
  126. To understand what's happening in this test would require
  127. looking at the source directory to see which files are tagged
  128. "20" and "30". But before walking through that, there's a
  129. variation of incremental building for AJDE. (The AJDE wrapper
  130. around the <code>ajc</code> compiler can also be driven by the
  131. test harness.)
  132. <p>
  133. In AJDE, incremental tests also involve the notion of "fresh builds",
  134. i.e., when the test reuses the same compiler and build configuration
  135. but rebuilds from scratch. In that case, there is still the
  136. question of whether source files should be updated; if not,
  137. the tag can have the special value "same". For example, if
  138. the last example had two more lines:
  139. </p>
  140. <pre>
  141. ...
  142. &lt;inc-compile tag="30"/>
  143. &lt;run class="Main"/>
  144. &lt;inc-compile fresh="true" tag="same"/>
  145. &lt;run class="Main"/>
  146. &lt;/ajc-test>
  147. </pre>
  148. The test would complete by completely rebuilding the same files
  149. and then running the main class. This option has no effect on
  150. the normal (ajc) compiler, and requires specifying
  151. <code>-ajdeCompiler</code> to the harness or compile step
  152. as an argument.
  153. <p/>
  154. To recap the attributes of note for setting up incremental tests:
  155. <ul>
  156. <li><code>compile</code> <code>staging="true"</code>:
  157. Incremental tests require staging, which copies the
  158. test source files to a temporary directory so they can be
  159. updated during the test without changing the actual sources.
  160. </li>
  161. <li><code>compile</code> <code>sourceroots="{..}"</code>:
  162. incremental mode only takes source files in the form of
  163. <code>-sourceroots</code> entries.
  164. </li>
  165. <li><code>compile</code> <code>options="-incremental{,..}"</code>:
  166. Specify the <code>-incremental</code> option to signal
  167. incremental mode to the compiler. If you do not include this,
  168. the harness will still run an incremental test, but the compiler
  169. will not do its additional checking it on input options.
  170. </li>
  171. <li><code>inc-compile</code> <code>tag="{##}"</code>:
  172. The required tag attribute is a suffix identifying
  173. files in the test source directory specifying how the sources should
  174. be changed before that incremental compilation step.
  175. If there is a prefixing suffix "delete", then the file is deleted;
  176. otherwise, the file is copied (with the effect either of updating
  177. an existing file or adding a new file).
  178. If the tag is "same", then no files are changed.
  179. </li>
  180. <li><code>inc-compile</code> <code>fresh="true"</code>:
  181. With the AJDE compiler, you can rebuild the current build
  182. configuration in its entirety. (By contrast, doing another
  183. &lt;compile> task would re-initialize the AJDE compiler.)
  184. This option is ignored unless <code>-ajdeCompiler</code>
  185. is passed to the harness on the command line or to the
  186. immediately preceding &lt;compile> task in the options.
  187. </li>
  188. </ul>
  189. <p/>
  190. Now, to get back to the question of
  191. what exactly is happening in an incremental test. To do so,
  192. compare the tags with the files specified in
  193. the test source directory; the tagged files are the updates
  194. for that particular step. (By convention the tags are numeric
  195. and in order, but they need not be.)
  196. For example, here are some sources for the test above:
  197. <pre>
  198. {some dir}
  199. {testDefinition}.xml
  200. new/
  201. incremental1/
  202. DeleteMe.delete.30.java
  203. DeleteMe.java
  204. Main.20.java
  205. Main.30.java
  206. Main.java
  207. NewFile.30.java
  208. </pre>
  209. Comparing this with the test specification, you can see
  210. the harness will run one compile and two re-compiles:
  211. <ol>
  212. <li>Initially compile <code>Main.java</code> and <code>DeleteMe.java</code>
  213. <pre>
  214. &lt;compile staging="true"
  215. files="Main.java,DeleteMe.java"/>
  216. {some dir}
  217. {testDefinition}.xml
  218. new/
  219. incremental1/
  220. ...
  221. DeleteMe.java
  222. ...
  223. Main.java
  224. ...
  225. </pre>
  226. </li>
  227. <li>For incremental tag 20,
  228. update <code>Main.java</code> with the contents of
  229. <code>Main.20.java</code>
  230. and recompile, expecting an error on line 15:
  231. <pre>
  232. &lt;inc-compile tag="20">
  233. &lt;message kind="error" line="15">
  234. &lt;/inc-compile>
  235. {some dir}
  236. {testDefinition}.xml
  237. new/
  238. incremental1/
  239. ...
  240. Main.20.java
  241. ...
  242. </pre></li>
  243. <li>For incremental tag 30,
  244. delete <code>DeleteMe.java</code>,
  245. add <code>NewFile.java</code>,
  246. update <code>Main.java</code> with the contents of
  247. <code>Main.30.java</code>
  248. and recompile with no error or warning messages:
  249. <pre>
  250. &lt;inc-compile tag="30"/>
  251. {some dir}
  252. {testDefinition}.xml
  253. new/
  254. incremental1/
  255. DeleteMe.delete.30.java
  256. ...
  257. Main.30.java
  258. ...
  259. NewFile.30.java
  260. </pre>
  261. </li>
  262. </ol>
  263. <a name="verifying"></a>
  264. <h4>Verifying test steps</h4>
  265. As seen above, two ways to verify that a compile was successful
  266. are to run the corresponding class or check the compiler messages.
  267. More generally, the harness can verify compile/run test steps by detecting the
  268. following things and comparing against expected behavior:
  269. <p/>
  270. <table border="1" cellpadding="1">
  271. <tr><th>Detect </th>
  272. <th>Evaluate</th>
  273. </tr>
  274. <tr><td>Exceptions </td>
  275. <td>signal failure </td>
  276. </tr>
  277. <tr><td>Result value </td>
  278. <td>heuristically compare with expected:
  279. compiles not expecting errors are expected
  280. to return a normal result status, and vice-versa.</td>
  281. </tr>
  282. <tr><td>Messages (e.g., compiler warnings and errors)</td>
  283. <td>Compare with expected messages</td>
  284. </tr>
  285. <tr><td>Directory changes (e.g., <code>.class</code> files created) </td>
  286. <td>Compare with expected changes</td>
  287. </tr>
  288. <tr><td>Runtime behavior</td>
  289. <td>Use <code>Tester</code> in test source code
  290. to signal events for comparison with expected events.
  291. To signal failure when running a forked test without Tester,
  292. throw an exception.</td>
  293. </tr>
  294. </table>
  295. <p/>
  296. <a name="messages"></a>
  297. <h5>Messages</h5>
  298. In a test definition, a nested <code>message</code> element
  299. specifies a condition on the successful completion of the nesting
  300. ajc-test sub-element. In the earlier example, if
  301. the harness does not detect an error message on line 10 or if
  302. there are unexpected messages, then the compile step will be
  303. reported as failing:
  304. <pre>
  305. &lt;ajc-test dir="new" title="simple error test">
  306. &lt;compile files="Main.java">
  307. &lt;message kind="error" line="10"/>
  308. &lt;/compile>
  309. &lt;/ajc-test>
  310. </pre>
  311. Expected messages can be specified as sub-elements for the three
  312. <code>ajc-test</code> elements
  313. <code>compile</code>,
  314. <code>inc-compile</code>, and
  315. <code>run</code>.
  316. Messages require a kind (error or warning) and a line.
  317. To make specification easier, if an error is specified for a line,
  318. the harness accepts as expected any number of errors on that line.
  319. <p>
  320. Most messages fall into those categories.
  321. However, an IMessage also has a Throwable thrown, a String detail,
  322. and a List of ISourceLocation (essentially, "see also", to point
  323. to other relevant places in the code). The thrown element is not
  324. supported, but you can specify the others:
  325. </p>
  326. <pre>
  327. &lt;ajc-test dir="new" title="simple error test">
  328. &lt;compile files="Main.java">
  329. &lt;message
  330. kind="error"
  331. line="10"
  332. file="Main.java"
  333. text="This join point should never happen!"
  334. detail="(Find the declaring code below.)">
  335. &lt;source line="12" file="Main.java"/>
  336. &lt;source line="14" file="Main.java"/>
  337. &lt;message>
  338. &lt;/compile>
  339. &lt;/ajc-test>
  340. </pre>
  341. This compiler-error test specifies a single error message triggered
  342. on line 10 of Main.java, with some text and details and two other
  343. source locations that are relevant, on lines 12 and 14 of the same
  344. file.
  345. <p>
  346. When specifying messages, be sure to provide enough detail that
  347. the harness can distinguish expected messages. For example, if you
  348. only specify the line number, then it will match the message in
  349. any file (if there is more than one). If there are two or more
  350. messages expected on a line, provide enough information
  351. to distinguish them. If you are using text or detail attributes,
  352. do not use one string that is a prefix of the other, since it
  353. will match either message, and the other message might not match.
  354. </p>
  355. <p>
  356. The "info" messages are special in that they are normally ignored.
  357. To specify expected "info" messages, you have to list all the
  358. messages the compiler will issue, which can vary depending on
  359. the compiler settings. Use the option <code>^verbose</code> to
  360. force the compiler's <code>-verbose</code> option off.
  361. </p>
  362. <p>
  363. By the same token, if you don't specify any extra source locations,
  364. then they will not be checked. If you think it is a bug if they
  365. are issued, then you have to specify one if them. (There is
  366. currently no way to specify that a message has no extra
  367. source locations.)
  368. </p>
  369. <a name="dirchanges"></a>
  370. <h5>Changes in an output directory</h5>
  371. As with messages, specifying directory changes as a nested element
  372. operates as a condition on the successful completion of the
  373. nesting element. The harness will check for files added, removed,
  374. updated, or unchanged from a given directory. The directory is
  375. specified explicitly or using a token for the shared classes or
  376. run directory. For even more brevity, the harness supports a
  377. default suffix for the files.
  378. <p>
  379. Directory changes have been used only to validate changes in
  380. the classes directory.
  381. The current harness defaults to using the classes directory,
  382. and when using the classes directory uses <code>.class</code>
  383. as a default suffix.
  384. </p>
  385. <p>
  386. Here's an example specification:
  387. </p>
  388. <pre>
  389. &lt;ajc-test dir="new/dirchanges-test" title="dir-changes test">
  390. &lt;compile staging="true"
  391. files="Main.java,DeleteMe.java,Unchanged.java"/>
  392. &lt;inc-compile tag="20">
  393. &lt;dir-changes updated="Main"
  394. removed="DeleteMe"
  395. unchanged="Unchanged"/>
  396. &lt;/inc-compile>
  397. &lt;/ajc-test>
  398. </pre>
  399. It checks after a recompile that
  400. <ul>
  401. <li><code>Main.class</code> was updated</li>
  402. <li><code>DeleteMe.class</code> was deleted</li>
  403. <li><code>Unchanged.class</code> was not touched</li>
  404. </ul>
  405. <a name="tester"></a>
  406. <h5>Runtime behavior</h5>
  407. Code that tests aspects often falls into the pattern of comparing
  408. expected and actual events/signals. For example, to prove that
  409. before advice in fact ran before a particular method execution,
  410. you might generated and expect signals corresponding to
  411. <ol>
  412. <li>method-call</li>
  413. <li>before advice execution</li>
  414. <li>method-execution</li>
  415. </ol>
  416. The <code>Tester</code> utility class provides API's for signalling
  417. actual and expecting events and comparing the two.
  418. Typically, events are symbolized and compared as String.
  419. Here's a small sample test case that for the scenario above:
  420. <pre>
  421. import org.aspectj.testing.Tester;
  422. public class Main implements Runnable {
  423. public static void main(String[] args) {
  424. Tester.expectEvent("before advice");
  425. Tester.expectEvent("execute run");
  426. new Main().run();
  427. Tester.checkAllEvents();
  428. }
  429. public void run() {
  430. Tester.event("execute run");
  431. }
  432. }
  433. aspect A {
  434. before () : target(Runnable) &amp;&amp; execution(void run()) {
  435. Tester.event("before advice");
  436. }
  437. }
  438. </pre>
  439. If either the advice or the method does not run,
  440. the harness will report a failure.
  441. <p>
  442. <code>Tester</code> also has methods that operate like
  443. JUnit assertions as idioms to detect differences in
  444. expected and actual values, signalling appropriately.
  445. </p>
  446. <code>Tester</code> is at
  447. <a href="../testing-client/src/org/aspectj/testing/Tester.java">
  448. ../testing-client/src/org/aspectj/testing/Tester.java</a>
  449. and is built into
  450. <a href="../lib/tests/testing-client.jar">
  451. ../lib/tests/testing-client.jar</a>
  452. which is included on the classpath by the compile and run steps.
  453. <p>You can write runtime test cases without using Tester;
  454. simply throw some exception from the main thread to signal failure.
  455. </p>
  456. <a name="forking"></a>
  457. <h4>Forking and load-time weaving</h4>
  458. <p>You can fork the tests that are run by setting global properties
  459. or by setting attributes to run. One attribute,
  460. <code>aspectpath</code>, forces the run to fork and uses
  461. load-time weaving to weave aspects with the classpath.
  462. </p>
  463. <p>To fork for all tests, set the global system property
  464. <code>javarun.fork</code> to "true". You can also
  465. set other properties to control how forking happens.
  466. (By default, forking uses the java executable that was
  467. used to run the harness.)
  468. The following causes all <code>run</code> steps to
  469. fork into the specified Java 1.1 VM.
  470. </p>
  471. <pre>
  472. java -Djavarun.fork=true \
  473. -Djavarun.java=c:/home/jdk11/bin/java.exe \
  474. -Djavarun.java.home=c:/home/jdk11 \
  475. -Djavarun.bootclasspath=c:/home/jdk11/lib/classes.zip \
  476. -Djavarun.vmargs=-Dname=value,-Dname2="value 2" \
  477. org.aspectj.testing.drivers.Harness ...
  478. </pre>
  479. <p>You can fork a specific test by setting
  480. the <code>fork</code> attribute (and optionally the
  481. <code>vmargs</code> attribute):
  482. </p>
  483. <pre>
  484. &lt;ajc-test dir="new" title="show forking">
  485. &lt;compile files="Main.java"/>
  486. &lt;run class="Main" fork="true"
  487. vmargs="-Dname=value,-Dname2="value 2"/>
  488. &lt;/ajc-test>
  489. </pre>
  490. <p>As a special case of forking, load-time weaving sets up
  491. a Java 1.4 or later VM using our weaving class loader,
  492. if you specify the <code>ltw</code> attribute to
  493. <code>run</code>.
  494. In the following example, the main class and the aspect
  495. are compiled separately. The main class is then woven
  496. and run using the aop.xml file specified in the <code>ltw</code> attribute.</p>
  497. <pre>
  498. &lt;ajc-test dir="new" title="show LTW">
  499. &lt;compile files="Aspect.java" outjar="out.jar"/>
  500. &lt;compile files="Main.java"/>
  501. &lt;run class="Main" ltw="aop-test.xml"/>
  502. &lt;/ajc-test>
  503. </pre>
  504. <a name="compilerOptions"></a>
  505. <h4>Compiler options</h4>
  506. The harness does not support all of the AspectJ 1.1 compiler options.
  507. Flags are mainly supported through the a comma-delimited list in
  508. the <code>options</code> attribute:
  509. <pre>
  510. &lt;ajc-test dir="new" title="lint test">
  511. &lt;compile files="LintTest.java"
  512. options="-Xlint,-emacssym,-source,1.4">
  513. &lt;message kind="warning" line="22">
  514. &lt;/compile>
  515. </pre>
  516. This should work even for complex single-arg options like
  517. <code>-g:none</code>, but will fail for comma-delimited single-arg options like
  518. <code>-g:lines,vars</code> because the comma delimiters
  519. are ambiguous (yes, a design bug!).
  520. <p/>
  521. The <code>compile</code> element has the following attributes
  522. which handle most of the other compiler arguments:
  523. <ul>
  524. <li><code>files</code>: .aj and .java files are treated as source files,
  525. but .jar/zip files are extracted and passed to the compiler
  526. as <code>-injars</code>
  527. and readable directories are passed as <code>-inpath</code>.
  528. </li><li><code>classpath</code>: directories and jar files for the classpath
  529. </li><li><code>aspectpath</code>: binary aspects in jar files
  530. </li><li><code>argfiles</code>: argument list files
  531. </li><li><code>sourceroots</code>: root directories for source files
  532. </li><li><code>xlintfile</code>: override org.aspectj.weaver.XlintDefault.properties
  533. </li>
  534. </ul>
  535. Paths for these are all relative to the test base directory, and
  536. multiple entries are separated with commas.
  537. (Use only one entry for xlintfile.)
  538. <p/>
  539. Here is a cooked example that uses all <code>compiler</code> attributes:
  540. <pre>
  541. &lt;ajc-test dir="new" title="attributes test">
  542. &lt;compile files="Main.java,injar.jar,some-directory"
  543. staging="true"
  544. options="-Xlint,-g:none"
  545. argfiles="debug.lst,aspects/test.lst"
  546. aspectpath="jars/requiredAspects.jar"
  547. xlintfile="ignore-all-but-typenotfound.properties"
  548. classpath="providedClassesDir,jars/required.jar"/>
  549. &lt;inc-compile tag="20"/>
  550. &lt;/ajc-test>
  551. </pre>
  552. <h5>Test-only compiler attributes</h5>
  553. The following attributes of the compiler entity dictate harness behavior:
  554. <ul>
  555. <li><u>badInput</u>:
  556. To test invalid input, set the compiler <code>badInput</code> attribute
  557. to "<code>true</code>". This prevents the harness from aborting a test
  558. because a specified input file was not found. (However, there is no way
  559. to specify bad input for a directory in the files attribute intended for
  560. -inpath, because the harness selects readable directories.)
  561. </li>
  562. <li><u>includeClassesDir</u>:
  563. Set this in order to include the output classes directory explicitly
  564. on the classpath.
  565. </li>
  566. <li><u>reuseCompiler</u>:
  567. Set this to re-use a compiler from a previous compiler run.
  568. (This tests statefulness of a compiler across non-incremental runs.)
  569. </li>
  570. </ul>
  571. <h5>Unsupported compiler options</h5>
  572. The harness does not support the following AspectJ compiler
  573. options: <code>-outjar {file}, -log {file}</code>.
  574. (<code>-d {dir}</code> is used but specification is not supported.)
  575. <a name="background"></a>
  576. <h4>Background information on the Harness</h4>
  577. To make the test specifications as terse as possible,
  578. harness components for
  579. <code>inc-compile</code> and <code>run</code> elements
  580. use information set up earlier by <code>compile</code>,
  581. some of which is only implicit.
  582. When a test is run, the harness creates a staging directory
  583. for temporary files and a sandbox component for sharing information
  584. between test components, particularly classpath entries
  585. shared between the compile and run components.
  586. The compile and run components share classpath information
  587. through the sandbox, adding default libraries:
  588. <ul>
  589. <li>Aside from any explicit classpath entries,
  590. <code>compile</code> always includes the jars
  591. <a href="../lib/tests/aspecjrt.jar">
  592. ../lib/tests/aspecjrt.jar</a> and
  593. <a href="../lib/tests/testing-client.jar">
  594. ../lib/tests/testing-client.jar</a>
  595. on the compile classpath.
  596. </li>
  597. <li><code>run</code> sets up its classpath as the compile
  598. classpath plus the compile output (classes) directory
  599. plus any entries on the aspectpath.
  600. </li>
  601. </ul>
  602. The harness provides some more advance behaviors,
  603. which you might see specified in the tests.
  604. For more information, see the API documentation for the harness
  605. (<a href="../testing-drivers/src/org/aspectj/testing/drivers/package.html">
  606. org/aspectj/testing/drivers/package.html</a>).
  607. <ul>
  608. <li><u>option dominance and overriding</u>:
  609. Both in test specifications and on the command line
  610. you can force compiler options on or off.
  611. (Forcing means that, e.g., even if an option is enabled in the
  612. test specification, it can be disabled from the command line.)
  613. These appear in the test specifications as options
  614. with prefixes
  615. '!' or '^' rather than '-' (e.g., '^emacssym' to force
  616. the emacssym option off, even in tests that specify it).
  617. </li>
  618. </ul>
  619. <hr/>
  620. <small>last updated June 30, 2006 </small> <!-- CVS variable -->
  621. </body>
  622. </html>