@@ -7,11 +7,13 @@ import org.assertj.core.api.Assertions.assertThat
77import org.jetbrains.kotlin.compiler.plugin.AbstractCliOption
88import org.jetbrains.kotlin.compiler.plugin.CliOption
99import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
10+ import org.junit.Ignore
1011import org.junit.Rule
1112import org.junit.Test
1213import org.junit.rules.TemporaryFolder
1314import java.io.ByteArrayOutputStream
1415import java.io.File
16+ import java.nio.file.Files
1517import javax.annotation.processing.AbstractProcessor
1618import javax.annotation.processing.RoundEnvironment
1719import javax.lang.model.element.TypeElement
@@ -830,33 +832,32 @@ class KotlinCompilationTests {
830832 )
831833 }
832834
835+ @Ignore // Ignored because symlinks can't be created on Windows 7 without admin rights
833836 @Test
834837 fun `java compilation runs in a sub-process when jdk is specified` () {
835838 val source = SourceFile .java(" JSource.java" ,
836839 """
837840 class JSource {}
838841 """ .trimIndent())
839- val fakeJdkHome = temporaryFolder.newFolder(" fake-jdk-home" )
840- fakeJdkHome.resolve(" bin" ).mkdirs()
842+ val fakeJdkHome = temporaryFolder.newFolder(" jdk-copy" )
843+ fakeJdkHome.mkdirs()
844+ Files .createLink(fakeJdkHome.resolve(" bin" ).toPath(), processJdkHome.toPath())
841845 val logsStream = ByteArrayOutputStream ()
842846 val compiler = defaultCompilerConfig().apply {
843847 sources = listOf (source)
844848 jdkHome = fakeJdkHome
845849 messageOutputStream = logsStream
846850 }
847- val compilation = runCatching {
848- // jdk is fake so it won't compile
849- compiler.compile()
850- }
851- // it should fail since we are passing a fake jdk
852- assertThat(compilation.isFailure).isTrue()
851+ val result = compiler.compile()
852+ assertThat(result.exitCode).isEqualTo(ExitCode .COMPILATION_ERROR )
853853 val logs = logsStream.toString(" utf-8" )// use string charset for jdk 8 compatibility
854854 assertThat(logs).contains(
855855 " compiling java in a sub-process because a jdkHome is specified"
856856 )
857857 assertThat(logs).doesNotContain(
858858 " jdkHome is set to null, removing boot classpath from java compilation"
859859 )
860+ fakeJdkHome.delete()
860861 }
861862
862863 class InheritedClass {}
0 commit comments