Karm / mandrel-integration-tests

Integration tests for GraalVM and its Mandrel distribution. Runs Quarkus, Helidon and Micronaut applications and small targeted reproducers. The focus is solely on native-image utility and compilation of Java applications into native executables.
Apache License 2.0
5 stars 3 forks source link

Adds minJDK and maxJDK to IfMandrelVersion annotation #88

Closed Karm closed 2 years ago

Karm commented 2 years ago

Tested examples:

    @Test
    @Tag("jdkVersionTest")
    @Order(1)
    @IfMandrelVersion(min = "21.3.1")
    public void jdkVersionCheckA(TestInfo testInfo) {
        System.out.println("KARM Running test "+testInfo.getTestMethod());
    }

    @Test
    @Tag("jdkVersionTest")
    @Order(2)
    @IfMandrelVersion(min = "21.3.1", minJDK = "17")
    public void jdkVersionCheckB(TestInfo testInfo) {
        System.out.println("KARM Running test "+testInfo.getTestMethod());
    }

    @Test
    @Tag("jdkVersionTest")
    @Order(3)
    @IfMandrelVersion(min = "22", minJDK = "17")
    public void jdkVersionCheckC(TestInfo testInfo) {
        System.out.println("KARM Running test "+testInfo.getTestMethod());
    }

    @Test
    @Tag("jdkVersionTest")
    @Order(4)
    @IfMandrelVersion(min = "22", minJDK = "17.0.2")
    public void jdkVersionCheckD(TestInfo testInfo) {
        System.out.println("KARM Running test "+testInfo.getTestMethod());
    }

    @Test
    @Tag("jdkVersionTest")
    @Order(5)
    @IfMandrelVersion(min = "22", minJDK = "17", maxJDK = "17.0.2")
    public void jdkVersionCheckE(TestInfo testInfo) {
        System.out.println("KARM Running test "+testInfo.getTestMethod());
    }

    @Test
    @Tag("jdkVersionTest")
    @Order(6)
    @IfMandrelVersion(min = "21", minJDK = "11.0.12", maxJDK = "17.0.1")
    public void jdkVersionCheckF(TestInfo testInfo) {
        System.out.println("KARM Running test "+testInfo.getTestMethod());
    }

    @Test
    @Tag("jdkVersionTest")
    @Order(7)
    @IfMandrelVersion(min = "21", maxJDK = "11")
    public void jdkVersionCheckG(TestInfo testInfo) {
        System.out.println("KARM Running test "+testInfo.getTestMethod());
    }
Karm commented 2 years ago

LGTM, Thanks @Karm .

One question though, why don't you include the unit tests in the PR as well?

I didn't want to fall into the rabbit hole of mocking classes or providing fake native-image command on PATH to properly test the test suite. The annotation is evaluated early. You gently pushed me into that rabbit hole now, so I'll try to include those tests without adding much overhead... :-D

Karm commented 2 years ago

@zakkak Tests added: https://github.com/Karm/mandrel-integration-tests/pull/88/files#diff-85646c56861bc740418a91c2da8cc67d41ce46b7cf583216e71e50f1d64e8de0

It creates a fake native-image command that spits out one predefined version. Test methods run (or don't run) accordingly. Log file is verified (only the expected subset of test methods should have written to that file).

Karm commented 2 years ago
Error:  org.graalvm.tests.integration.utils.versions.VersionsTest  Time elapsed: 0.078 s  <<< ERROR!
java.nio.file.NoSuchFileException: C:\Users\RUNNER~1\AppData\Local\Temp\versions-log
    at org.graalvm.tests.integration.utils.versions.VersionsTest.teardown(VersionsTest.java:77)

Hmm, it passes just fine on my Windows VM, so this might be some GH setup...like "don't use Temp" ?

Karm commented 2 years ago

I see what's wrong. One cannot run it with the rest of the tests, because org.graalvm.tests.integration.utils.versions.UsedVersion is immutably set an the fake native-image version is then used for the rest of the TS.

I will make a separate GH workflow just for this.

Karm commented 2 years ago
cp: cannot create regular file '/home/runner/.m2/settings.xml': No such file or directory
Error: Process completed with exit code 1.

?

Karm commented 2 years ago

Finally O.K. Squashed.