-
Notifications
You must be signed in to change notification settings - Fork 132
ECJ Testing
< JDT Core Programmer Guide | ECJ
For testing the compiler it is not necessary to ever run a maven build.
Running org.eclipse.jdt.core.tests.RunCompilerTests
(or any of its
constituents) as a JUnit (3) Plug-in Test suffices. For faster
launching, open the "Main" page of the run dialog and choose "Headless
Mode" as the application.
For selectively running only a single test method, or a group of
test methods, see that each test class has a static block with a
commented assignment to TEST_NAMES
and similar. Uncomment and insert
the name of the desired test and run the class. Note, that the given
name will be used for prefix-matching, so tests testMethod1
, ...
testMethod13
can all be run by specifying "testMethod"
. Please try
not to commit this change of TEST_NAMES
.
Specify at which compliance levels a test should be run by adding a VM argument like this (using a comma separated list of values):
-Dcompliance=1.8,14
Some compiler tests not only compile but also execute the compiled class files. For those ensure that the test is executed on a JRE that is the same or newer as the newest compliance level specified.
Not specifying a compliance level causes the tests to be executed for each supported compliance level compatible with the current running JRE, which can be very time consuming.
This special test mode is used to compare the behaviors of ecj and javac.
As of https://github.com/eclipse-jdt/eclipse.jdt.core/issues/386 we have two levels of enabling:
-
-Drun.javac=enabled
will enable this mode for the entire compiler test suite -
-Drun.javac=optin
enables this mode only for "blessed" classes that opt in to the mode. (this is done by settingAbstractCompilerTest.runJavacOptIn
to true in asetUp()
method).
If nothing else is specified, setting run.javac
will pick up javac
from the JDK running the tests.
You may optionally specify a different JDK by saying
-
-Djdk.root=<path-to-jdk>
-- to specify exactly one JDK -
-Djdk.roots=<paths-separated-by-pathseparator>
-- to specify a list of JDKs
In any case, any version of javac will only be run when the current test compliance matches the version of javac. So, for effective run.javac mode, also -Dcompliance=...
is relevant.
Dedicated Jenkins jobs exist to test in this mode for different compliance levels:
- eclipse.jdt.core-run.javac-12 -- essentially defunct, too many errors reports
- eclipse.jdt.core-run.javac-23 -- running in opt-in mode, so only selected classes will be tested against javac.
The active job is triggered once per week (on weekends).
- A historic record of differences can be found in bug 404648#c121.
- For a while the umbrella for known differences was bug 564617.
- Currently we have https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2959 for this.
Known differences are documented using constants of type
org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.JavacTestOptions.Excuse
during test invocation. For conveniently passing the correct "Excuse" in
each affected test, it is recommended to use class "Runner" as shown
below, and its field
javacTestOptions
.
Flow analysis has separate implementations for the first 64 variables and subsequent ("extra") variables. Since most tests only exercise the first implementation, a mode has been added to explicitly test the second implementation (by faking 64 additional variables).
-Djdt.flow.test.extra=true
For better test coverage, this mode is enabled for one of the time-scheduled jobs: eclipse.jdt.core-run.javac-10
Since that job is known to fail, watching for regressions of this job is particularly relevant.
A few JDT tests include some sort of performance assertions, ideally not tied to specific wall time thresholds, but testing the characteristics at which complexity grows (linearly vs. O(2^n) etc).
Since these tests frequently fail on the fluctuating jenkins infrastructure of gerrit jobs, those assertions are disabled for gerrit:
-Djdt.performance.asserts=disabled
Other test runs still keep them enabled (the default).
When new performance-related tests are added to the suite, they should
guard their performance assertions under the same flag, in code
accessible as
org.eclipse.jdt.core.tests.util.AbstractCompilerTest.PERFORMANCE_ASSERTS
.
This property will tell the test suite to create test files in a non-standard location (otherwise files will be created below the default temp dir).
Inside each test method of the compiler test suite, an invocation like
runConformTest
, runNegativeTest
passes the source file and
additional parameters to the actual testing infra structure.
Traditionally, a myriad of overloads of these methods has been created to accommodate the needs of different tests, which makes picking the appropriate method tedious and still uninteresting parameters have to be provided in many cases.
More recently, class
org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.Runner
has been created to enable providing exactly the relevant test
parameters before invoking one of the run*Test()
methods.