Implement -X arguments passing from kotlin runner to compiler

This commit is contained in:
Ilya Chernikov
2021-01-04 13:06:18 +01:00
parent 9a7d1948a7
commit d2ecc1e361
6 changed files with 52 additions and 16 deletions
@@ -48,9 +48,16 @@ class LauncherScriptTest : TestCaseWithTmpdir() {
)
pb.directory(workDirectory)
val process = pb.start()
val stdout = StringUtil.convertLineSeparators(process.inputStream.bufferedReader().use { it.readText() })
val stderr = StringUtil.convertLineSeparators(process.errorStream.bufferedReader().use { it.readText() })
.replace("Picked up [_A-Z]+:.*\n".toRegex(), "")
val stdout =
AbstractCliTest.getNormalizedCompilerOutput(
StringUtil.convertLineSeparators(process.inputStream.bufferedReader().use { it.readText() }),
null, testDataDirectory
)
val stderr =
AbstractCliTest.getNormalizedCompilerOutput(
StringUtil.convertLineSeparators(process.errorStream.bufferedReader().use { it.readText() }),
null, testDataDirectory
).replace("Picked up [_A-Z]+:.*\n".toRegex(), "")
process.waitFor(10, TimeUnit.SECONDS)
val exitCode = process.exitValue()
try {
@@ -228,6 +235,19 @@ class LauncherScriptTest : TestCaseWithTmpdir() {
runProcess("kotlin", "LegacyAssertEnabledKt", "-J-ea:kotlin._Assertions", workDirectory = tmpdir)
}
fun testScriptWithXArguments() {
runProcess(
"kotlin", "$testDataDirectory/funWithResultReturn.kts",
expectedExitCode = 1,
expectedStderr = """error: 'kotlin.Result' cannot be used as a return type (funWithResultReturn.kts:2:11)
compiler/testData/launcher/funWithResultReturn.kts:2:11: error: 'kotlin.Result' cannot be used as a return type
fun f() : Result<Int> = Result.success(42)
^
"""
)
runProcess("kotlin", "-Xallow-result-return-type", "$testDataDirectory/funWithResultReturn.kts", expectedStdout = "42\n")
}
fun testProperty() {
runProcess("kotlinc", "$testDataDirectory/property.kt", "-d", tmpdir.path)