Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce Time Required for Each Test Execution #531

Merged
merged 2 commits into from Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -225,7 +225,7 @@ class JavaApplicationFunctionalTest extends AbstractFunctionalTest {
def pgoFile = file("build/native/nativeCompile/default.iprof")

given:
withSample("java-application")
withSample("java-application", false)
buildFile << """
graalvmNative {
useArgFile = false // required to check for --pgo flag
Expand Down
Expand Up @@ -48,7 +48,7 @@ class MultiProjectJavaApplicationWithTestsFunctionalTest extends AbstractFunctio
@Unroll("transitive dependencies are included when testing with JUnit Platform #junitVersion")
def "transitive dependencies are included when testing"() {
given:
withSample("multi-project-with-tests")
withSample("multi-project-with-tests", false)

when:
run 'nativeTest'
Expand Down
Expand Up @@ -137,9 +137,19 @@ abstract class AbstractFunctionalTest extends Specification {
Files.createDirectory(testDirectory)
}

protected void withSample(String name) {
protected void withSample(String name, boolean quickBuildMode = true) {
File sampleDir = new File("../samples/$name")
FileUtils.copyDirectory(sampleDir.toPath(), testDirectory)

if (quickBuildMode) {
buildFile << """
graalvmNative {
binaries.all {
buildArgs.add("-Ob")
}
}
""".stripIndent()
}
}

void run(String... args) {
Expand Down
Expand Up @@ -66,7 +66,7 @@ class JavaApplicationFunctionalTest extends AbstractGraalVMMavenFunctionalTest {
withSample("java-application")

when:
mvn '-Pnative', '-DskipTests', 'package', 'exec:exec@native'
mvn '-Pnative', '-DquickBuild', '-DskipTests', 'package', 'exec:exec@native'

then:
buildSucceeded
Expand All @@ -77,7 +77,7 @@ class JavaApplicationFunctionalTest extends AbstractGraalVMMavenFunctionalTest {
withSample("java-application")

when:
mvn '-Pshaded', '-DskipTests', 'package', 'exec:exec@native'
mvn '-Pshaded', '-DquickBuild', '-DskipTests', 'package', 'exec:exec@native'

then:
buildSucceeded
Expand All @@ -90,7 +90,7 @@ class JavaApplicationFunctionalTest extends AbstractGraalVMMavenFunctionalTest {
withSample("java-application")

when:
mvn '-Pnative', '-DskipTests', 'package', 'exec:exec@native', "-DuseArgFile=${argFile}"
mvn '-Pnative', '-DquickBuild', '-DskipTests', 'package', 'exec:exec@native', "-DuseArgFile=${argFile}"

then:
buildSucceeded
Expand All @@ -104,7 +104,7 @@ class JavaApplicationFunctionalTest extends AbstractGraalVMMavenFunctionalTest {
withSample("java-application-with-custom-packaging")

when:
mvnDebug 'package', '-Dpackaging=native-image', 'exec:exec@native'
mvnDebug '-DquickBuild', 'package', '-Dpackaging=native-image', 'exec:exec@native'

then:
buildSucceeded
Expand All @@ -116,7 +116,7 @@ class JavaApplicationFunctionalTest extends AbstractGraalVMMavenFunctionalTest {
withSample("java-application")

when:
mvn '-Pnative', 'native:write-args-file'
mvn '-DquickBuild', '-Pnative', 'native:write-args-file'

then:
buildSucceeded
Expand Down
Expand Up @@ -54,7 +54,7 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
when:
// Run Maven in debug mode (-X) in order to capture the command line arguments
// used to launch Surefire with the agent.
mvnDebug '-Pnative', 'test', '-Dagent=true', '-DskipNativeTests'
mvnDebug '-Pnative', '-DquickBuild', 'test', '-Dagent=true', '-DskipNativeTests'

then:
// Agent is used with Surefire
Expand All @@ -81,10 +81,10 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
def "test agent with metadata copy task"() {
given:
withSample("java-application-with-reflection")
mvn'-Pnative', '-DskipNativeBuild=true', 'package', '-Dagent=true', 'exec:exec@java-agent'
mvn'-Pnative', '-DquickBuild', '-DskipNativeBuild=true', 'package', '-Dagent=true', 'exec:exec@java-agent'

when:
mvn'-Pnative', '-DskipNativeTests', '-Dagent=true', 'native:metadata-copy'
mvn'-Pnative', '-DquickBuild', '-DskipNativeTests', '-Dagent=true', 'native:metadata-copy'

then:
buildSucceeded
Expand All @@ -98,10 +98,10 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
def "test agent with metadata copy task and disabled stages"() {
given:
withSample("java-application-with-reflection")
mvn'-PagentConfigurationWithDisabledStages', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'
mvn'-PagentConfigurationWithDisabledStages', '-DquickBuild', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'

when:
mvn '-PagentConfigurationWithDisabledStages', '-DskipNativeTests', 'native:metadata-copy'
mvn '-PagentConfigurationWithDisabledStages', '-DquickBuild', '-DskipNativeTests', 'native:metadata-copy'

then:
buildSucceeded
Expand All @@ -116,10 +116,10 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
def "test agent in direct mode with metadata copy task"() {
given:
withSample("java-application-with-reflection")
mvn'-PagentConfigurationDirectMode', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'
mvn'-PagentConfigurationDirectMode', '-DquickBuild', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'

when:
mvn '-PagentConfigurationDirectMode', '-DskipNativeTests', 'native:metadata-copy'
mvn '-PagentConfigurationDirectMode', '-DquickBuild', '-DskipNativeTests', 'native:metadata-copy'

then:
buildSucceeded
Expand All @@ -132,10 +132,10 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
def "test agent in conditional mode with metadata copy task"() {
given:
withSample("java-application-with-reflection")
mvn '-PagentConfigurationConditionalMode', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'
mvn '-PagentConfigurationConditionalMode', '-DquickBuild', '-DskipNativeBuild=true', 'package', 'exec:exec@java-agent'

when:
mvn '-PagentConfigurationConditionalMode', '-DskipNativeTests', 'native:metadata-copy'
mvn '-PagentConfigurationConditionalMode', '-DquickBuild', '-DskipNativeTests', 'native:metadata-copy'

then:
buildSucceeded
Expand All @@ -149,7 +149,7 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
withSample("java-application-with-reflection")

when:
mvn'-PnoAgentConfiguration', 'package'
mvn'-PnoAgentConfiguration', '-DquickBuild', 'package'

then:
buildSucceeded
Expand All @@ -160,7 +160,7 @@ class JavaApplicationWithAgentFunctionalTest extends AbstractGraalVMMavenFunctio
withSample("java-application-with-reflection")

when:
mvn '-Pnative', '-Dagent=false', 'test'
mvn '-Pnative', '-DquickBuild', '-Dagent=false', 'test'

then:
outputContains """
Expand Down
Expand Up @@ -25,7 +25,7 @@ class JavaApplicationWithResourcesFunctionalTest extends AbstractGraalVMMavenFun
}

