Browse Source

initial version

tags/initial_CPL
wisberg 21 years ago
parent
commit
31b7d84b2b
54 changed files with 2835 additions and 0 deletions
  1. 17
    0
      testing-drivers/.classpath
  2. 25
    0
      testing-drivers/.project
  3. 8
    0
      testing-drivers/readme-testing-drivers.html
  4. 1
    0
      testing-drivers/src/.cvsignore
  5. 1215
    0
      testing-drivers/src/org/aspectj/testing/drivers/Harness.java
  6. 26
    0
      testing-drivers/src/org/aspectj/testing/drivers/RFE-find-tests-for-resource.teamtask
  7. 194
    0
      testing-drivers/src/org/aspectj/testing/drivers/package.html
  8. 58
    0
      testing-drivers/testdata/defaultSuite.xml
  9. 5
    0
      testing-drivers/testdata/incremental/harness/TestNoTester.java
  10. 11
    0
      testing-drivers/testdata/incremental/harness/classAdded/main/Main.20.java
  11. 7
    0
      testing-drivers/testdata/incremental/harness/classAdded/main/Main.java
  12. 8
    0
      testing-drivers/testdata/incremental/harness/classRemoved/main/Main.20.java
  13. 11
    0
      testing-drivers/testdata/incremental/harness/classRemoved/main/Main.java
  14. 12
    0
      testing-drivers/testdata/incremental/harness/classUnchanged/main/Main.20.java
  15. 11
    0
      testing-drivers/testdata/incremental/harness/classUnchanged/main/Main.java
  16. 8
    0
      testing-drivers/testdata/incremental/harness/classUpdated/main/Main.20.java
  17. 7
    0
      testing-drivers/testdata/incremental/harness/classUpdated/main/Main.java
  18. 8
    0
      testing-drivers/testdata/incremental/harness/defaultPackage/Main.30.java
  19. 7
    0
      testing-drivers/testdata/incremental/harness/defaultPackage/Main.40.java
  20. 7
    0
      testing-drivers/testdata/incremental/harness/defaultPackage/Main.java
  21. 9
    0
      testing-drivers/testdata/incremental/harness/defaultPackage/Target.20.java
  22. 2
    0
      testing-drivers/testdata/incremental/harness/defaultPackage/Target.delete.40.java
  23. 7
    0
      testing-drivers/testdata/incremental/harness/expClasses/Main.java
  24. BIN
      testing-drivers/testdata/incremental/harness/expClasses/exp/Main.class
  25. 145
    0
      testing-drivers/testdata/incremental/harness/selectionTest.xml
  26. 12
    0
      testing-drivers/testdata/incremental/harness/sourceAdded/main/Main.30.java
  27. 7
    0
      testing-drivers/testdata/incremental/harness/sourceAdded/main/Main.java
  28. 9
    0
      testing-drivers/testdata/incremental/harness/sourceAdded/main/Target.20.java
  29. 2
    0
      testing-drivers/testdata/incremental/harness/sourceDeleted/delete/DeleteMe.delete.20.java
  30. 7
    0
      testing-drivers/testdata/incremental/harness/sourceDeleted/delete/DeleteMe.java
  31. 8
    0
      testing-drivers/testdata/incremental/harness/sourceDeleted/delete/Main.java
  32. 7
    0
      testing-drivers/testdata/incremental/harness/sourceDeleted/delete/Target.30.java
  33. 8
    0
      testing-drivers/testdata/incremental/harness/sourceDeleted/delete/Target.java
  34. 109
    0
      testing-drivers/testdata/incremental/harness/suite.xml
  35. 134
    0
      testing-drivers/testdata/incremental/harness/suiteFails.xml
  36. 58
    0
      testing-drivers/testdata/incremental/inc-suite.xml
  37. 5
    0
      testing-drivers/testdata/incremental/java/delete/DeleteMe.delete.20.java
  38. 8
    0
      testing-drivers/testdata/incremental/java/delete/DeleteMe.java
  39. 9
    0
      testing-drivers/testdata/incremental/java/delete/Main.java
  40. 9
    0
      testing-drivers/testdata/incremental/java/delete/Target.30.java
  41. 10
    0
      testing-drivers/testdata/incremental/java/delete/Target.java
  42. 9
    0
      testing-drivers/testdata/incremental/java/static/Main.30.java
  43. 11
    0
      testing-drivers/testdata/incremental/java/static/Main.40.java
  44. 11
    0
      testing-drivers/testdata/incremental/java/static/Main.60.java
  45. 9
    0
      testing-drivers/testdata/incremental/java/static/Main.java
  46. 8
    0
      testing-drivers/testdata/incremental/java/static/Target.20.java
  47. 10
    0
      testing-drivers/testdata/incremental/java/static/Target.40.java
  48. 8
    0
      testing-drivers/testdata/incremental/java/static/Target.50.java
  49. 8
    0
      testing-drivers/testdata/incremental/java/static/Target.java
  50. 3
    0
      testing-drivers/testing-drivers.mf.txt
  51. 32
    0
      testing-drivers/testsrc/TestingDriversModuleTests.java
  52. 32
    0
      testing-drivers/testsrc/org/aspectj/testing/drivers/DriversTests.java
  53. 286
    0
      testing-drivers/testsrc/org/aspectj/testing/drivers/HarnessSelectionTest.java
  54. 197
    0
      testing-drivers/testsrc/org/aspectj/testing/drivers/SuiteTest.java

+ 17
- 0
testing-drivers/.classpath View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="testsrc"/>
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
<classpathentry kind="src" path="/bridge"/>
<classpathentry kind="src" path="/bcweaver"/>
<classpathentry kind="src" path="/testing"/>
<classpathentry kind="src" path="/testing-client"/>
<classpathentry kind="src" path="/util"/>
<classpathentry kind="lib" path="/lib/junit/junit.jar" sourcepath="/lib/junit/junit-src.zip"/>
<classpathentry kind="lib" path="/lib/commons/commons.jar" sourcepath="/lib/commons/commons-src.zip"/>
<classpathentry kind="src" path="/org.aspectj.ajdt.core"/>
<classpathentry kind="src" path="/asm"/>
<classpathentry kind="src" path="/org.eclipse.jdt.core"/>
<classpathentry kind="output" path="bin"/>
</classpath>

+ 25
- 0
testing-drivers/.project View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>testing-drivers</name>
<comment></comment>
<projects>
<project>asm</project>
<project>bcweaver</project>
<project>bridge</project>
<project>org.aspectj.ajdt.core</project>
<project>org.eclipse.jdt.core</project>
<project>testing</project>
<project>testing-client</project>
<project>util</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

+ 8
- 0
testing-drivers/readme-testing-drivers.html View File

@@ -0,0 +1,8 @@
<html>
<body>
This project is for integration testing.
<p>
It depends on other projects, but requires that
they export any required libraries.
</body>
</html>

+ 1
- 0
testing-drivers/src/.cvsignore View File

@@ -0,0 +1 @@
*.lst

+ 1215
- 0
testing-drivers/src/org/aspectj/testing/drivers/Harness.java
File diff suppressed because it is too large
View File


