Skip to content

Commit 1b35914

Browse files
demiurg906Space Team
authored andcommitted
[Test] Workaround stdlib duplication in AbstractJavaModulesIntegrationTest
These tests invoke CLI compiler and pass the stdlib/reflect as part of the modular classpath. But at the same time CLI compiler itself adds stdlib and reflect from `dist`, as `-no-stdlib` flag was not passed. After setting the `compiler-tests-convention` gradle plugin, stdlib and reflect paths are set via system property to jars produced by building corresponding modules, not from `dist`, which caused the compiler to report warnings about duplicated libraries on the classpath. The workaround is to use libraries from dist ignoring the environment properties.
1 parent 80c3596 commit 1b35914

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

compiler/test-infrastructure-utils/testFixtures/org/jetbrains/kotlin/codegen/forTestCompile/ForTestCompileRuntime.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ public static File runtimeJarForTests() {
2727
return propertyOrDist(KOTLIN_FULL_STDLIB_PATH, "dist/kotlinc/lib/kotlin-stdlib.jar");
2828
}
2929

30+
/**
31+
* This function left as a workaround for AbstractJavaModulesIntegrationTest
32+
* For any other case use `runtimeJarForTests` instead
33+
*/
34+
@NotNull
35+
@Deprecated
36+
public static File runtimeJarFromDistForTests() {
37+
return new File("dist/kotlinc/lib/kotlin-stdlib.jar");
38+
}
39+
3040
@NotNull
3141
public static File runtimeJarForTestsWithJdk8() {
3242
return propertyOrDist(KOTLIN_FULL_STDLIB_PATH, "dist/kotlinc/lib/kotlin-stdlib-jdk8.jar");
@@ -47,6 +57,16 @@ public static File reflectJarForTests() {
4757
return propertyOrDist(KOTLIN_REFLECT_JAR_PATH, "dist/kotlinc/lib/kotlin-reflect.jar");
4858
}
4959

60+
/**
61+
* This function left as a workaround for AbstractJavaModulesIntegrationTest
62+
* For any other case use `runtimeJarForTests` instead
63+
*/
64+
@NotNull
65+
@Deprecated
66+
public static File reflectJarFromDistForTests() {
67+
return new File("dist/kotlinc/lib/kotlin-reflect.jar");
68+
}
69+
5070
@NotNull
5171
public static File scriptRuntimeJarForTests() {
5272
return propertyOrDist(KOTLIN_SCRIPT_RUNTIME_PATH, "dist/kotlinc/lib/kotlin-script-runtime.jar");

compiler/tests-integration/tests/org/jetbrains/kotlin/jvm/modules/AbstractJavaModulesIntegrationTest.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ abstract class AbstractJavaModulesIntegrationTest(
4040
destination: File? = null,
4141
checkKotlinOutput: (String) -> Unit = this.checkKotlinOutput(name),
4242
): File {
43-
val paths = (modulePath + ForTestCompileRuntime.runtimeJarForTests()).joinToString(separator = File.pathSeparator) { it.path }
43+
@Suppress("DEPRECATION")
44+
val paths = (modulePath + ForTestCompileRuntime.runtimeJarFromDistForTests()).joinToString(separator = File.pathSeparator) { it.path }
4445

4546
val kotlinOptions = mutableListOf(
4647
K2JVMCompilerArguments::jdkHome.cliArgument, jdkHome.path,
@@ -243,20 +244,22 @@ abstract class AbstractJavaModulesIntegrationTest(
243244
module("main", listOf(d1, d2))
244245
}
245246

247+
@Suppress("DEPRECATION")
246248
fun testDependencyOnStdlib() {
247249
module("unnamed")
248250
val namedWithExplicitDependency = module("namedWithExplicitDependency")
249251
module("namedWithoutExplicitDependency")
250252
module("namedWithIndirectDependencyViaOtherModule", listOf(namedWithExplicitDependency))
251-
module("namedWithIndirectDependencyViaReflect", listOf(ForTestCompileRuntime.reflectJarForTests()))
253+
module("namedWithIndirectDependencyViaReflect", listOf(ForTestCompileRuntime.reflectJarFromDistForTests()))
252254
}
253255

254256
fun testDependencyOnStdlibJdk78() {
255257
module("usage", listOf(File("dist/kotlinc/lib/kotlin-stdlib-jdk7.jar"), File("dist/kotlinc/lib/kotlin-stdlib-jdk8.jar")))
256258
}
257259

260+
@Suppress("DEPRECATION")
258261
fun testDependencyOnReflect() {
259-
module("usage", listOf(ForTestCompileRuntime.reflectJarForTests()))
262+
module("usage", listOf(ForTestCompileRuntime.reflectJarFromDistForTests()))
260263
}
261264

262265
fun testWithBuildFile() {
@@ -277,8 +280,9 @@ abstract class AbstractJavaModulesIntegrationTest(
277280
assertEquals("usage/some.module.withsome.packages.Test", stdout)
278281
}
279282

283+
@Suppress("DEPRECATION")
280284
fun testReflection() {
281-
val reflect = ForTestCompileRuntime.reflectJarForTests()
285+
val reflect = ForTestCompileRuntime.reflectJarFromDistForTests()
282286
val usage = module("usage", listOf(reflect))
283287
val (stdout, stderr) = runModule("usage/usage.test.UsageKt", listOf(usage, reflect))
284288
assertEquals("", stderr)

0 commit comments

Comments
 (0)