Avoid compiling Java files twice in boxAgainstJava tests

After b602c08773, this test started to put all .java files to the
dependencies when compiling .kt files, _in addition_ to the already
compiled class files from those Java sources. This is incorrect because
the test should actually check how Kotlin compiles _against_ Java
binaries. The other behavior (compiling against Java sources) is already
supported and used in normal box tests with .java sources.

However, we can't simply filter out all .java files before calling
`super.doMultiFileTest` because many of those contain directives
(WITH_RUNTIME, FULL_JDK, etc.) and we should load them in
`CodegenTestCase.compile`. As a workaround, remove '.java' file
extension to prevent their compilation but still be able to resolve
directives.
This commit is contained in:
Alexander Udalov
2019-06-05 18:55:34 +02:00
parent e3d2419beb
commit c6d61346dd
@@ -27,7 +27,12 @@ abstract class AbstractBlackBoxAgainstJavaCodegenTest : AbstractBlackBoxCodegenT
CodegenTestUtil.compileJava(CodegenTestUtil.findJavaSourcesInDirectory(directory), emptyList(), extractJavacOptions(files))
}
super.doMultiFileTest(wholeFile, files)
super.doMultiFileTest(wholeFile, files.map { file ->
// This is a hack which allows to avoid compiling Java sources for the second time (which would be incorrect in this test),
// while also retaining content of all Java sources so that we could find and use test directives in Java sources
// in CodegenTestCase.compile.
if (file.name.endsWith(".java")) TestFile("${file.name}.disabled", file.content) else file
})
}
override fun updateConfiguration(configuration: CompilerConfiguration) {