+ 26
- 0
testing-drivers/src/org/aspectj/testing/drivers/RFE-find-tests-for-resource.teamtask View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<TeamTask>
<TeamTaskMeta>
<CreationDate format="yyyy-MM-dd :: HH:mm:ss z">2002-10-07 :: 08:44:57 PDT</CreationDate>
<LastModificationDate format="yyyy-MM-dd :: HH:mm:ss z">2002-10-07 :: 13:21:02 PDT</LastModificationDate>
</TeamTaskMeta>
<Summary>find all tests associated with a give .java source file</Summary>
<User>isberg</User>
<Module>testing-drivers</Module>
<AssignedTo>isberg</AssignedTo>
<State description="Postponed" index="2" />
<Severity description="Enhancement" index="0" />
<Description>When updating a source file, it would be nice to be able to find all the test definitions that use it, especially when updating error line numbers in message-variant tests.</Description>
<Notification>
<Recipient>isberg@parc.com</Recipient>
</Notification>
<NoteHistory>
<Note user="isberg">
<NoteMeta>
<NoteDate format="yyyy-MM-dd :: HH:mm:ss z">2002-10-07 :: 13:21:02 PDT</NoteDate>
</NoteMeta>
Ignoring this pending more traffic in the use-case.
</Note>
</NoteHistory>
</TeamTask>


+ 194
- 0
testing-drivers/src/org/aspectj/testing/drivers/package.html View File

@@ -0,0 +1,194 @@
<html>
<body>
These harnesses drive ajc compiler tests. Following is information on how to use them.
<p>

Use <code>Harness.main(String[])</code> from the command-line,
or <code>Harness.getHarness()</code> programmatically.
<code>Harness.runMain(String[])</code> takes arguments that
each component in the chain may accept and interpret.
<p>
<table cellpadding="1" border="1">
<tr><th>Component</th><th>Options</th></tr>

<tr><td rowspan="5" valign="top">Harness
<p>suite files, harness verbosity, temp files, option variants
</td></tr>
<tr><td><u>suite files</u>: ajcTest-compliant .txt or .xml files are accepted.
<!-- XXX link to ajcTestSuite.dtd and .txt definitions -->
</td></tr>
<tr><td><u><code>-verboseHarness</code>, <code>-quietHarness</code></u>:
Log accepted options and skipped tests,
or do not print even info messages.
</td></tr>
<tr><td><u><code>-keepTemp</code></u>: Normally the harness saves temp files until
the end of the run, and deletes them. If you abort the run or specify
<code>-keepTemp</code>, then temporary (sandbox) directories will remain for analysis.
</td></tr>
<tr><td><u>*- variants</u>: Options with a trailing "-" cause two sets of
option lists to be produced, one with and one without the corresponding
option. E.g., "-usejavac-" will run the suite twice, once with and
once without the "-usejavac" flag.
That means if you use this on each of three options, you will
get 8 variant sets (1 with no options, 1 with all 3 options,
3 with 2 options, and 3 with 1 option).
</td></tr>
<tr><td rowspan="5" valign="top">FeatureHarness
<p>output and logging options
</td></tr>
<tr><td><u>tracing</u>:
<code>-progressDots</code> will print "." for every passed
test completed and "!" for every test completed but not passed.
<code>-traceTests</code> will print a one-line summary for each test
of the time and space taken and whether the test passed.
<code>-traceTestsMin</code> will print only the test and whether it passed.
<code>-baseline</code> is an alias for
<code>-traceTestsMin</code>
<code>-hideStreams</code> and
<code>!eclipse</code>, used to emit tests results in a form
comparable by <code>org.aspectj.testing.util.TestDiffs</code>.
</td></tr>
<tr><td><u>output</u>: <code>-hide{Compiler|Run}Streams</code> will prevent output and
error streams from being printed to System.err and System.out,
optionally only for run or compile steps.
</td></tr>
<tr><td><u>logging</u>:
Log variants take the form <code>-log{Min|Xml}[Fail|Pass|All]</code>.
The suffix {All|Pass|Fail} selects all tests or only passing or failing tests.
The infix {Min} means to log with minimal information, typically only any
fail messages.
The infix {Xml} means to log the XML form of the test definition, so that
you can inspect the input or re-run arbitrary tests. (For the latter, consider
also using keywords, under <code>-ajctestsRequireKeywords=...</code> below.)
Finally, the experimental option <code>-XlogPublicType</code> will
log the XML test definition for
any test run that emits any ERROR messages containing the text "public type".
</td></tr>
<tr><td><u>interaction of output streams and logging</u>:
Streams will be emitted before the test is logged, unless streams are hidden.
When logging in normal (non-Min or -XML) form, the log will emit the streams
with the test report, so e.g., you can use -hideStreams -logFail to
hide streams for passing tests but emit them for failing tests.
</td></tr>
<tr><td rowspan="3" valign="top">AjcTest
<p>selection options for keywords, bugID (PR)
</td></tr>
<tr><td><u>keywords</u>: <code>-ajctest[Require|Skip]Keywords=one{,two}</code>
will either require or skip tests that have the specified keywords.
</td></tr>
<tr><td><u>Bugs</u>: <code>-ajctestPR=101{,102}</code>
will run only tests that are associated with one of the bug id's listed.
</td></tr>
<tr><td rowspan="6" valign="top">CompilerRun
<p>compiler options and side-effects
</td></tr>
<tr><td><u>supported options</u>: Options given on the command-line have
the same meaning as the options in the test specification.
Only one-word options are supported; for this reason, <code>-source 1.4</code> is
specified as <code>-source14</code> and converted by CompilerRun back
to <code>-source 1.4</code>. Unsupported options include
<code>-argfile</code>,
<code>-d</code>,
<code>-classpath</code>,
<code>-outjar</code>, and
<code>-sourceroot</code>.
</td></tr>
<tr><td><u>compiler selectors</u>: Use <code>-ajc</code> or <code>-eclipse</code> to select the old
(ajc 1.0) or new (eajc 1.1) compilers.
</td></tr>
<tr><td><u>option dominance <code>-!^</code></u>:
Some tests require or prohibit certain options;
likewise, sometime the person running the tests wants to require that all tests
run with or without an option specified on the command-line. CompilerRun supports encodings and
conflict resolution for these, so an option may be specified as
<code>-option</code>,
<code>!option</code>, or
<code>^option</code>.
<ul>
<li><u>- set</u>: If the leading character of an option is "-", then it is set unless forced-off.</li>
<li><u>^ force-off</u>: If the leading character of an option is "^", then it is forced off.</li>
<li><u>! force-on</u>: If the leading character of an option is "!", then it is forced on.</li>
<li><u>force conflict</u>: If local and global forces oppose, the test is skipped.</li>
<li><u>compiler conflicts</u>: compiler selectors may be forced (e.g.,
<code>!ajc</code> or <code>^eclipse</code>), and conflicts are resolved
in the same way, so a local-global set conflict resolves in favor of the
global specification. (e.g., local <code>-eclipse</code> and global
<code>-ajc</code> will use the ajc compiler)</li>
<ul><p>
</td></tr>
<tr><td><u>auto-skip</u>: After collation of global and local options, there may be
conflicting or impossible options, which cause the test to be skipped:
<ul>
<li><u>semantic conflicts</u>: two options may conflict in meaning
- e.g., <code>-lenient</code> and <code>-strict</code></li>
<li><u>impossible option</u>: It may not be possible in the current configuration to
implement an option - e.g., <code>-usejavac</code> or <code>-eclipse</code>
when javac or the eclipse implementation is not on the classpath</li>
<ul><p>
</td></tr>
<tr><td><u>source searching</u>: Given <code>-seek:{literal}</code>,
as a side-effect,
CompilerRun will search source files for {literal},
emitting for each instance an INFO message of the form:
<tt>found: {file}:{line}:{column}</tt>
(Note that the harness does not display INFO messages unless <tt>-verboseHarness</tt>
or <tt>-loud</tt> is used.)
</td></tr>
</table>
<p>
Following are some sample configurations:
<ul>
<li><code>java {harness} -hideStreams {suiteFile}</code>
<p>Use this to output only a 1-line summary of the test results
(tests skipped, incomplete, failed, passed).<p>
</li>
<li><code>java {harness} -hideStreams -logMinFail {suiteFile}</code>
<p>Use this when running tests mainly to see if they pass or
if the failure messages are typically enough information
to indicate why the test is failing. It produces only minimal
output for failed tests.<p>
</li>
<li><code>java {harness} -hideStreams -verboseHarness -logFail {suiteFile}</code>
<p>When it's not clear at first glance why a test is failing, before
looking at the test code you can run it and print any harness or test
setup failures and all the associated messages from the test components.<p>
</li>

