From 2ed2b262d27ac75eca62fe313626b0ae8ee20505 Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Tue, 18 Jul 2017 14:58:23 +0700 Subject: [PATCH] gradle-plugin, tests: Escape windows path separator in konan.home --- tools/kotlin-native-gradle-plugin/build.gradle | 4 ++-- .../plugin/test/IncrementalSpecification.groovy | 10 +++++----- .../kotlin/gradle/plugin/test/KonanProject.groovy | 12 +++++++++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/tools/kotlin-native-gradle-plugin/build.gradle b/tools/kotlin-native-gradle-plugin/build.gradle index 723e20526e5..333a2b808fa 100644 --- a/tools/kotlin-native-gradle-plugin/build.gradle +++ b/tools/kotlin-native-gradle-plugin/build.gradle @@ -63,9 +63,9 @@ dependencies { } test { - dependsOn ':dist' + dependsOn ':cross_dist' //testLogging.showStandardStreams = true - systemProperty("konan.home", rootProject.file('dist')) + systemProperty("konan.home", rootProject.file('dist').canonicalPath) } jar { diff --git a/tools/kotlin-native-gradle-plugin/src/test/groovy/org/jetbrains/kotlin/gradle/plugin/test/IncrementalSpecification.groovy b/tools/kotlin-native-gradle-plugin/src/test/groovy/org/jetbrains/kotlin/gradle/plugin/test/IncrementalSpecification.groovy index 21a10b84e02..4eeb5aaf1e9 100644 --- a/tools/kotlin-native-gradle-plugin/src/test/groovy/org/jetbrains/kotlin/gradle/plugin/test/IncrementalSpecification.groovy +++ b/tools/kotlin-native-gradle-plugin/src/test/groovy/org/jetbrains/kotlin/gradle/plugin/test/IncrementalSpecification.groovy @@ -185,7 +185,7 @@ class IncrementalSpecification extends Specification { } def results = buildTwice(project) { KonanInteropProject it -> def manifest = it.generateSrcFile('manifest', "#some manifest file") - it.buildFile.append("konanArtifacts['main'].manifest '${manifest.canonicalPath}'") + it.buildFile.append("konanArtifacts['main'].manifest '${manifest.canonicalPath.replace('\\', '\\\\')}'") } then: @@ -198,7 +198,7 @@ class IncrementalSpecification extends Specification { def project = KonanInteropProject.createEmpty(tmpFolder) { KonanInteropProject it -> it.generateSrcFile('main.kt') manifest = it.generateSrcFile('manifest', "#some manifest file\n") - it.buildFile.append("konanArtifacts['main'].manifest '${manifest.canonicalPath}'") + it.buildFile.append("konanArtifacts['main'].manifest '${manifest.canonicalPath.replace('\\', '\\\\')}'") } def results = buildTwice(project) { KonanInteropProject it -> manifest.append("#something else\n") @@ -232,7 +232,7 @@ class IncrementalSpecification extends Specification { project.generateSrcFile('main.kt') def defFile = project.generateDefFile("foo.def", "#some content") def results = buildTwice(project) { KonanInteropProject it -> - it.buildFile.append("konanInterop['stdio'].defFile file('${defFile.canonicalPath}')\n") + it.buildFile.append("konanInterop['stdio'].defFile file('${defFile.canonicalPath.replace('\\', '\\\\')}')\n") } then: @@ -245,7 +245,7 @@ class IncrementalSpecification extends Specification { project.generateSrcFile('main.kt') def header = project.generateSrcFile('header.h', "#define CONST 1") def results = buildTwice(project) { KonanInteropProject it -> - it.buildFile.append("konanInterop['stdio'].headers '${header.canonicalPath}'\n") + it.buildFile.append("konanInterop['stdio'].headers '${header.canonicalPath.replace('\\', '\\\\')}'\n") } then: @@ -294,7 +294,7 @@ class IncrementalSpecification extends Specification { recompilationAndInteropProcessingHappened(*results) } - @IgnoreIf({ System.getProperty('os.name').contains('windows') }) + @IgnoreIf(System.getProperty('os.name').contains('windows')) def 'target change should cause recompilation and interop reprocessing'() { when: def newTarget diff --git a/tools/kotlin-native-gradle-plugin/src/test/groovy/org/jetbrains/kotlin/gradle/plugin/test/KonanProject.groovy b/tools/kotlin-native-gradle-plugin/src/test/groovy/org/jetbrains/kotlin/gradle/plugin/test/KonanProject.groovy index 366a8d8ddc4..6b4b44af743 100644 --- a/tools/kotlin-native-gradle-plugin/src/test/groovy/org/jetbrains/kotlin/gradle/plugin/test/KonanProject.groovy +++ b/tools/kotlin-native-gradle-plugin/src/test/groovy/org/jetbrains/kotlin/gradle/plugin/test/KonanProject.groovy @@ -9,7 +9,7 @@ class KonanProject { File getProjectDirRoot() { return projectDir.root } - String konanHome = System.getProperty("konan.home") ?: { throw new IllegalStateException("konan.home isn't specified") }() + String konanHome File buildFile File propertiesFile @@ -26,6 +26,16 @@ class KonanProject { protected KonanProject(TemporaryFolder projectDir) { this.projectDir = projectDir + def konanHome = System.getProperty("konan.home") + if (konanHome == null) { + throw new IllegalStateException("konan.home isn't specified") + } + def konanHomeDir = new File(konanHome) + if (!konanHomeDir.exists() || !konanHomeDir.directory) { + throw new IllegalStateException("konan.home doesn't exist or is not a directory: $konanHomeDir.canonicalPath") + } + // Escape windows path separator + this.konanHome = konanHomeDir.canonicalPath.replace('\\', '\\\\') } void generateFolders() {