From d7795bb207e005f9af89ea2b4c301d0573908b52 Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Tue, 31 Oct 2017 19:32:05 +0300 Subject: [PATCH] tests: Support custom konan.home for platform lib tests * Move testLibrary tasks from klib into backend.native/tests * Support konan.home property in them --- backend.native/tests/build.gradle | 32 ++++++++++++++++++- .../testLibrary/kotlin/test_platform_lib.kt | 0 klib/build.gradle | 31 +----------------- 3 files changed, 32 insertions(+), 31 deletions(-) rename {klib/src => backend.native/tests}/testLibrary/kotlin/test_platform_lib.kt (100%) diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index fb726096ba6..46a90a6e30e 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -62,6 +62,36 @@ allprojects { } } +def konanHome = rootProject.file(project.findProperty("konan.home") ?: distDir).absolutePath +def suffix = isWindows() ? ".bat" : "" + +// TODO: Ideally we want to write just konanArtifacts{} clause here, +// but we need to make Kotlin/Native Gradle Plugin a dependence +// of our buildScripts first. +task compileKonanTestLibrary(type: Exec) { + if (!project.hasProperty("konan.home")) { + dependsOn ':dist' + } + + def compiler = "$konanHome/bin/konanc$suffix" + def source = 'testLibrary' + def artifact = 'build/konan/bin/testLibrary' + + executable compiler + args source, '-o', artifact, '-p', 'library' +} + +task installTestLibrary(type: Exec) { + dependsOn 'compileKonanTestLibrary' + + def tool = "$konanHome/bin/klib$suffix" + def repo = "$konanHome/klib/common" + def library = 'build/konan/bin/testLibrary.klib' + + executable tool + args 'install', library, '-repository', repo +} + // TODO: use lastSuccessful teamcity build. task update_external_tests() { doLast { @@ -1247,7 +1277,7 @@ task link_testLib_explicitly(type: RunStandaloneKonanTest) { // there are no testLibrary for cross targets yet. disabled = (project.testTarget != null && project.testTarget != project.hostName) - dependsOn ':klib:installTestLibrary' + dependsOn 'installTestLibrary' goldValue = "This is a side effect of a test library linked into the binary.\nYou should not be seeing this.\n\nHello\n" source = "link/omit/hello.kt" // We force library inclusion, so need to see the warning banner. diff --git a/klib/src/testLibrary/kotlin/test_platform_lib.kt b/backend.native/tests/testLibrary/kotlin/test_platform_lib.kt similarity index 100% rename from klib/src/testLibrary/kotlin/test_platform_lib.kt rename to backend.native/tests/testLibrary/kotlin/test_platform_lib.kt diff --git a/klib/build.gradle b/klib/build.gradle index f679fb0026e..1ccee49785e 100644 --- a/klib/build.gradle +++ b/klib/build.gradle @@ -23,33 +23,4 @@ apply plugin: 'kotlin' dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile project(path: ':backend.native', configuration: 'cli_bc') -} - -def dist = distDir.absolutePath -def suffix = isWindows() ? ".bat" : "" - -// TODO: Ideally we want to write just konanArtifacts{} clause here, -// but we need to make Kotlin/Native Gradle Plugin a dependence -// of our buildScripts first. -task compileKonanTestLibrary(type: Exec) { - dependsOn ':dist' - - def compiler = "$dist/bin/konanc$suffix" - def source = 'src/testLibrary' - def artifact = 'build/konan/bin/testLibrary' - - executable compiler - args source, '-o', artifact, '-p', 'library' -} - -task installTestLibrary(type: Exec) { - dependsOn 'compileKonanTestLibrary' - - def tool = "$dist/bin/klib$suffix" - def repo = "$dist/klib/common" - def library = 'build/konan/bin/testLibrary.klib' - - executable tool - args 'install', library, '-repository', repo -} - +} \ No newline at end of file