<li><code>java {harness} -hideStreams -usejavac- -ajc -Xlint- {suiteFile}</code>
<p>This would do four complete runs with the old (Ajc 1.0) compiler: one with
no options, one with -lenient, one with -Xlint, and one with both.<p>
</li>

<li><code>java {harness} --ajctestPR=101,102 -Xlint- ^usejavac !eclipse {suiteFile}</code>
<p>Run any tests associated with bugs 101 and 102, with and without -Xlint,
forcing off -usejavac and forcing the use of the new eclipse-based compiler.<p>
</li>
</ul>

If you have a set of options you use often, you can define a single-word
option alias for it; see <code>Harness.optionAliases</code>.

<p><u>Configuration</u>: most tests use the library jars in
<code>aspectj/modules/lib/test</code>, defined in
<code>org.aspectj.testing.harness.bridge.Globals</code>.
Normally the harness finds these by relative path
<code>../lib/tests/*.jar</code>, which works whenever the tests are
run from a peer module directory. When running tests elsewhere,
define the environment variable <code>harness.libdir</code> - e.g.,
<pre>
$ cd aspectj/tests
$ java -Dharness.libdir=../modules/lib/test -jar eajctesting.jar ajcTests.xml
</pre>

</body>
</html>

+ 58
- 0
testing-drivers/testdata/defaultSuite.xml View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<!DOCTYPE suite [
<!ELEMENT suite (ajc-test+)>
<!ATTLIST suite file CDATA #IMPLIED >
<!ELEMENT ajc-test (compile*,inc-compile*,run*)>
<!ATTLIST ajc-test title CDATA #REQUIRED >
<!ATTLIST ajc-test dir CDATA #REQUIRED >
<!ATTLIST ajc-test pr CDATA #IMPLIED >
<!ATTLIST ajc-test keywords CDATA #IMPLIED >

<!ELEMENT compile (file*,message*)>
<!ATTLIST compile files CDATA #IMPLIED >
<!ATTLIST compile options CDATA #IMPLIED >
<!ATTLIST compile staging (true | false) #IMPLIED >

<!ELEMENT inc-compile (message*)>
<!ATTLIST inc-compile tag CDATA #REQUIRED >
<!ATTLIST inc-compile changedFiles CDATA #IMPLIED >

<!ELEMENT run (message*)>
<!ATTLIST run class CDATA #REQUIRED >
<!ATTLIST run skipTester CDATA #IMPLIED >
<!ATTLIST run options CDATA #IMPLIED >

<!ELEMENT file (#PCDATA)>
<!ATTLIST file path CDATA #IMPLIED >
<!ELEMENT message (#PCDATA)>
<!ATTLIST message kind (error | warning | Xlint) #REQUIRED >
<!ATTLIST message line CDATA #REQUIRED >
<!ATTLIST message text CDATA #IMPLIED >
<!ATTLIST message file CDATA #IMPLIED >
]>

<suite file="defaultSuite.xml">

<ajc-test dir="incremental/java/static"
title="minimal incremental test"
keywords="incremental" >
<compile staging="true" files="Main.java,Target.java"/>
<inc-compile tag="20" changedFiles="Main.java">
<message kind="error" line="6" file="Main.java"/>
</inc-compile>
<inc-compile tag="30"/>
<inc-compile tag="40"/>
</ajc-test>

<ajc-test dir="incremental/java/delete"
title="minimal incremental test with delete operation"
keywords="incremental" >
<compile staging="true" files="Main.java,Target.java,DeleteMe.java"/>
<inc-compile tag="20">
<message kind="error" line="7" file="Target.java" text="*DeleteMe.main*"/>
</inc-compile>
<inc-compile tag="30"/>
</ajc-test>

</suite>

+ 5
- 0
testing-drivers/testdata/incremental/harness/TestNoTester.java View File

@@ -0,0 +1,5 @@

public class TestNoTester {
public static void main (String[] args) {
}
}

+ 11
- 0
testing-drivers/testdata/incremental/harness/classAdded/main/Main.20.java View File

@@ -0,0 +1,11 @@
package main;

public class Main {
public static void main (String[] args) {
new Target().run();
}
}

class Target {
void run() {}
}

+ 7
- 0
testing-drivers/testdata/incremental/harness/classAdded/main/Main.java View File

@@ -0,0 +1,7 @@

package main;

public class Main {
public static void main (String[] args) {
}
}

+ 8
- 0
testing-drivers/testdata/incremental/harness/classRemoved/main/Main.20.java View File

@@ -0,0 +1,8 @@

package main;

public class Main {
public static void main (String[] args) {
}
}


+ 11
- 0
testing-drivers/testdata/incremental/harness/classRemoved/main/Main.java View File

@@ -0,0 +1,11 @@
package main;

public class Main {
public static void main (String[] args) {
new Target().run();
}
}

class Target {
void run() {}
}

+ 12
- 0
testing-drivers/testdata/incremental/harness/classUnchanged/main/Main.20.java View File

@@ -0,0 +1,12 @@

package main;

public class Main {
public static void main (String[] args) {
String s = "" + new Target();
}
}

class Target {
void run() {}
}

+ 11
- 0
testing-drivers/testdata/incremental/harness/classUnchanged/main/Main.java View File

@@ -0,0 +1,11 @@
package main;

public class Main {
public static void main (String[] args) {
new Target().run();
}
}

class Target {
void run() {}
}

+ 8
- 0
testing-drivers/testdata/incremental/harness/classUpdated/main/Main.20.java View File

@@ -0,0 +1,8 @@
package main;

public class Main {
public static void main (String[] args) {
new Main().run();
}
void run() {}
}

+ 7
- 0
testing-drivers/testdata/incremental/harness/classUpdated/main/Main.java View File

@@ -0,0 +1,7 @@

package main;

public class Main {
public static void main (String[] args) {
}
}

+ 8
- 0
testing-drivers/testdata/incremental/harness/defaultPackage/Main.30.java View File

@@ -0,0 +1,8 @@

// default package

public class Main {
public static void main (String[] args) {
new Target().run();
}
}

+ 7
- 0
testing-drivers/testdata/incremental/harness/defaultPackage/Main.40.java View File

@@ -0,0 +1,7 @@

// default package

public class Main {
public static void main (String[] args) {
}
}

+ 7
- 0
testing-drivers/testdata/incremental/harness/defaultPackage/Main.java View File

@@ -0,0 +1,7 @@

// default package

public class Main {
public static void main (String[] args) {
}
}

+ 9
- 0
testing-drivers/testdata/incremental/harness/defaultPackage/Target.20.java View File

@@ -0,0 +1,9 @@

// default package

public class Target {
public static void main(String[] args) {
new Target().run();
}
void run() {}
}

+ 2
- 0
testing-drivers/testdata/incremental/harness/defaultPackage/Target.delete.40.java View File

@@ -0,0 +1,2 @@

// delete this file

+ 7
- 0
testing-drivers/testdata/incremental/harness/expClasses/Main.java View File

@@ -0,0 +1,7 @@

// default package

public class Main {
public static void main (String[] args) {
}
}

BIN
testing-drivers/testdata/incremental/harness/expClasses/exp/Main.class View File


+ 145
- 0
testing-drivers/testdata/incremental/harness/selectionTest.xml View File

@@ -0,0 +1,145 @@

<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd">

<suite >

<!-- .............................................................................
Should get 1 tests run and passed when running with global options:
-ajctestRequireKeywords=requireKeyword
-ajctestSkipKeywords=skipKeyword
!verbose
-eclipse
This is used by a JUnit test HarnessSelectionTest.
Do not change the outcome without changing that test.
-->
<ajc-test dir="." title="run and pass"
keywords="requireKeyword" >
<compile files="TestNoTester.java"/>
<run class="TestNoTester"/>
</ajc-test>

<!-- .............................................................................
AjcTest should skip or select based on (arbitrary) keywords
-->

<ajc-test dir="." pr="100" title="omit if skipKeyword" keywords="requireKeyword,skipKeyword" >
<compile staging="false" files="TestNoTester.java"/>
<run class="TestNoTester"/>
</ajc-test>
<!-- .............................................................................
CompilerRun should resolve soft conflicts in favor of globals. XXX
-->

<!-- .............................................................................
CompilerRun should skip hard conflicts (both local and global use force). XXX
-->
<ajc-test dir="." pr="101" title="skip - conflict of local ^verbose and global !verbose XXX failing - runs"
keywords="requireKeyword" >
<compile files="TestNoTester.java" options="^verbose"/>
<run class="TestNoTester"/>
</ajc-test>

<!-- .............................................................................
CompilerRun should skip semantic conflicts - see CompilerRun.Spec.setupArgs(..).
-->

<ajc-test dir="." title="skip - local conflict between -lenient, -strict"
keywords="requireKeyword" >
<compile files="TestNoTester.java" options="-lenient,-strict"/>
<run class="TestNoTester"/>
</ajc-test>

<ajc-test dir="." title="skip - local conflict between forced lenient, forced strict"
keywords="requireKeyword" >
<compile files="TestNoTester.java" options="!lenient,!strict"/>
<run class="TestNoTester"/>
</ajc-test>

<!-- ................... ajc limitations -->
<ajc-test dir="." title="skip - forced ajc with incremental tests"
keywords="requireKeyword" >
<compile staging="true" files="TestNoTester.java" options="!ajc"/>
<run class="TestNoTester"/>
</ajc-test>

<!-- ................... eajc limitations -->
<ajc-test dir="." title="skip - forced eclipse with -strict"
keywords="requireKeyword,ajcEclipseForceConflict,eclipseOptionSkip" >
<compile staging="true" files="TestNoTester.java" options="-strict,!eclipse"/>
<run class="TestNoTester"/>
</ajc-test>

<ajc-test dir="." title="skip - forced eclipse with -lenient"
keywords="requireKeyword,ajcEclipseForceConflict,eclipseOptionSkip" >
<compile staging="true" files="TestNoTester.java" options="-lenient,!eclipse"/>
<run class="TestNoTester"/>
</ajc-test>

<ajc-test dir="." title="skip - forced eclipse with forced strict"
keywords="requireKeyword,ajcEclipseForceConflict,eclipseOptionSkip" >
<compile staging="true" files="TestNoTester.java" options="!strict,!eclipse"/>
<run class="TestNoTester"/>
</ajc-test>

<ajc-test dir="." title="skip - forced eclipse with forced lenient"
keywords="requireKeyword,ajcEclipseForceConflict,eclipseOptionSkip" >
<compile staging="true" files="TestNoTester.java" options="!lenient,!eclipse"/>
<run class="TestNoTester"/>
</ajc-test>

<ajc-test dir="." title="skip - forced eclipse with -preprocess"
keywords="requireKeyword,ajcEclipseForceConflict,eclipseOptionSkip" >
<compile staging="true" files="TestNoTester.java" options="-preprocess,!eclipse"/>
<run class="TestNoTester"/>
</ajc-test>

<ajc-test dir="." title="skip - forced eclipse with -usejavac"
keywords="requireKeyword,ajcEclipseForceConflict,eclipseOptionSkip" >
<compile staging="true" files="TestNoTester.java" options="-usejavac,!eclipse"/>
<run class="TestNoTester"/>
</ajc-test>

<!-- .............................................................................
CompilerRun should skip invalid options CompilerRun.Spec.INVALID_OPTIONS:
{ "-workingdir", "-argfile", "-sourceroot", "-outjar", "-source" }
-->

<ajc-test dir="." title="skip - local invalid option -workingdir"
keywords="requireKeyword,localInvalidOption" >
<compile files="TestNoTester.java" options="-workingdir,."/>
<run class="TestNoTester"/>
</ajc-test>

<ajc-test dir="." title="skip - local invalid option -argfile"
keywords="requireKeyword,localInvalidOption" >
<compile files="TestNoTester.java" options="-argfile,f"/>
<run class="TestNoTester"/>
</ajc-test>

<ajc-test dir="." title="skip - local invalid option -sourceroot"
keywords="requireKeyword,localInvalidOption" >
<compile files="TestNoTester.java" options="-sourceroot,."/>
<run class="TestNoTester"/>
</ajc-test>

<ajc-test dir="." title="skip - local invalid option -outjar"
keywords="requireKeyword,localInvalidOption" >
<compile files="TestNoTester.java" options="-outjar,foo.jar"/>
<run class="TestNoTester"/>
</ajc-test>

<ajc-test dir="." title="skip - local invalid option -source 1.4"
keywords="requireKeyword,localInvalidOption" >
<compile files="TestNoTester.java" options="-source,1.4"/>
<run class="TestNoTester"/>
</ajc-test>
<!-- .............................................................................
CompilerRun should skip invalid options specified as globals XXX
-->

</suite>

+ 12
- 0
testing-drivers/testdata/incremental/harness/sourceAdded/main/Main.30.java View File

@@ -0,0 +1,12 @@

package main;

import org.aspectj.testing.Tester;

public class Main {
public static void main (String[] args) {
new Target().run();
Tester.expectEvent("Target.run()");
Tester.checkAllEvents();
}
}

+ 7
- 0
testing-drivers/testdata/incremental/harness/sourceAdded/main/Main.java View File

@@ -0,0 +1,7 @@

package main;

public class Main {
public static void main (String[] args) {
}
}

+ 9
- 0
testing-drivers/testdata/incremental/harness/sourceAdded/main/Target.20.java View File

@@ -0,0 +1,9 @@
package main;

import org.aspectj.testing.Tester;

public class Target {
void run() {
Tester.event("Target.run()");
}
}

+ 2
- 0
testing-drivers/testdata/incremental/harness/sourceDeleted/delete/DeleteMe.delete.20.java View File

@@ -0,0 +1,2 @@

// delete file DeleteMe.java

+ 7
- 0
testing-drivers/testdata/incremental/harness/sourceDeleted/delete/DeleteMe.java View File

@@ -0,0 +1,7 @@

package delete;

public class DeleteMe {
static void run() {
}
}

+ 8
- 0
testing-drivers/testdata/incremental/harness/sourceDeleted/delete/Main.java View File

@@ -0,0 +1,8 @@

package delete;

public class Main {
public static void main(String[] args) {
Target.run();
}
}

+ 7
- 0
testing-drivers/testdata/incremental/harness/sourceDeleted/delete/Target.30.java View File

@@ -0,0 +1,7 @@

package delete;

public class Target {
static void run() {
}
}

+ 8
- 0
testing-drivers/testdata/incremental/harness/sourceDeleted/delete/Target.java View File

@@ -0,0 +1,8 @@

package delete;

public class Target {
static void run() {
DeleteMe.run(); // CE 6 after DeleteMe deleted
}
}

+ 109
- 0
testing-drivers/testdata/incremental/harness/suite.xml View File

@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd">

<suite>

<!-- driven from JUnit by HarnessSelectionTest.testIncrementalSuite() -->
<!--
Using OldAjc (no inc-compile), get two errors (updated file not found (b/c cleared?),
deleted file not found.
-->

<!--
test harness ability to update and delete source files to prep for a compile
-->
<ajc-test dir="sourceDeleted" title=" file" keywords="incremental" >
<compile staging="true" files="delete/Main.java,delete/Target.java,delete/DeleteMe.java"/>
<run class="delete.Main"/>
<inc-compile tag="20">
<dir-changes removed="delete.DeleteMe"/>
<message kind="error" line="6" file="delete/Target.java"/>
</inc-compile>
<inc-compile tag="30"/>
<run class="delete.Main"/>
</ajc-test>
<ajc-test dir="sourceAdded" title="add file with class" keywords="incremental" >
<compile staging="true" files="main/Main.java"/>
<run class="main.Main"/>
<inc-compile tag="20">
<dir-changes added="main.Target"/>
</inc-compile>
<inc-compile tag="30">
<dir-changes updated="main.Main"/>
</inc-compile>
<run class="main.Main"/>
</ajc-test>

<ajc-test dir="defaultPackage" title="do everything in default package" keywords="incremental" >
<compile staging="true" files="Main.java"/>
<run class="Main"/>
<inc-compile tag="20">
<dir-changes added="Target"/>
</inc-compile>
<run class="Target" skipTester="true"/>
<inc-compile tag="30">
<dir-changes updated="Main"/>
</inc-compile>
<run class="Main" skipTester="true"/>
<inc-compile tag="40">
<dir-changes updated="Main" removed="Target"/>
<message kind="error" line="1"/>
</inc-compile>
<run class="Main"/>
</ajc-test>

<!--
test harness detection of .class file added, removed, or changed
as a result of the compile process.
XXX test dir-changes for JavaRun, CompilerRun
XXX document special handling of dir-changes paths as FQN for .class suffix
XXX need negative tests, fails reported
-->
<ajc-test dir="classAdded" title="expect class added" keywords="incremental" >
<compile staging="true" files="main/Main.java"/>
<run class="main.Main"/>
<inc-compile tag="20" >
<dir-changes added="main.Target"/>
</inc-compile>
<run class="main.Main" skipTester="true"/>
</ajc-test>

<ajc-test dir="classRemoved" title="expect class removed" keywords="incremental" >
<compile staging="true" files="main/Main.java"/>
<run class="main.Main"/>
<inc-compile tag="20">
<dir-changes removed="main.Target"/>
</inc-compile>
<run class="main.Main"/>
</ajc-test>

<ajc-test dir="classUnchanged" title="expect class unchanged" keywords="incremental" >
<compile staging="true" files="main/Main.java"/>
<run class="main.Main"/>
<inc-compile tag="20">
<dir-changes updated="main.Main" unchanged="main.Target"/>
</inc-compile>
<run class="main.Main"/>
</ajc-test>

<ajc-test dir="classUpdated" title="expect class updated" keywords="incremental" >
<compile staging="true" files="main/Main.java"/>
<run class="main.Main"/>
<inc-compile tag="20">
<dir-changes updated="main.Main"/>
</inc-compile>
<run class="main.Main"/>
</ajc-test>

<ajc-test dir="expClasses" title="expected class tree" keywords="incremental"
comment="XXX need to install Main.class compiled with harness" >
<compile files="Main.java">
<dir-changes expDir="expClasses"/>
</compile>
<run class="Main"/>
</ajc-test>


</suite>

+ 134
- 0
testing-drivers/testdata/incremental/harness/suiteFails.xml View File

@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<!DOCTYPE suite [
<!ELEMENT suite (ajc-test+)>
<!ATTLIST suite suiteDir CDATA #IMPLIED >
<!ATTLIST suite verbose CDATA #IMPLIED >

<!ELEMENT ajc-test (compile, (compile | inc-compile | run )*)>
<!ATTLIST ajc-test title CDATA #REQUIRED >
<!ATTLIST ajc-test dir CDATA #REQUIRED >
<!ATTLIST ajc-test pr CDATA #IMPLIED >
<!ATTLIST ajc-test keywords CDATA #IMPLIED >

<!ELEMENT compile (dir-changes*,file*,message*)>
<!ATTLIST compile files CDATA #IMPLIED >
<!ATTLIST compile options CDATA #IMPLIED >
<!ATTLIST compile staging (true | false) #IMPLIED >

<!ELEMENT inc-compile (dir-changes*,message*)> <!-- 0-1? -->
<!ATTLIST inc-compile tag CDATA #REQUIRED >
<!ATTLIST inc-compile changedFiles CDATA #IMPLIED >
<!ATTLIST inc-compile classesAdded CDATA #IMPLIED >
<!ATTLIST inc-compile classesRemoved CDATA #IMPLIED >
<!ATTLIST inc-compile classesUpdated CDATA #IMPLIED >

<!ELEMENT run (dir-changes*,message*)>
<!ATTLIST run class CDATA #REQUIRED >
<!ATTLIST run skipTester CDATA #IMPLIED >
<!ATTLIST run options CDATA #IMPLIED >

<!ELEMENT file (#PCDATA)>
<!ATTLIST file path CDATA #IMPLIED >

<!ELEMENT dir-changes (#PCDATA)>
<!ATTLIST dir-changes dirToken (classes | run) #IMPLIED >
<!ATTLIST dir-changes defaultSuffix CDATA #IMPLIED >
<!ATTLIST dir-changes added CDATA #IMPLIED >
<!ATTLIST dir-changes removed CDATA #IMPLIED >
<!ATTLIST dir-changes updated CDATA #IMPLIED >
<!ATTLIST dir-changes unchanged CDATA #IMPLIED >

<!ELEMENT message (#PCDATA)>
<!ATTLIST message kind (error | warning | info | Xlint) #REQUIRED >
<!ATTLIST message line CDATA #REQUIRED >
<!ATTLIST message text CDATA #IMPLIED >
<!ATTLIST message file CDATA #IMPLIED >
]>

<suite suiteDir="." verbose="true">
<!--
Using OldAjc (no inc-compile), get two errors (updated file not found (b/c cleared?),
deleted file not found.
-->

<!--
test harness ability to update and delete source files to prep for a compile
-->
<!--
test harness ability to detect directory changes
-->
<ajc-test title="report dir-changes fail when expected added class not added"
dir="classAdded" keywords="incremental" >
<compile staging="true" files="main/Main.java"/>
<run class="main.Main"/>
<inc-compile tag="20" >
<dir-changes added="main.ExpectNotAdded"/>
</inc-compile>
</ajc-test>

<ajc-test title="report dir-changes fail when expected added class exists at start"
dir="classAdded" keywords="incremental" >
<compile staging="true" files="main/Main.java"/>
<run class="main.Main"/>
<inc-compile tag="20" >
<dir-changes added="main.Main"/>
</inc-compile>
</ajc-test>

<ajc-test title="report dir-changes fail when expected unchanged class changed"
dir="classAdded" keywords="incremental" >
<compile staging="true" files="main/Main.java"/>
<run class="main.Main"/>
<inc-compile tag="20" >
<dir-changes unchanged="main.Main"/>
</inc-compile>
</ajc-test>

<ajc-test title="report dir-changes fail when expected unchanged class does not exist at start"
dir="classAdded" keywords="incremental" >
<compile staging="true" files="main/Main.java"/>
<run class="main.Main"/>
<inc-compile tag="20" >
<dir-changes unchanged="main.DoesNotExistAtStart"/>
</inc-compile>
</ajc-test>

<ajc-test title="report dir-changes fail when expected updated class is not updated"
dir="classUnchanged" keywords="incremental" >
<compile staging="true" files="main/Main.java"/>
<run class="main.Main"/>
<inc-compile tag="20" >
<dir-changes updated="main.Target"/>
</inc-compile>
</ajc-test>

<ajc-test title="report dir-changes fail when expected updated class does not exist at start"
dir="classAdded" keywords="incremental" >
<compile staging="true" files="main/Main.java"/>
<run class="main.Main"/>
<inc-compile tag="20" >
<dir-changes updated="main.DoesNotExistAtStart"/>
</inc-compile>
</ajc-test>


<ajc-test title="report dir-changes fail when expected deleted class not deleted"
dir="classAdded" keywords="incremental" >
<compile staging="true" files="main/Main.java"/>
<run class="main.Main"/>
<inc-compile tag="20" >
<dir-changes removed="main.Main"/>
</inc-compile>
</ajc-test>

<ajc-test title="report dir-changes fail when expected deleted class does not exist at start"
dir="classAdded" keywords="incremental" >
<compile staging="true" files="main/Main.java"/>
<run class="main.Main"/>
<inc-compile tag="20" >
<dir-changes removed="main.DoesNotExistAtStart"/>
</inc-compile>
</ajc-test>

</suite>

+ 58
- 0
testing-drivers/testdata/incremental/inc-suite.xml View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<!DOCTYPE suite [
<!ELEMENT suite (ajc-test+)>
<!ATTLIST suite file CDATA #IMPLIED >
<!ELEMENT ajc-test (compile*,inc-compile*,run*)>
<!ATTLIST ajc-test title CDATA #REQUIRED >
<!ATTLIST ajc-test dir CDATA #REQUIRED >
<!ATTLIST ajc-test pr CDATA #IMPLIED >
<!ATTLIST ajc-test keywords CDATA #IMPLIED >

<!ELEMENT compile (file*,message*)>
<!ATTLIST compile files CDATA #IMPLIED >
<!ATTLIST compile options CDATA #IMPLIED >
<!ATTLIST compile staging (true | false) #IMPLIED >

<!ELEMENT inc-compile (message*)>
<!ATTLIST inc-compile tag CDATA #REQUIRED >
<!ATTLIST inc-compile changedFiles CDATA #IMPLIED >

<!ELEMENT run (message*)>
<!ATTLIST run class CDATA #REQUIRED >
<!ATTLIST run skipTester CDATA #IMPLIED >
<!ATTLIST run options CDATA #IMPLIED >

<!ELEMENT file (#PCDATA)>
<!ATTLIST file path CDATA #IMPLIED >
<!ELEMENT message (#PCDATA)>
<!ATTLIST message kind (error | warning | Xlint) #REQUIRED >
<!ATTLIST message line CDATA #REQUIRED >
<!ATTLIST message text CDATA #IMPLIED >
<!ATTLIST message file CDATA #IMPLIED >
]>

<suite file="inc-suite.xml">

<ajc-test dir="java/static"
title="minimal incremental test"
keywords="incremental" >
<compile staging="true" files="Main.java,Target.java"/>
<inc-compile tag="20" changedFiles="Main.java">
<message kind="error" line="6" file="Main.java"/>
</inc-compile>
<inc-compile tag="30"/>
<inc-compile tag="40"/>
</ajc-test>

<ajc-test dir="java/delete"
title="minimal incremental test with delete operation"
keywords="incremental" >
<compile staging="true" files="Main.java,Target.java,DeleteMe.java"/>
<inc-compile tag="20">
<message kind="error" line="7" file="Target.java" text="*DeleteMe.main*"/>
</inc-compile>
<inc-compile tag="30"/>
</ajc-test>

</suite>

+ 5
- 0
testing-drivers/testdata/incremental/java/delete/DeleteMe.delete.20.java View File

@@ -0,0 +1,5 @@
public class Main {
public static void main (String[] args) {
}
}

+ 8
- 0
testing-drivers/testdata/incremental/java/delete/DeleteMe.java View File

@@ -0,0 +1,8 @@



public class DeleteMe {
public static void main (String[] args) {
}
}

+ 9
- 0
testing-drivers/testdata/incremental/java/delete/Main.java View File

@@ -0,0 +1,9 @@

// default package

public class Main {
public static void main (String[] args) {
Target.staticMethod();
}
}

+ 9
- 0
testing-drivers/testdata/incremental/java/delete/Target.30.java View File

@@ -0,0 +1,9 @@


// default package

class Target {
static void staticMethod() {
}
}

+ 10
- 0
testing-drivers/testdata/incremental/java/delete/Target.java View File

@@ -0,0 +1,10 @@


// default package

class Target {
static void staticMethod() {
DeleteMe.main(new String[0]);
}
}

+ 9
- 0
testing-drivers/testdata/incremental/java/static/Main.30.java View File

@@ -0,0 +1,9 @@

// default package

public class Main {
public static void main (String[] args) {
Target.staticMethod(1);
}
}

+ 11
- 0
testing-drivers/testdata/incremental/java/static/Main.40.java View File

@@ -0,0 +1,11 @@

// default package

public class Main {
public static void main (String[] args) {
Target.staticMethod(1);
}
static Target.Inner foo = null;
}

+ 11
- 0
testing-drivers/testdata/incremental/java/static/Main.60.java View File

@@ -0,0 +1,11 @@

// default package

public class Main {
public static void main (String[] args) {
Target.staticMethod(1);
}
static Target.Inner foo = null;
}

+ 9
- 0
testing-drivers/testdata/incremental/java/static/Main.java View File

@@ -0,0 +1,9 @@

// default package

public class Main {
public static void main (String[] args) {
Target.staticMethod();
}
}

+ 8
- 0
testing-drivers/testdata/incremental/java/static/Target.20.java View File

@@ -0,0 +1,8 @@


// default package

class Target {
static void staticMethod(int i) { // CE Main.java:6
}
}

+ 10
- 0
testing-drivers/testdata/incremental/java/static/Target.40.java View File

@@ -0,0 +1,10 @@


// default package

class Target {
static void staticMethod(int i) { // CE Main.java:6
}
static class Inner {}
}

+ 8
- 0
testing-drivers/testdata/incremental/java/static/Target.50.java View File

@@ -0,0 +1,8 @@


// default package

class Target {
static void staticMethod(int i) { // CE Main.java:6
}
}

+ 8
- 0
testing-drivers/testdata/incremental/java/static/Target.java View File

@@ -0,0 +1,8 @@


// default package

class Target {
static void staticMethod() {
}
}

+ 3
- 0
testing-drivers/testing-drivers.mf.txt View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: org.aspectj.testing.drivers.Harness


+ 32
- 0
testing-drivers/testsrc/TestingDriversModuleTests.java View File

@@ -0,0 +1,32 @@
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/


// default package

import org.aspectj.testing.drivers.DriversTests;

import junit.framework.*;
import junit.framework.Test;

public class TestingDriversModuleTests extends TestCase {

public static Test suite() {
TestSuite suite = new TestSuite(TestingDriversModuleTests.class.getName());
suite.addTest(DriversTests.suite());
return suite;
}

public TestingDriversModuleTests(String name) { super(name); }

}

+ 32
- 0
testing-drivers/testsrc/org/aspectj/testing/drivers/DriversTests.java View File

@@ -0,0 +1,32 @@
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/


package org.aspectj.testing.drivers;

import junit.framework.*;

public class DriversTests extends TestCase {

public static Test suite() {
TestSuite suite = new TestSuite(DriversTests.class.getName());
// for now, do not include SuiteTest because it would take 15 minutes
//$JUnit-BEGIN$
suite.addTestSuite(HarnessSelectionTest.class);
//$JUnit-END$
return suite;
}

public DriversTests(String name) { super(name); }

}

+ 286
- 0
testing-drivers/testsrc/org/aspectj/testing/drivers/HarnessSelectionTest.java View File

@@ -0,0 +1,286 @@
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/

package org.aspectj.testing.drivers;

import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.MessageHandler;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.testing.drivers.Harness.RunResult;
import org.aspectj.testing.harness.bridge.AbstractRunSpec;
import org.aspectj.testing.harness.bridge.AjcTest;
import org.aspectj.testing.harness.bridge.AjcTest.Spec;
import org.aspectj.testing.run.IRunStatus;
import org.aspectj.testing.run.RunValidator;
import org.aspectj.testing.util.BridgeUtil;
import org.aspectj.testing.util.RunUtils;
import org.aspectj.testing.xml.AjcSpecXmlReader;
import org.aspectj.util.LangUtil;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.List;

import junit.framework.TestCase;

/**
*
*/
public class HarnessSelectionTest extends TestCase {
private static final String SELECT
= "testdata/incremental/harness/selectionTest.xml";
/** @see testIncrementalSuite() */
private static final String INCREMENTAL
= "testdata/incremental/harness/suite.xml";
private static Hashtable SPECS = new Hashtable();
private static AjcTest.Suite.Spec getSpec(String suiteFile) {
AjcTest.Suite.Spec result = (AjcTest.Suite.Spec) SPECS.get(suiteFile);
if (null == result) {
try {
result = AjcSpecXmlReader.getReader().readAjcSuite(new File(suiteFile));
SPECS.put(suiteFile, result);
} catch (IOException e) {
e.printStackTrace(System.err);
}
}
return result;
}
private boolean verbose;

public HarnessSelectionTest(String name) {
super(name);
}
public void testIncrementalSuite() {
if (!eclipseAvailable()) {
System.err.println("skipping test - eclipse classes not available");
return;
}
String[] options = new String[]
{ "!verbose", "!eclipse",
};
Exp exp = new Exp(8, 8, 0, 8, 0, 0, 0);
checkSelection(INCREMENTAL, options, "INFIX IGNORED", exp);
}
public void testKeywordSelectionBoth() {
if (!eclipseAvailable()) {
System.err.println("skipping test - eclipse classes not available");
return;
}
String[] options = new String[]
{ "-ajctestRequireKeywords=requireKeyword",
"-ajctestSkipKeywords=skipKeyword",
"!verbose",
"-eclipse",
};
Exp exp = new Exp(17, 1, 16, 1, 0, 0, 1);
checkSelection(SELECT, options, "keyword skipKeyword was found", exp);
}
public void testKeywordSelectionRequire() {
if (!eclipseAvailable()) {
System.err.println("skipping test - eclipse classes not available");
return;
}
String[] options = new String[]
{ "-ajctestRequireKeywords=skipKeyword",
"!verbose",
"-eclipse",
};
Exp exp = new Exp(17, 1, 16, 1, 0, 0, 16);
checkSelection(SELECT, options, "keyword skipKeyword was not found", exp);
}

public void testKeywordSelectionSkip() {
if (!eclipseAvailable()) {
System.err.println("skipping test - eclipse classes not available");
return;
}
String[] options = new String[]
{ "-ajctestSkipKeywords=requireKeyword",
"!verbose",
"-eclipse",
};
Exp exp = new Exp(17, 0, 17, 0, 0, 0, 17);
checkSelection(SELECT, options, "keyword requireKeyword was found", exp);
}
public void testNoOptions() {
if (!ajcAvailable()) {
System.err.println("skipping test - ajc classes not available");
return;
}
String[] options = new String[]
{ "!ajc"
};
Exp exp = new Exp(17, 3, 14, 3, 0, 0, 4);
checkSelection(SELECT, options, "normally-valid", exp);
}

public void testEclipseOptionsSkip() {
String[] options = new String[]
{ "-eclipse",
"-ajctestRequireKeywords=eclipseOptionSkip"
};
Exp exp = new Exp(17, 0, 17, 0, 0, 0, 6);
checkSelection(SELECT, options, "no support in eclipse-based compiler", exp);
}
public void testAjcEclipseConflict() {
if (!ajcAvailable()) {
System.err.println("skipping test - ajc classes not available");
return;
}
String[] options = new String[]
{ "!ajc"
};
Exp exp = new Exp(17, 3, 14, 3, 0, 0, 6);
checkSelection(SELECT, options, "conflict between !eclipse and !ajc", exp);
}
public void testEclipseConflict() {
String[] options = new String[]
{ "^eclipse"
};
Exp exp = new Exp(17, 3, 14, 3, 0, 0, 6);
checkSelection(SELECT, options, "conflict between arg=!eclipse and global=^eclipse", exp);
}
public void testSinglePR() {
String[] options = new String[]
{ "-eclipse", "-ajctestPR=100"
};
Exp exp = new Exp(17, 1, 16, 1, 0, 0, 16);
checkSelection(SELECT, options, "bugId required", exp);
}
public void testTwoPR() {
String[] options = new String[]
{ "-eclipse", "-ajctestPR=100,101"
};
Exp exp = new Exp(17, 2, 15, 2, 0, 0, 15);
checkSelection(SELECT, options, "bugId required", exp);
}

/**
* Run the static test suite with the given options.
* @param setupHolder the IMessageHolder for any setup messages
* @return null if setup failed or Harness.RunResult if suite completed.
*/
private Harness.RunResult runSuite(String suiteFile, String[] options, MessageHandler setupHolder) {
AbstractRunSpec.RT runtime = new AbstractRunSpec.RT();
runtime.setOptions(options);
AjcTest.Suite.Spec spec = getSpec(suiteFile);
assertNotNull(spec);
ArrayList kids = spec.getChildren();
assertNotNull(kids);
if ((suiteFile == SELECT) && (17 != kids.size())) {
assertTrue("expected 17 kids, got " + kids.size(), false);
}
if (!spec.adoptParentValues(runtime, setupHolder)) {
return null;
} else {
class TestHarness extends Harness {
public RunResult run(AjcTest.Suite.Spec spec) {
return super.run(spec);
}
}
TestHarness h = new TestHarness();
return h.run(spec);
}
}

class Exp {
public final int tests;
public final int testsRun;
public final int skipped;
public final int passed;
public final int failed;
public final int incomplete;
public final int infix;
Exp(int tests, int testsRun, int skipped, int passed, int failed, int incomplete, int infix) {
this.tests = tests;
this.testsRun = testsRun;
this.skipped = skipped;
this.passed = passed;
this.failed = failed;
this.incomplete = incomplete;
this.infix = infix;
}
}
public void checkSelection(String suiteFile, String[] options, String infoInfix, Exp exp) {
MessageHandler holder = new MessageHandler();
Harness.RunResult result = runSuite(suiteFile, options, holder);
if (verbose) {
MessageUtil.print(System.out, holder, " setup - ");
}
assertNotNull("Harness.RunResult", result);
// XXX sync hack snooping of message text with skip messages, harness
final List skipList = MessageUtil.getMessages(holder, IMessage.INFO, false, "skip");
final int numSkipped = skipList.size();
IRunStatus status = result.status;
assertNotNull(status);
if (verbose) {
RunUtils.print(System.out, "result - ", status);
System.out.println(BridgeUtil.childString(status, numSkipped, result.numIncomplete));
}
assertEquals("skips", exp.skipped, numSkipped);
IRunStatus[] children = status.getChildren();
assertNotNull(children);
assertTrue(children.length + "!= expRun=" + exp.testsRun,
exp.testsRun == children.length);
int actPass = 0;
for (int i = 0; i < children.length; i++) {
if (RunValidator.NORMAL.runPassed(children[i])) {
actPass++;
}
}
if (exp.passed != actPass) {
assertTrue("exp.passed=" + exp.passed + " != actPass=" + actPass, false);
}
if (!LangUtil.isEmpty(infoInfix)) {
int actInfix = MessageUtil.getMessages(holder, IMessage.INFO, false, infoInfix).size();
if (actInfix != exp.infix) {
String s = "for infix \"" + infoInfix
+ "\" actInfix=" + actInfix + " != expInfix=" + exp.infix;
assertTrue(s, false);
}
}
}
private boolean ajcAvailable() { // XXX util
try {
return (null != Class.forName("org.aspectj.compiler.base.JavaCompiler"));
} catch (ClassNotFoundException e) {
return false;
}
}

private boolean eclipseAvailable() { // XXX util
try {
return (null != Class.forName("org.aspectj.ajdt.ajc.AjdtCommand"));
} catch (ClassNotFoundException e) {
return false;
}
}
}