when:
mvn(['-Pnative', '-DskipTests', *options, 'package', 'exec:exec@native'])
mvn(['-Pnative', '-DquickBuild', '-DskipTests', *options, 'package', 'exec:exec@native'])

then:
buildSucceeded
Expand Down Expand Up @@ -69,7 +69,7 @@ class JavaApplicationWithResourcesFunctionalTest extends AbstractGraalVMMavenFun
}

when:
mvn(['-Pnative', 'test', *options])
mvn(['-Pnative', '-DquickBuild', 'test', *options])

then:
buildSucceeded
Expand Down
Expand Up @@ -49,7 +49,7 @@ class JavaApplicationWithTestsFunctionalTest extends AbstractGraalVMMavenFunctio
withSample("java-application-with-tests")

when:
mvn '-Pnative', 'test'
mvn '-Pnative', '-DquickBuild', 'test'

then:
buildSucceeded
Expand All @@ -74,7 +74,7 @@ class JavaApplicationWithTestsFunctionalTest extends AbstractGraalVMMavenFunctio
withSample("java-application-with-tests")

when:
mvn '-Pshaded', 'integration-test'
mvn '-Pshaded', '-DquickBuild', 'integration-test'

then:
buildSucceeded
Expand All @@ -100,7 +100,7 @@ class JavaApplicationWithTestsFunctionalTest extends AbstractGraalVMMavenFunctio
withSample("java-application-with-tests")

when:
mvn '-Pnative', 'test', '-DskipTests'
mvn '-Pnative', '-DquickBuild', 'test', '-DskipTests'

then:
buildSucceeded
Expand All @@ -114,7 +114,7 @@ class JavaApplicationWithTestsFunctionalTest extends AbstractGraalVMMavenFunctio
withSample("java-application-with-tests")

when:
mvn '-Pnative', 'test', '-DskipNativeTests'
mvn '-Pnative', '-DquickBuild', 'test', '-DskipNativeTests'

then:
buildSucceeded
Expand All @@ -129,7 +129,7 @@ class JavaApplicationWithTestsFunctionalTest extends AbstractGraalVMMavenFunctio
withSample("java-application-with-tests")

when:
mvn '-Pnative', '-Ptest-variables', 'test'
mvn '-Pnative', '-DquickBuild', '-Ptest-variables', 'test'

