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.

package.html 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <html>
  2. <head><title>Harness Package Documentation</title></head>
  3. <body>
  4. <p>
  5. The AspectJ compiler test harness can compile and run AspectJ programs
  6. as specified by the test definitions.
  7. This document tells you how to run the harness.
  8. It describes the options you can specify on the command-line to
  9. control various components that form the harness, either to
  10. specify options that augment the test definitions or to
  11. change how the harness works, e.g., selecting particular tests
  12. or logging more information.
  13. For information on how to write a test definition, see
  14. <code>readme-writing-compiler-tests.html</code> in the testing module.
  15. </p>
  16. <p>
  17. The harness drives compiler tests, using
  18. a chain of responsibility to map elements
  19. in the schema of a test definition to implementing classes.
  20. </p>
  21. <table border="1" cellpadding="1">
  22. <tr><th align="left">Test feature</th>
  23. <th align="left">Description</th>
  24. <th align="left">Implementing class</th>
  25. </tr>
  26. <tr><td>(loading suites...)</td>
  27. <td>general harness</td>
  28. <td>Harness</td>
  29. </tr>
  30. <tr><td>(logging...)</td>
  31. <td>subclass feature harness</td>
  32. <td>FeatureHarness</td>
  33. </tr>
  34. <tr><td><code>&lt;suite&gt;</code></td>
  35. <td>Test suite</td>
  36. <td>AjcTest.Suite</td>
  37. </tr>
  38. <tr><td>&nbsp;&nbsp;<code>&lt;ajc-test&gt;</code></td>
  39. <td>Test case</td>
  40. <td>AjcTest</td>
  41. </tr>
  42. <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;compile&gt;</code></td>
  43. <td>Initial (batch) compile run</td>
  44. <td>CompilerRun</td>
  45. </tr>
  46. <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;inc-compile&gt;</code></td>
  47. <td>Incremental re-compile</td>
  48. <td>IncCompilerRun</td>
  49. </tr>
  50. <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;<code>&lt;run&gt;</code></td>
  51. <td>Run class</td>
  52. <td>JavaRun</td>
  53. </tr>
  54. </table>
  55. <!--
  56. general harness (Harness)
  57. subclass feature harness (FeatureHarness)
  58. &lt;ajc-test&gt; run component (AjcTest)
  59. &lt;compile&gt; {sub-} run component (CompilerRun)
  60. &lt;inc-compile&gt; {sub-} run component (IncCompilerRun)
  61. &lt;run&gt; {sub-} run component (JavaRun)
  62. ...
  63. -->
  64. <p/>
  65. The compiler used is the AspectJ compiler <code>ajc</code>
  66. (optionally as wrapped by the Ant task or AJDE API's), but
  67. in principle any compiler accepting similar options can be
  68. used.
  69. <p/>
  70. To run from the command-line, use
  71. <code>Harness.main(String[])</code>.
  72. To run programmatically, use <code>Harness.getHarness()</code>.
  73. <code>Harness.runMain(String[])</code> takes arguments that
  74. each component in the chain may accept and interpret, so
  75. you can modify how the tests run by specifying the following
  76. arguments on the harness command line:
  77. <p/>
  78. <table cellpadding="1" border="1">
  79. <tr><th>Component</th><th>Options</th></tr>
  80. <tr><td rowspan="6" valign="top">Harness
  81. <p>suite files, harness verbosity, temp files, option variants
  82. </p></td></tr>
  83. <tr><td><u>suite files</u>: ajcTest-compliant .txt or .xml files are accepted.
  84. <!-- XXX link to ajcTestSuite.dtd and .txt definitions -->
  85. </td></tr>
  86. <tr><td><u><code>-verboseHarness</code></u>,
  87. <u><code>-quietHarness</code></u>:
  88. Log accepted options and skipped tests,
  89. or do not print even info messages.
  90. </td></tr>
  91. <tr><td><u><code>-keepTemp</code></u>: Normally the harness saves temp files until
  92. the end of the run, and deletes them. If you abort the run or specify
  93. <code>-keepTemp</code>, then temporary (sandbox) directories will remain for analysis.
  94. In either case, the file system accumulates all temporary directories
  95. and files used for a give harness run; for the <code>ajcTests.xml</code>
  96. suite, this runs into thousands of files.
  97. </td></tr>
  98. <tr><td><u><code>-killTemp</code></u>: The opposite of <code>-keepTemp</code>,
  99. this causes the harness to delete temporary (sandbox) directories at
  100. the end of each test run.
  101. In this case, the file system only accumulates files for
  102. the current test.
  103. </td></tr>
  104. <tr><td><u>*- variants</u>: Options with a trailing "-" cause two sets of
  105. option lists to be produced, one with and one without the corresponding
  106. option. E.g., "-emacssym-" will run the suite twice, once with and
  107. once without the "-emacssym" flag.
  108. That means if you use this on each of three options, you will
  109. get 8 variant sets (1 with no options, 1 with all 3 options,
  110. 3 with 2 options, and 3 with 1 option).
  111. </td></tr>
  112. <tr><td rowspan="5" valign="top">FeatureHarness
  113. <p>output and logging options
  114. </p></td></tr>
  115. <tr><td><u>tracing</u>:
  116. <code>-progressDots</code> will print "." for every passed
  117. test completed and "!" for every test completed but not passed.
  118. <code>-traceTests</code> will print a one-line summary for each test
  119. of the time and space taken and whether the test passed.
  120. <code>-traceTestsMin</code> will print only the test and whether it passed.
  121. <code>-baseline</code> is an alias for
  122. <code>-traceTestsMin</code>
  123. <code>-hideStreams</code> and
  124. <code>!eclipse</code>, used to emit tests results in a form
  125. comparable by <code>org.aspectj.testing.util.TestDiffs</code>.
  126. or usable to select tests by title for options like
  127. <code>-ajctestTitleList</code>.
  128. </td></tr>
  129. <tr><td><u>output</u>: <code>-hide{Compiler|Run}Streams</code> will prevent output and
  130. error streams from being printed to System.err and System.out,
  131. optionally only for run or compile steps.
  132. </td></tr>
  133. <tr><td><u>logging</u>:
  134. Log variants take the form <code>-log{Min|Xml}[Fail|Pass|All]</code>.
  135. The suffix {All|Pass|Fail} selects all tests or only passing or failing tests.
  136. The infix {Min} means to log with minimal information, typically only any
  137. fail messages.
  138. The infix {Xml} means to log the XML form of the test definition, so that
  139. you can inspect the input or re-run arbitrary tests.
  140. (You can also re-run a set of tests using keywords
  141. (e.g., "<code>-ajctestsRequireKeywords=...</code>" or using titles
  142. (e.g., "<code>-ajctestsTitleFailList=ajcTestResults.txt</code>".)
  143. Finally, the experimental option <code>-XlogPublicType</code> will
  144. log the XML test definition for
  145. any test run that emits any ERROR messages containing the text "public type".
  146. </td></tr>
  147. <tr><td><u>interaction of output streams and logging</u>:
  148. Streams will be emitted in real-time,
  149. <em>before</em> the test is logged, unless streams are hidden.
  150. When logging in normal (non-Min or -XML) form, the log will emit the streams
  151. with the test report, so e.g., you can use -hideStreams -logFail to
  152. hide streams for passing tests but emit them for failing tests
  153. in the context of the log.
  154. </td></tr>
  155. <tr><td rowspan="5" valign="top">AjcTest
  156. <p>selection options for keywords, bugID (PR), or title (description)
  157. </p></td></tr>
  158. <tr><td><u>keywords</u>: <code>-ajctest[Require|Skip]Keywords=one{,two}</code>
  159. will either require or skip a test that has one of the
  160. specified keywords.
  161. </td></tr>
  162. <tr><td><u>Bugs</u>: <code>-ajctestPR=101{,102}</code>
  163. will require that a test have one of the listed bug id's.
  164. </td></tr>
  165. <tr><td><u>title</u>:
  166. <code>"-ajctestTitleContains=one,two"</code>
  167. will require that the title (description) of a test contain
  168. one of the specified substrings, here either "one" or "two".
  169. Use this to select a few tests you know generally.
  170. <br/>
  171. <code>"-ajctestTitleList=first title\, in theory, second title"</code>
  172. will require that the title (description) of a test be
  173. exactly "first title, in theory" or "second title".
  174. The entire option must be one argument on the command line.
  175. Use this when working with just a few specific tests.
  176. <br/>
  177. <code>"-ajctestTitleList=../tests/ajcTestResults.txt"</code>
  178. will require that the title (description) of a test be
  179. equal to one listed in <code>../tests/ajcTestResults.txt</code>
  180. as a line of the form "[PASS|FAIL] {title}(.."
  181. (This form is emitted by the <code>-traceTestsMin</code> option).
  182. This option only differs from the prior in that the parameter
  183. is a valid file to read.
  184. Use this to re-run a large set of tests.
  185. <br/>
  186. <code>"-ajctestTitleFailList=../tests/ajcTestResults.txt"</code>
  187. is the same as the <code>-ajctestTitleList={file}</code> variant,
  188. except that only results prefixed "FAIL" are included.
  189. Use this to re-run only the tests that failed from a large set.
  190. </td></tr>
  191. <tr><td><u>Combinations</u>: all selectors are applied to each test,
  192. so all tests selected will comply with all constraints.
  193. Specifying lists within a particular constraints will match
  194. a union of tests for that constraint
  195. (e.g., all tests with bug id's 101 or 102),
  196. but there is no way to get a union of constraints
  197. (e.g., all tests with bug id's 101 or 102 <em>or</em>
  198. with keywords pure-java or knownLimitation).
  199. However, <code>-ajctestSkipKeywords=...</code> can return all
  200. tests without the specified keywords, so it can form unions like
  201. "all tests without the knownLimitation keyword, but with
  202. bug id's 101 or 102".
  203. Title lists can work similarly. E.g., to run the failed
  204. incremental tests from ajcTestResults.txt, specify
  205. <code>-ajctestTitleFailList=../tests/ajcTestResults.txt</code>
  206. <code>-ajctestRequireKeywords=incremental-test</code>.
  207. </td></tr>
  208. <tr><td rowspan="6" valign="top">CompilerRun
  209. <p>compiler options and side-effects
  210. </p></td></tr>
  211. <tr><td><u>supported options</u>:
  212. The command line passed to the compiler by <code>CompilerRun</code>
  213. is composed of entries derived from the <code>&lt;compile&gt;</code>
  214. attributes and recognized from the harness command line.
  215. <code>&lt;compile&gt;</code> has specific attributes like
  216. <code>files</code>,
  217. <code>argfiles</code>,
  218. <code>classpath</code> and
  219. <code>sourceroot</code>
  220. which translate directly to their counterparts.
  221. The output option <code>-d</code> is defined by <code>CompilerRun</code> and
  222. may not be specified (and <code>-outjar</code> is not supported).
  223. Most other compiler options are defined in
  224. <code>CompilerRun.Spec.CRSOptions</code> and may be specified
  225. on the harness command-line
  226. or in the <code>options</code> attribute of
  227. <code>&lt;compile&gt;</code>.
  228. In the <code>options</code> attribute, each argument is comma-delimited,
  229. so an option with an argument would look like
  230. <code>&lt;compile options="-source,1.4" ...&gt;</code>.
  231. If options collide, duplicates
  232. can be resolved using option dominance (below).
  233. </td></tr>
  234. <tr><td><u>compiler selectors</u>:
  235. Use <code>-ajc</code> or <code>-eclipse</code> to select the old
  236. (ajc 1.0) or new (eajc 1.1) compilers.
  237. Note that the old compiler is not
  238. available in the CVS source tree at eclipse.org.
  239. Use <code>-ajdeCompiler</code> to run a wrapper around the
  240. AJDE interface
  241. and <code>-ajctaskCompiler</code> to run a wrapper around the
  242. AjcTask (Ant task) interface.
  243. </td></tr>
  244. <tr><td><u>option dominance <code>[-|!|^]</code></u>:
  245. Some tests require or prohibit certain options;
  246. likewise, sometime you want to force all tests
  247. run with or without an option specified on the command-line,
  248. regardless of its setting in the <code>&lt;compile options=".." ...&gt;</code>
  249. attribute.
  250. For this reason an option may be specified in the options attribute
  251. or on the harness command-line as
  252. <code>-option</code>,
  253. <code>!option</code>, or
  254. <code>^option</code>.
  255. <ul>
  256. <li><u>- set</u>: If the leading character of an option is "-", then it is set unless forced-off.</li>
  257. <li><u>^ force-off</u>: If the leading character of an option is "^", then it is forced off.
  258. Any other matching option will be removed.</li>
  259. <li><u>! force-on</u>: If the leading character of an option is "!", then it is forced on.
  260. Any other non-force-on matching option will be removed.</li>
  261. <li><u>force conflict</u>: If there are two matching force-on options, the test is skipped.</li>
  262. <li><u>related options</u>: Two options match if they are the same or
  263. if they are in the same family. For example, <code>-ajc</code> and
  264. <code>eclipse</code> are both compiler, and <code>-source 1.4</code>
  265. and <code>-source 1.3</code> are both source.
  266. <br/>
  267. </li>
  268. </ul>
  269. </td></tr>
  270. <tr><td><u>auto-skip</u>: After combining global and local options, there may be
  271. conflicting or impossible options, which cause the test to be skipped:
  272. <ul>
  273. <li><u>semantic conflicts</u>: two options may conflict in meaning
  274. - e.g., <code>-lenient</code> and <code>-strict</code></li>
  275. <li><u>impossible option</u>: It may not be possible in the current configuration to
  276. implement an option - e.g., <code>-usejavac</code> or <code>-eclipse</code>
  277. when javac or the eclipse implementation is not on the classpath
  278. <br/></li>
  279. </ul>
  280. </td></tr>
  281. <tr><td><u>source searching</u>: Given <code>-seek:{literal}</code>,
  282. as a side-effect,
  283. <code>CompilerRun</code> will search source files for {literal},
  284. emitting for each instance an INFO message of the form:
  285. <tt>found: {file}:{line}:{column}</tt>
  286. (Note that the harness does not display INFO messages unless <tt>-verboseHarness</tt>
  287. or <tt>-loud</tt> is used.)
  288. </td></tr>
  289. <tr><td rowspan="2" valign="top">JavaRun
  290. <p>Options and forking</p></td>
  291. <td><u>options</u>: options specified in the test are passed
  292. to the main method as they would be on the command-line.
  293. No options passed to the harness are passed through to
  294. the main class.
  295. </td></tr>
  296. <tr><td><u>forking</u>:
  297. Forking is useful to run in a different version of Java
  298. than can be supported by the harness (i.e., some 1.1 flavor);
  299. it's very time-consuming otherwise.
  300. Currently forking is only controllable through system properties
  301. of the invoking vm (defined in JavaRun.java):
  302. <ul>
  303. <li><u>javarun.fork</u>: anything to run in a new vm.
  304. </li>
  305. <li><u>javarun.java</u>: path to the java executable to run
  306. (suffix included). If not supplied, the harness tries to
  307. find the java that invoked the harness.
  308. </li>
  309. <li><u>javarun.java.home</u>: the value of the JAVA_HOME
  310. environment variable, if it needs to be set.
  311. </li>
  312. <li><u>javarun.bootclasspath</u>: this is prepended to the
  313. run classpath. Multiple entries must be separated by
  314. the system-dependent path separator.
  315. </li>
  316. <li><u>javarun.vmargs</u>: this is added to the fork command-line
  317. right after java. Multiple entries must be separated by a comma
  318. (and the whole thing should be one parameter), e.g.,
  319. <code>-Djavarun.vmargs=-Dname=value,-Dname2="value 2"</code>
  320. </li>
  321. </ul>
  322. </td></tr>
  323. </table>
  324. <br/>
  325. Following are some sample configurations:
  326. <ul>
  327. <li><code>java {harness} -hideStreams {suiteFile}</code>
  328. <p>Use this to output only a 1-line summary of the test results
  329. (tests skipped, incomplete, failed, passed).<br/></p>
  330. </li>
  331. <li><code>java {harness} -hideStreams -traceTestsMin {suiteFile} > results.txt</code>
  332. <p>This writes to result.txt one line [PASS|FAIL] per test, plus a
  333. 1-line summary of the test results.<br/></p>
  334. </li>
  335. <li><code>java {harness} -logFail {suiteFile} -ajctestTitleFailList=results.txt</code>
  336. <p>This re-runs any test that failed from the "results.txt" run,
  337. verbosely logging any fails.<br/></p>
  338. </li>
  339. <li><code>java {harness} -hideStreams -logMinFail {suiteFile}</code>
  340. <p>Use this when running tests mainly to see if they pass or
  341. if the failure messages are typically enough information
  342. to indicate why the test is failing. It produces only minimal
  343. output for failed tests.<br/></p>
  344. </li>
  345. <li><code>java {harness} -hideStreams -verboseHarness -logFail {suiteFile}</code>
  346. <p>When it's not clear at first glance why a test is failing, before
  347. looking at the test code you can run it and print any harness or test
  348. setup failures and all the associated messages from the test components.<br/></p>
  349. </li>
  350. <li><code>java {harness} -hideStreams -usejavac- -ajc -Xlint- {suiteFile}</code>
  351. <p>Because of the trailing '-' on two of the options,
  352. this would do four complete runs with the old (Ajc 1.0) compiler: one with
  353. no options, one with -lenient, one with -Xlint, and one with both.<br/></p>
  354. </li>
  355. <li><code>java {harness} --ajctestPR=101,102 -Xlint- ^usejavac !eclipse {suiteFile}</code>
  356. <p>Run any tests associated with bugs 101 and 102, with and without -Xlint,
  357. forcing off -usejavac and forcing the use of the new eclipse-based compiler.<br/></p>
  358. </li>
  359. </ul>
  360. If you have a set of options you use often, you can define a single-word
  361. option alias for it; see <code>Harness.optionAliases</code>.
  362. <br/><u>Configuration</u>: Most tests use the library jars in
  363. <code>modules/lib/test</code>, defined in
  364. <code>org.aspectj.testing.harness.bridge.Globals</code>.
  365. Normally the harness finds these by relative path
  366. <code>../lib/tests/*.jar</code>, which works whenever the tests are
  367. run from a peer module directory. When running tests elsewhere,
  368. define the environment variable <code>harness.libdir</code> - e.g.,
  369. <pre>
  370. $ cd aspectj/tests
  371. $ java -Dharness.libdir=../modules/lib/test ...
  372. </pre>
  373. <br/><u>Forking:</u>:
  374. The harness must be run in a compiler-compatible VM, and the
  375. compiler steps run in-process.
  376. However, the java steps can be run in forked mode, which is useful
  377. when compiling for a VM which can't run the compiler.
  378. To compile for a different target VM could require
  379. setting the options for bootclasspath, target, and source.
  380. To run the harness so that any &lt;run.. tasks run in a
  381. separate vm, do something like this:
  382. <pre>
  383. java -Djavarun.java=d:\jdk1.1.8\bin\java.exe \
  384. -Djavarun.bootclasspath=d:\jdk1.1.8\lib\classes.zip \
  385. -Djavarun.java.home=d:\jdk1.1.8 \
  386. -Djavarun.fork=true \
  387. -jar ../aj-build/jars/testing-drivers-all.jar \
  388. ajcTests.xml -logFail
  389. </pre>
  390. Here <code>CompilerRun</code> would add the bootclasspath as such when compiling.
  391. JavaRun would fork using the 1.1 vm and prepend the bootclasspath
  392. to the classpath, with an effect like these commands
  393. (ignoring the line splitting in the classpath):
  394. <pre>
  395. set JAVA_HOME=d:\jdk1.1.8
  396. d:\jdk1.1.8\bin\java.exe \
  397. -classpath "d:\jdk1.1.8\lib\classes.zip;
  398. d:\aspectj-src\lib\test\testing-client.jar;
  399. d:\aspectj-src\lib\test\aspectjrt.jar;
  400. c:\TEMP\sandbox7wers\classes"
  401. {mainClass} {option..}
  402. </pre>
  403. </body>
  404. </html>