+ 197
- 0
testing-drivers/testsrc/org/aspectj/testing/drivers/SuiteTest.java View File

@@ -0,0 +1,197 @@
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/

package org.aspectj.testing.drivers;

import org.aspectj.bridge.IMessageHolder;
import org.aspectj.bridge.MessageHandler;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.testing.harness.bridge.AbstractRunSpec;
import org.aspectj.testing.harness.bridge.AjcTest;
import org.aspectj.testing.harness.bridge.Sandbox;
import org.aspectj.testing.harness.bridge.Validator;
import org.aspectj.testing.run.IRun;
import org.aspectj.testing.run.IRunIterator;
import org.aspectj.testing.run.RunStatus;
import org.aspectj.testing.run.Runner;
import org.aspectj.testing.util.RunUtils;
import org.aspectj.util.LangUtil;

import java.io.File;

import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestResult;
import junit.framework.TestSuite;

/**
*
*/
public class SuiteTest extends TestCase {
private static final String[] SUITES = new String[]
{ "testdata/incremental/harness/selectionTest.xml",
"../tests/ajcTests.xml"
};
public static Test suite() {
TestSuite suite = new TestSuite();
for (int i = 0; i < SUITES.length; i++) {
suite.addTest(JUnitSuite.suite(SUITES[i]));
}
return suite;
}
public SuiteTest(String name) {
super(name);
}
}

