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 8f84ba351..fb523b80d 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 @@ -77,7 +77,7 @@ class JavaApplicationWithResourcesFunctionalTest extends AbstractFunctionalTest process.output.contains "Hello, native!" and: - file("build/native/generated/generateResourcesConfigFile/resource-config.json").text == '''{ + matches(file("build/native/generated/generateResourcesConfigFile/resource-config.json"), '''{ "resources" : { "includes" : [ { "pattern" : "\\\\Qmessage.txt\\\\E" @@ -85,7 +85,7 @@ class JavaApplicationWithResourcesFunctionalTest extends AbstractFunctionalTest "excludes" : [ ] }, "bundles" : [ ] -}''' +}''') where: junitVersion = System.getProperty('versions.junit') @@ -151,7 +151,7 @@ graalvmNative { } and: - file("build/native/generated/generateTestResourcesConfigFile/resource-config.json").text == '''{ + matches(file("build/native/generated/generateTestResourcesConfigFile/resource-config.json"), '''{ "resources" : { "includes" : [ { "pattern" : "\\\\Qmessage.txt\\\\E" @@ -161,7 +161,7 @@ graalvmNative { "excludes" : [ ] }, "bundles" : [ ] -}''' +}''') where: junitVersion = System.getProperty('versions.junit') @@ -242,7 +242,7 @@ graalvmNative { nativeApp.exists() and: - file("build/native/generated/generateResourcesConfigFile/resource-config.json").text == '''{ + matches(file("build/native/generated/generateResourcesConfigFile/resource-config.json"), '''{ "resources" : { "includes" : [ { "pattern" : "\\\\Qmessage.txt\\\\E" @@ -250,7 +250,7 @@ graalvmNative { "excludes" : [ ] }, "bundles" : [ ] -}''' +}''') when: def process = execute(nativeApp) diff --git a/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/ReachabilityMetadataFunctionalTest.groovy b/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/ReachabilityMetadataFunctionalTest.groovy index cb5ec6f59..33b733513 100644 --- a/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/ReachabilityMetadataFunctionalTest.groovy +++ b/native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/ReachabilityMetadataFunctionalTest.groovy @@ -59,7 +59,7 @@ class ReachabilityMetadataFunctionalTest extends AbstractFunctionalTest { } and: "has copied metadata file" - file("build/native-reachability-metadata/META-INF/native-image/com.h2database/h2/2.1.210/resource-config.json").text.trim() == '''{ + matches(file("build/native-reachability-metadata/META-INF/native-image/com.h2database/h2/2.1.210/resource-config.json").text.trim(), '''{ "bundles": [], "resources": { "includes": [ @@ -71,7 +71,7 @@ class ReachabilityMetadataFunctionalTest extends AbstractFunctionalTest { } ] } -}''' +}''') and: "has copied reachability-metadata.properties file" file("build/native-reachability-metadata/META-INF/native-image/io.netty/netty-codec-http/4.1.80.Final/reachability-metadata.properties").text.trim() == 'override=true' } diff --git a/native-gradle-plugin/src/test/groovy/org/graalvm/buildtools/gradle/tasks/AbstractPluginTest.groovy b/native-gradle-plugin/src/test/groovy/org/graalvm/buildtools/gradle/tasks/AbstractPluginTest.groovy index 80bbf8059..b603458b3 100644 --- a/native-gradle-plugin/src/test/groovy/org/graalvm/buildtools/gradle/tasks/AbstractPluginTest.groovy +++ b/native-gradle-plugin/src/test/groovy/org/graalvm/buildtools/gradle/tasks/AbstractPluginTest.groovy @@ -199,4 +199,11 @@ abstract class AbstractPluginTest extends Specification { } } + static boolean matches(String actual, String expected) { + normalizeString(actual) == normalizeString(expected) + } + + private static String normalizeString(String input) { + input.replace("\r\n", "\n") + } } diff --git a/native-gradle-plugin/src/test/groovy/org/graalvm/buildtools/gradle/tasks/GenerateResourcesConfigFileTest.groovy b/native-gradle-plugin/src/test/groovy/org/graalvm/buildtools/gradle/tasks/GenerateResourcesConfigFileTest.groovy index 8f2bd3aa6..27b027c93 100644 --- a/native-gradle-plugin/src/test/groovy/org/graalvm/buildtools/gradle/tasks/GenerateResourcesConfigFileTest.groovy +++ b/native-gradle-plugin/src/test/groovy/org/graalvm/buildtools/gradle/tasks/GenerateResourcesConfigFileTest.groovy @@ -51,13 +51,13 @@ class GenerateResourcesConfigFileTest extends AbstractPluginTest { then: with(project) { outputFile.exists() - outputFile.text == '''{ + matches(outputFile.text, '''{ "resources" : { "includes" : [ ], "excludes" : [ ] }, "bundles" : [ ] -}''' +}''') } } @@ -72,7 +72,7 @@ class GenerateResourcesConfigFileTest extends AbstractPluginTest { then: with(project) { outputFile.exists() - outputFile.text == '''{ + matches(outputFile.text, '''{ "resources" : { "includes" : [ ], "excludes" : [ ] @@ -82,7 +82,7 @@ class GenerateResourcesConfigFileTest extends AbstractPluginTest { }, { "name" : "other.bundle" } ] -}''' +}''') } } @@ -98,7 +98,7 @@ class GenerateResourcesConfigFileTest extends AbstractPluginTest { then: with(project) { outputFile.exists() - outputFile.text == '''{ + matches(outputFile.text, '''{ "resources" : { "includes" : [ { "pattern" : "pattern" @@ -112,7 +112,7 @@ class GenerateResourcesConfigFileTest extends AbstractPluginTest { } ] }, "bundles" : [ ] -}''' +}''') } } @@ -127,13 +127,13 @@ class GenerateResourcesConfigFileTest extends AbstractPluginTest { then: with(project) { outputFile.exists() - outputFile.text == '''{ + matches(outputFile.text, '''{ "resources" : { "includes" : [ ], "excludes" : [ ] }, "bundles" : [ ] -}''' +}''') } } @@ -149,7 +149,7 @@ class GenerateResourcesConfigFileTest extends AbstractPluginTest { then: with(project) { outputFile.exists() - outputFile.text == '''{ + matches(outputFile.text, '''{ "resources" : { "includes" : [ { "pattern" : "\\\\Qorg/foo/some/resource.txt\\\\E" @@ -157,7 +157,7 @@ class GenerateResourcesConfigFileTest extends AbstractPluginTest { "excludes" : [ ] }, "bundles" : [ ] -}''' +}''') } } @@ -174,7 +174,7 @@ class GenerateResourcesConfigFileTest extends AbstractPluginTest { then: with(project) { outputFile.exists() - outputFile.text == '''{ + matches(outputFile.text, '''{ "resources" : { "includes" : [ { "pattern" : "\\\\Qorg/foo/some/resource.txt\\\\E" @@ -182,7 +182,7 @@ class GenerateResourcesConfigFileTest extends AbstractPluginTest { "excludes" : [ ] }, "bundles" : [ ] -}''' +}''') } } @@ -198,7 +198,7 @@ class GenerateResourcesConfigFileTest extends AbstractPluginTest { then: with(project) { outputFile.exists() - outputFile.text == '''{ + matches(outputFile.text, '''{ "resources" : { "includes" : [ { "pattern" : "\\\\Qorg/foo/some/resource.txt\\\\E" @@ -206,7 +206,7 @@ class GenerateResourcesConfigFileTest extends AbstractPluginTest { "excludes" : [ ] }, "bundles" : [ ] -}''' +}''') } } @@ -224,13 +224,13 @@ class GenerateResourcesConfigFileTest extends AbstractPluginTest { then: with(project) { outputFile.exists() - outputFile.text == '''{ + matches(outputFile.text, '''{ "resources" : { "includes" : [ ], "excludes" : [ ] }, "bundles" : [ ] -}''' +}''') } } @@ -246,13 +246,13 @@ class GenerateResourcesConfigFileTest extends AbstractPluginTest { then: with(project) { outputFile.exists() - outputFile.text == '''{ + matches(outputFile.text, '''{ "resources" : { "includes" : [ ], "excludes" : [ ] }, "bundles" : [ ] -}''' +}''') } } 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 aeb10aa5b..b480e24dd 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 @@ -169,6 +169,10 @@ abstract class AbstractFunctionalTest extends Specification { assert errorOutput.contains(normalizeString(text)) } + static boolean matches(String actual, String expected) { + normalizeString(actual) == normalizeString(expected) + } + void tasks(@DelegatesTo(value = TaskExecutionGraph, strategy = Closure.DELEGATE_FIRST) Closure spec) { def graph = new TaskExecutionGraph() spec.delegate = graph diff --git a/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationWithResourcesFunctionalTest.groovy b/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationWithResourcesFunctionalTest.groovy index 6125442e3..3fbd42830 100644 --- a/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationWithResourcesFunctionalTest.groovy +++ b/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/JavaApplicationWithResourcesFunctionalTest.groovy @@ -32,7 +32,7 @@ class JavaApplicationWithResourcesFunctionalTest extends AbstractGraalVMMavenFun outputContains "Hello, native!" and: - file("target/native/generated/generateResourceConfig/resource-config.json").text == '''{ + matches(file("target/native/generated/generateResourceConfig/resource-config.json").text, '''{ "resources" : { "includes" : [ { "pattern" : "\\\\Qmessage.txt\\\\E" @@ -40,7 +40,7 @@ class JavaApplicationWithResourcesFunctionalTest extends AbstractGraalVMMavenFun "excludes" : [ ] }, "bundles" : [ ] -}''' +}''') where: detection | includedPatterns | restrictToModules | detectionExclusionPatterns @@ -75,7 +75,7 @@ class JavaApplicationWithResourcesFunctionalTest extends AbstractGraalVMMavenFun buildSucceeded and: - file("target/native/generated/generateTestResourceConfig/resource-config.json").text == '''{ + matches(file("target/native/generated/generateTestResourceConfig/resource-config.json").text, '''{ "resources" : { "includes" : [ { "pattern" : "\\\\Qmessage.txt\\\\E" @@ -85,7 +85,7 @@ class JavaApplicationWithResourcesFunctionalTest extends AbstractGraalVMMavenFun "excludes" : [ ] }, "bundles" : [ ] -}''' +}''') where: detection | includedPatterns | restrictToModules | detectionExclusionPatterns diff --git a/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/MetadataRepositoryFunctionalTest.groovy b/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/MetadataRepositoryFunctionalTest.groovy index 724caaf72..238a1e011 100644 --- a/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/MetadataRepositoryFunctionalTest.groovy +++ b/native-maven-plugin/src/functionalTest/groovy/org/graalvm/buildtools/maven/MetadataRepositoryFunctionalTest.groovy @@ -186,12 +186,12 @@ class MetadataRepositoryFunctionalTest extends AbstractGraalVMMavenFunctionalTes buildSucceeded and: - file("target/classes/META-INF/native-image/org.graalvm.internal/library-with-reflection/1.5/reflect-config.json").text.trim() == '''[ + matches(file("target/classes/META-INF/native-image/org.graalvm.internal/library-with-reflection/1.5/reflect-config.json").text.trim(), '''[ { "name": "org.graalvm.internal.reflect.Message", "allDeclaredFields": true, "allDeclaredMethods": true } -]''' +]''') } } diff --git a/native-maven-plugin/src/testFixtures/groovy/org/graalvm/buildtools/maven/AbstractGraalVMMavenFunctionalTest.groovy b/native-maven-plugin/src/testFixtures/groovy/org/graalvm/buildtools/maven/AbstractGraalVMMavenFunctionalTest.groovy index 8c07466a2..f5ff112ea 100644 --- a/native-maven-plugin/src/testFixtures/groovy/org/graalvm/buildtools/maven/AbstractGraalVMMavenFunctionalTest.groovy +++ b/native-maven-plugin/src/testFixtures/groovy/org/graalvm/buildtools/maven/AbstractGraalVMMavenFunctionalTest.groovy @@ -222,6 +222,10 @@ abstract class AbstractGraalVMMavenFunctionalTest extends Specification { !normalizeString(result.stdOut).contains(normalizeString(text)) } + static boolean matches(String actual, String expected) { + normalizeString(actual) == normalizeString(expected) + } + File file(String path) { testDirectory.resolve(path).toFile() }