Skip to content

Commit

Permalink
Introduce helpers for executables and shared libs.
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Oct 16, 2023
1 parent 7095f29 commit b133492
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand All @@ -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")
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -73,6 +64,6 @@ class JavaLibraryFunctionalTest extends AbstractFunctionalTest {
outputContains "--shared"

and:
library.exists()
sharedLibrary.exists()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit b133492

Please sign in to comment.