exercism / java-test-runner

GNU Affero General Public License v3.0
9 stars 13 forks source link

Investigate the source of unrelated warnings when solution does not compile #79

Closed sanderploegsma closed 7 months ago

sanderploegsma commented 7 months ago

For some reason the diagnostics output from the compiler contains warnings that are not related to the submitted solution when it fails to compile. An example of this can be seen in the output of the solution-file-empty smoke test:

./src/test/java/LeapTest.java:10: error: cannot find symbol
    private Leap leap;
            ^
  symbol:   class Leap
  location: class LeapTestwarning: unknown enum constant org.apiguardian.api.API.Status.STABLE
  reason: class file for org.apiguardian.api.API$Status not foundwarning: unknown enum constant org.apiguardian.api.API.Status.STABLEwarning: unknown enum constant org.apiguardian.api.API.Status.STABLE./src/test/java/LeapTest.java:14: error: cannot find symbol
        leap = new Leap();
                   ^
  symbol:   class Leap
  location: class LeapTest

The following part should not be there:

warning: unknown enum constant org.apiguardian.api.API.Status.STABLE
  reason: class file for org.apiguardian.api.API$Status not found
warning: unknown enum constant org.apiguardian.api.API.Status.STABLE
warning: unknown enum constant org.apiguardian.api.API.Status.STABLE

It looks like these errors started happening after migrating the exercises to use JUnit 5. After some googling I did stumble upon https://github.com/junit-team/junit5/issues/1104 but that is already a few years old and should have been fixed in JUnit 5.1.0 while we are on 5.10.0.

sanderploegsma commented 7 months ago

Interestingly, ./gradlew lib:dependencies shows the following dependencies in the runtimeClasspath:

runtimeClasspath - Runtime classpath of source set 'main'.
+--- com.google.auto.value:auto-value-annotations:1.8.2
+--- com.google.guava:guava:30.1.1-jre
|    +--- com.google.guava:failureaccess:1.0.1
|    +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
|    +--- com.google.code.findbugs:jsr305:3.0.2
|    +--- org.checkerframework:checker-qual:3.8.0
|    +--- com.google.errorprone:error_prone_annotations:2.5.1
|    \--- com.google.j2objc:j2objc-annotations:1.3
+--- com.fasterxml.jackson.core:jackson-core:2.12.5 -> 2.12.7
|    \--- com.fasterxml.jackson:jackson-bom:2.12.7
|         +--- com.fasterxml.jackson.core:jackson-annotations:2.12.7 (c)
|         +--- com.fasterxml.jackson.core:jackson-core:2.12.7 (c)
|         +--- com.fasterxml.jackson.core:jackson-databind:2.12.7 -> 2.12.7.1 (c)
|         \--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.7 (c)
+--- com.fasterxml.jackson.core:jackson-databind:2.12.7.1
|    +--- com.fasterxml.jackson.core:jackson-annotations:2.12.7
|    |    \--- com.fasterxml.jackson:jackson-bom:2.12.7 (*)
|    +--- com.fasterxml.jackson.core:jackson-core:2.12.7 (*)
|    \--- com.fasterxml.jackson:jackson-bom:2.12.7 (*)
+--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.5 -> 2.12.7
|    +--- com.fasterxml.jackson.core:jackson-core:2.12.7 (*)
|    +--- com.fasterxml.jackson.core:jackson-databind:2.12.7 -> 2.12.7.1 (*)
|    \--- com.fasterxml.jackson:jackson-bom:2.12.7 (*)
+--- com.github.javaparser:javaparser-core:3.23.0
+--- org.assertj:assertj-core:3.25.1
|    \--- net.bytebuddy:byte-buddy:1.14.11
+--- org.junit:junit-bom:5.10.0
|    +--- org.junit.jupiter:junit-jupiter:5.10.0 (c)
|    +--- org.junit.jupiter:junit-jupiter-engine:5.10.0 (c)
|    +--- org.junit.platform:junit-platform-launcher:1.10.0 (c)
|    +--- org.junit.jupiter:junit-jupiter-api:5.10.0 (c)
|    +--- org.junit.jupiter:junit-jupiter-params:5.10.0 (c)
|    +--- org.junit.platform:junit-platform-engine:1.10.0 (c)
|    \--- org.junit.platform:junit-platform-commons:1.10.0 (c)
+--- org.junit.jupiter:junit-jupiter -> 5.10.0
|    +--- org.junit:junit-bom:5.10.0 (*)
|    +--- org.junit.jupiter:junit-jupiter-api:5.10.0
|    |    +--- org.junit:junit-bom:5.10.0 (*)
|    |    +--- org.opentest4j:opentest4j:1.3.0
|    |    \--- org.junit.platform:junit-platform-commons:1.10.0
|    |         \--- org.junit:junit-bom:5.10.0 (*)
|    +--- org.junit.jupiter:junit-jupiter-params:5.10.0
|    |    +--- org.junit:junit-bom:5.10.0 (*)
|    |    \--- org.junit.jupiter:junit-jupiter-api:5.10.0 (*)
|    \--- org.junit.jupiter:junit-jupiter-engine:5.10.0
|         +--- org.junit:junit-bom:5.10.0 (*)
|         +--- org.junit.platform:junit-platform-engine:1.10.0
|         |    +--- org.junit:junit-bom:5.10.0 (*)
|         |    +--- org.opentest4j:opentest4j:1.3.0
|         |    \--- org.junit.platform:junit-platform-commons:1.10.0 (*)
|         \--- org.junit.jupiter:junit-jupiter-api:5.10.0 (*)
+--- org.junit.platform:junit-platform-launcher -> 1.10.0
|    +--- org.junit:junit-bom:5.10.0 (*)
|    \--- org.junit.platform:junit-platform-engine:1.10.0 (*)
+--- org.junit.jupiter:junit-jupiter-engine -> 5.10.0 (*)
+--- org.json:json:20190722
\--- io.reactivex.rxjava2:rxjava:2.2.12
     \--- org.reactivestreams:reactive-streams:1.0.2

Note the absence of org.apiguardian:apiguardian-api:1.1.2, which should be there as a transitive dependency of org.junit.jupiter:junit-jupiter-api:5.10.0.

sanderploegsma commented 7 months ago

Right, it looks like the org.apiguardian:apiguardian-api:1.1.2 dependency scope was changed to compileOnly by the JUnit team, which explains why it's not there on our classpath. Solution would be to include it ourselves with another scope so that it is also present at runtime.

https://github.com/junit-team/junit5/commit/c5ee49d1347bdab01b7e72d6aa61a0e3c1a9065b