From 269f6f54938c784fff9c1b65be95d918afa1610a Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Mon, 14 Sep 2020 23:12:17 +0300 Subject: [PATCH] Support friend modules in external tests --- .../org/jetbrains/kotlin/KonanTest.groovy | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/build-tools/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy b/build-tools/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy index 176c5888ea5..f8fd630c2a2 100644 --- a/build-tools/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy +++ b/build-tools/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy @@ -514,9 +514,13 @@ fun runTest() { if (!module.isDefaultModule()) { def klibModulePath = "${executablePath()}.${module.name}.klib" libs.addAll(module.dependencies) + def klibs = libs.collectMany { ["-l", "${executablePath()}.${it}.klib"] }.toList() + def friends = module.friends ? + module.friends.collectMany { + ["-friend-modules", "${executablePath()}.${it}.klib"] + }.toList() : [] runCompiler(compileList.findAll { it.module == module }.collect { it.path }, - klibModulePath, flags + ["-p", "library"] + - libs.collectMany { ["-l", "${executablePath()}.${it}.klib"] }.toList()) + klibModulePath, flags + ["-p", "library"] + klibs + friends) } } @@ -526,8 +530,13 @@ fun runTest() { compileMain.forEach { f -> libs.addAll(f.module.dependencies) } - if (!compileMain.empty) runCompiler(compileMain.collect { it.path }, executablePath(), - flags + libs.collectMany { ["-l", "${executablePath()}.${it}.klib"] }.toList()) + def friends = compileMain.collectMany {it.module.friends }.toSet() + if (!compileMain.empty) { + runCompiler(compileMain.collect { it.path }, executablePath(), flags + + libs.collectMany { ["-l", "${executablePath()}.${it}.klib"] }.toList() + + friends.collectMany {["-friend-modules", "${executablePath()}.${it}.klib"]}.toList() + ) + } } } catch (Exception ex) { project.logger.quiet("ERROR: Compilation failed for test suite: $name with exception", ex)