@@ -7,11 +7,13 @@ import org.assertj.core.api.Assertions.assertThat
7
7
import org.jetbrains.kotlin.compiler.plugin.AbstractCliOption
8
8
import org.jetbrains.kotlin.compiler.plugin.CliOption
9
9
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
10
+ import org.junit.Ignore
10
11
import org.junit.Rule
11
12
import org.junit.Test
12
13
import org.junit.rules.TemporaryFolder
13
14
import java.io.ByteArrayOutputStream
14
15
import java.io.File
16
+ import java.nio.file.Files
15
17
import javax.annotation.processing.AbstractProcessor
16
18
import javax.annotation.processing.RoundEnvironment
17
19
import javax.lang.model.element.TypeElement
@@ -830,33 +832,32 @@ class KotlinCompilationTests {
830
832
)
831
833
}
832
834
835
+ @Ignore // Ignored because symlinks can't be created on Windows 7 without admin rights
833
836
@Test
834
837
fun `java compilation runs in a sub-process when jdk is specified` () {
835
838
val source = SourceFile .java(" JSource.java" ,
836
839
"""
837
840
class JSource {}
838
841
""" .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())
841
845
val logsStream = ByteArrayOutputStream ()
842
846
val compiler = defaultCompilerConfig().apply {
843
847
sources = listOf (source)
844
848
jdkHome = fakeJdkHome
845
849
messageOutputStream = logsStream
846
850
}
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 )
853
853
val logs = logsStream.toString(" utf-8" )// use string charset for jdk 8 compatibility
854
854
assertThat(logs).contains(
855
855
" compiling java in a sub-process because a jdkHome is specified"
856
856
)
857
857
assertThat(logs).doesNotContain(
858
858
" jdkHome is set to null, removing boot classpath from java compilation"
859
859
)
860
+ fakeJdkHome.delete()
860
861
}
861
862
862
863
class InheritedClass {}
0 commit comments