/** adapt ajc test suite to JUnit TestSuite */
class JUnitSuite extends TestSuite {
public static final String DEFAULT_SUITE = "../tests/ajcTests.xml";
public static final String[] DEFAULT_OPTIONS = new String[]
{ "-eclipse", "-hideStreams", "-logMinFail" };

static TestSuite suite() {
return suite(DEFAULT_SUITE);
}

static TestSuite suite(String path, String[] options, boolean verbose) {
return new JUnitSuite(path, options, verbose);
}

static TestSuite suite(String path) {
return new JUnitSuite(path, DEFAULT_OPTIONS, true);
}

private final Runner runner;

private boolean loadedTestCases;
private JUnitSuite(String suiteFile, String[] options, boolean verbose) {
super(suiteFile);
runner = new Runner();
loadTestCases(suiteFile, options, verbose);
}
public void runTest(Test test, TestResult result) {
if (!(test instanceof JUnitRunAdapter)) {
test.run(result);
return;
}
RunStatus status = new RunStatus(new MessageHandler(), runner);
result.startTest(test);
IRun testRun = ((JUnitRunAdapter) test).run;
try {
runner.run(testRun, status, null);
if (!status.runResult()) {
RunUtils.VERBOSE_PRINTER.printRunStatus(System.out, status);
AssertionFailedError failure = new AssertionFailedError(""+status);
result.addFailure(test, failure);
}
} finally {
result.endTest(test);
if (testRun instanceof AjcTest) {
AjcTest ajcTest = (AjcTest) testRun;
}
}
}
private void loadTestCases(String suiteFile, String[] options, boolean verbose) {
if (loadedTestCases) { // guard that cleanup is last
throw new IllegalStateException("already loaded test cases");
}
loadedTestCases = true;
final SuiteReader reader = new SuiteReader();
final Validator validator = new Validator(new MessageHandler());
AjcTest.Suite.Spec spec = reader.readSuite(new File(suiteFile));
if (null == spec) {
return;
}
IMessageHolder holder = new MessageHandler();
final AbstractRunSpec.RT parentValues = new AbstractRunSpec.RT();
parentValues.setOptions(options);
parentValues.setVerbose(verbose);
spec.adoptParentValues(parentValues, holder);
if (0 < holder.numMessages(null, true)) {
System.err.println("init: messages adopting options ");
MessageUtil.print(System.err, holder, "init: ");
holder = new MessageHandler();
}
final RunStatus status = new RunStatus(holder, runner);
status.setIdentifier(spec);
final Sandbox sandbox = new Sandbox(spec.getSuiteDirFile(), validator);
int i = 0;
System.out.println("-- loading tests");
for (IRunIterator tests = spec.makeRunIterator(sandbox, validator);
tests.hasNextRun();) {
final IRun run = tests.nextRun(holder, runner);
if (0 < holder.numMessages(null, true)) {
System.err.println(i + ": messages loading " + run);
MessageUtil.print(System.err, holder, i + ": ");
holder = new MessageHandler();
} else if (null == run) {
System.err.println(i + ": null run ");
} else {
addTest(new JUnitRunAdapter(run));
}
System.out.print(".");
i++;
if ((i % 50) == 0) {
System.out.println(" -- " + i);
}
}
System.out.println("-- done loading tests for this suite");
// add a cleanup test
addTest(new Test() {
public int countTestCases() { return 1;}
public void run(TestResult result) {
result.startTest(this);
validator.deleteTempFiles(false);
result.endTest(this);
}
public String toString() { return "validator cleanup"; }
});
}

/** just opens up access, protected to public */
static class SuiteReader extends Harness {
public AjcTest.Suite.Spec readSuite(File suiteFile) {
return super.readSuite(suiteFile);
}

}
/** non-functional wrapper for the enclosed IRun */
public static class JUnitRunAdapter implements Test {
static final UnsupportedOperationException EX =
new UnsupportedOperationException("");
public final IRun run;
public JUnitRunAdapter(IRun run) {
LangUtil.throwIaxIfNull(run, "run");
this.run = run;
}
public final void run(TestResult result) {
throw EX;
}
public final int countTestCases() {
return 1;
}
public String toString() {
return run.toString();
}

}
}

Loading…
Cancel
Save