then:
buildSucceeded
Expand All @@ -146,7 +146,7 @@ class JavaApplicationWithTestsFunctionalTest extends AbstractGraalVMMavenFunctio
withSample("multi-project-with-tests")

when:
mvn 'package'
mvn '-DquickBuild', 'package'

then:
buildSucceeded
Expand Down
Expand Up @@ -57,7 +57,7 @@ class JavaLibraryFunctionalTest extends AbstractGraalVMMavenFunctionalTest {
def library = file("target/java-library" + libExt)

when:
mvn '-Pnative', '-DskipTests', 'package', '-DuseArgFile=false'
mvn '-Pnative', '-DquickBuild', '-DskipTests', 'package', '-DuseArgFile=false'

then:
buildSucceeded
Expand Down
Expand Up @@ -50,7 +50,7 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
withSample("native-config-integration")

when:
mvn '-Pnative', '-DskipTests', 'package', 'exec:exec@native'
mvn '-Pnative', '-DquickBuild', '-DskipTests', 'package', 'exec:exec@native'

then:
buildSucceeded
Expand All @@ -62,7 +62,7 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
withSample("native-config-integration")

when:
mvn '-Pnative,metadataLocal', '-DskipTests', 'package', 'exec:exec@native'
mvn '-Pnative,metadataLocal', '-DquickBuild', '-DskipTests', 'package', 'exec:exec@native'

then:
buildSucceeded
Expand Down Expand Up @@ -92,7 +92,7 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
withSample("native-config-integration")

when:
mvn '-Pnative,metadataMissing', '-DskipTests', 'package', 'exec:exec@native'
mvn '-Pnative,metadataMissing', '-DquickBuild', '-DskipTests', 'package', 'exec:exec@native'

then:
buildSucceeded
Expand All @@ -105,7 +105,7 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
withSample("native-config-integration")

when:
mvn '-Pnative,metadataExclude', '-DskipTests', 'package', 'exec:exec@native'
mvn '-Pnative,metadataExclude', '-DquickBuild', '-DskipTests', 'package', 'exec:exec@native'

then:
buildSucceeded
Expand All @@ -117,7 +117,7 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
withSample("native-config-integration")

when:
mvn '-Pnative,metadataForceVersion', '-DskipTests', 'package', 'exec:exec@native'
mvn '-Pnative,metadataForceVersion', '-DquickBuild','-DskipTests', 'package', 'exec:exec@native'

then:
buildSucceeded
Expand All @@ -130,7 +130,7 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
withSample("native-config-integration")

when:
mvn '-Pnative,metadataArchive', '-DrepoFormat=zip', '-DskipTests', 'package', 'exec:exec@native'
mvn '-Pnative,metadataArchive', '-DquickBuild', '-DrepoFormat=zip', '-DskipTests', 'package', 'exec:exec@native'

then:
buildSucceeded
Expand All @@ -149,7 +149,7 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
withLocalServer()

when:
mvn '-Pnative,metadataUrl', "-Dmetadata.url=http://localhost:${localServerPort}/target/repo.zip", '-DskipTests', 'package', 'exec:exec@native'
mvn '-Pnative,metadataUrl', '-DquickBuild', "-Dmetadata.url=http://localhost:${localServerPort}/target/repo.zip", '-DskipTests', 'package', 'exec:exec@native'

then:
buildSucceeded
Expand All @@ -169,7 +169,7 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
withLocalServer()

when:
mvn '-Pnative,metadataUrl', "-Dmetadata.url=https://google.com/notfound", '-DskipTests', 'package', 'exec:exec@native'
mvn '-Pnative,metadataUrl', '-DquickBuild', "-Dmetadata.url=https://google.com/notfound", '-DskipTests', 'package', 'exec:exec@native'

then:
buildSucceeded
Expand All @@ -182,7 +182,7 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes
withSample("native-config-integration")

when:
mvn '-X', '-PaddMetadataHints', '-DskipTests', 'package'
mvn '-X', '-PaddMetadataHints', '-DquickBuild', '-DskipTests', 'package'

then:
buildSucceeded
Expand Down
Expand Up @@ -50,7 +50,7 @@ class OfficialMetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunct
withSample("metadata-repo-integration")

when:
mvn '-Pnative', '-DskipTests', 'package', 'exec:exec@native'
mvn '-Pnative', '-DquickBuild', '-DskipTests', 'package', 'exec:exec@native'

then:
buildSucceeded
Expand All @@ -70,7 +70,7 @@ class OfficialMetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunct
withSample("metadata-repo-integration")

when:
mvn '-PnativeVersioned', '-DskipTests', 'package', 'exec:exec@native'
mvn '-PnativeVersioned', '-DquickBuild', '-DskipTests', 'package', 'exec:exec@native'

then:
buildSucceeded
Expand Down