diff --git a/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaApplicationFunctionalTest.groovy b/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaApplicationFunctionalTest.groovy index ec8b25587..028195c77 100644 --- a/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaApplicationFunctionalTest.groovy +++ b/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaApplicationFunctionalTest.groovy @@ -51,7 +51,7 @@ import java.nio.file.Files class JavaApplicationFunctionalTest extends AbstractFunctionalTest { def "can build a native image for a simple application"() { - def nativeApp = file("build/native/nativeCompile/java-application") + def nativeApp = getExecutableFile("build/native/nativeCompile/java-application") debug = true given: @@ -85,7 +85,7 @@ class JavaApplicationFunctionalTest extends AbstractFunctionalTest { @Issue("https://github.com/graalvm/native-build-tools/issues/129") def "can build a native image with dependencies only needed by native image"() { - def nativeApp = file("build/native/nativeCompile/java-application") + def nativeApp = getExecutableFile("build/native/nativeCompile/java-application") given: withSample("java-application-with-extra-sourceset") @@ -119,7 +119,7 @@ class JavaApplicationFunctionalTest extends AbstractFunctionalTest { }) @Ignore("Need to find another way to test this since toolchains will now always be evaluated early") def "can override toolchain selection"() { - def nativeApp = file("build/native/nativeCompile/java-application") + def nativeApp = getExecutableFile("build/native/nativeCompile/java-application") given: withSample("java-application") @@ -178,7 +178,7 @@ class JavaApplicationFunctionalTest extends AbstractFunctionalTest { } and: - def nativeApp = file("build/native/nativeCompile/java-application") + def nativeApp = getExecutableFile("build/native/nativeCompile/java-application") nativeApp.exists() when: @@ -191,7 +191,7 @@ class JavaApplicationFunctionalTest extends AbstractFunctionalTest { @Issue("https://github.com/graalvm/native-build-tools/issues/275") def "can pass environment variables to the builder process"() { - def nativeApp = file("build/native/nativeCompile/java-application") + def nativeApp = getExecutableFile("build/native/nativeCompile/java-application") given: withSample("java-application") @@ -221,7 +221,7 @@ class JavaApplicationFunctionalTest extends AbstractFunctionalTest { @IgnoreIf({ System.getenv("IS_GRAALVM_DEV_BUILD") }) def "can build a native image with PGO instrumentation"() { def pgoDir = file("src/pgo-profiles/main").toPath() - def nativeApp = file("build/native/nativeCompile/java-application-instrumented") + def nativeApp = getExecutableFile("build/native/nativeCompile/java-application-instrumented") def pgoFile = file("build/native/nativeCompile/default.iprof") given: diff --git a/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaApplicationWithResourcesFunctionalTest.groovy b/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaApplicationWithResourcesFunctionalTest.groovy index e6e38ed5c..8f84ba351 100644 --- a/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaApplicationWithResourcesFunctionalTest.groovy +++ b/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaApplicationWithResourcesFunctionalTest.groovy @@ -46,7 +46,7 @@ import spock.lang.Unroll class JavaApplicationWithResourcesFunctionalTest extends AbstractFunctionalTest { @Unroll("can build an application which uses resources using #pattern with JUnit Platform #junitVersion") def "can build an application which uses resources"() { - def nativeApp = file("build/native/nativeCompile/java-application") + def nativeApp = getExecutableFile("build/native/nativeCompile/java-application") debug = true given: withSample("java-application-with-resources") @@ -196,7 +196,7 @@ graalvmNative { } def "scans resources of jar file even if it includes a native-image/resources-config.json file"() { - def nativeApp = file("build/native/nativeCompile/java-application") + def nativeApp = getExecutableFile("build/native/nativeCompile/java-application") debug = true given: withSample("java-application-with-resources") diff --git a/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaApplicationWithTestsFunctionalTest.groovy b/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaApplicationWithTestsFunctionalTest.groovy index 80a08b7e4..d3f4f3765 100644 --- a/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaApplicationWithTestsFunctionalTest.groovy +++ b/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaApplicationWithTestsFunctionalTest.groovy @@ -49,7 +49,7 @@ import spock.lang.Unroll class JavaApplicationWithTestsFunctionalTest extends AbstractFunctionalTest { @Unroll("can execute tests in a native image with JUnit Platform #junitVersion") def "can build a native image and run it"() { - def nativeTestsApp = file("build/native/nativeTestCompile/java-application-tests") + def nativeTestsApp = getExecutableFile("build/native/nativeTestCompile/java-application-tests") given: withSample("java-application-with-tests") diff --git a/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaLibraryFunctionalTest.groovy b/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaLibraryFunctionalTest.groovy index fcc0d98e3..a4ed3a99a 100644 --- a/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaLibraryFunctionalTest.groovy +++ b/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaLibraryFunctionalTest.groovy @@ -46,16 +46,7 @@ import org.graalvm.buildtools.gradle.fixtures.AbstractFunctionalTest class JavaLibraryFunctionalTest extends AbstractFunctionalTest { def "can build a native image for a simple library"() { - def libExt = "" - if (IS_LINUX) { - libExt = ".so" - } else if (IS_WINDOWS) { - libExt = ".dll" - } else if (IS_MAC) { - libExt = ".dylib" - } - - def library = file("build/native/nativeCompile/java-library" + libExt) + def sharedLibrary = getSharedLibraryFile("build/native/nativeCompile/java-library") debug = true given: @@ -73,6 +64,6 @@ class JavaLibraryFunctionalTest extends AbstractFunctionalTest { outputContains "--shared" and: - library.exists() + sharedLibrary.exists() } } diff --git a/native-gradle-plugin/src/testFixtures/groovy/org/graalvm/buildtools/gradle/fixtures/AbstractFunctionalTest.groovy b/native-gradle-plugin/src/testFixtures/groovy/org/graalvm/buildtools/gradle/fixtures/AbstractFunctionalTest.groovy index aed808f5e..aeb10aa5b 100644 --- a/native-gradle-plugin/src/testFixtures/groovy/org/graalvm/buildtools/gradle/fixtures/AbstractFunctionalTest.groovy +++ b/native-gradle-plugin/src/testFixtures/groovy/org/graalvm/buildtools/gradle/fixtures/AbstractFunctionalTest.groovy @@ -91,6 +91,23 @@ abstract class AbstractFunctionalTest extends Specification { path(pathElements).toFile() } + File getExecutableFile(String path) { + file(IS_WINDOWS ? path + ".exe" : path) + } + + File getSharedLibraryFile(String path) { + def libExt = "" + if (IS_LINUX) { + libExt = ".so" + } else if (IS_WINDOWS) { + libExt = ".dll" + } else if (IS_MAC) { + libExt = ".dylib" + } + assert !libExt.isEmpty(): "Unable to determine shared library extension: unexpected operating system" + file("build/native/nativeCompile/java-library" + libExt) + } + File getGroovyBuildFile() { file("build.gradle") }