Update tests, which check -X... flag in LauncherScriptTest

Previously, -Xallow-result-return-type was used to test, whether the
launcher parses -X... flags correctly, however, it has no effect -
returning Result is allowed anyway. So, instead, use -Xno-inline and
check runtime behavior.
This commit is contained in:
Ilmir Usmanov
2021-03-22 21:05:59 +01:00
committed by Space
parent 499ffd610a
commit 886e3e6655
5 changed files with 27 additions and 16 deletions
-4
View File
@@ -1,4 +0,0 @@
fun f() : Result<Int> = Result.success(42)
println(f().getOrNull())
@@ -1,5 +0,0 @@
@file:CompilerOptions("-Xallow-result-return-type")
fun f() : Result<Int> = Result.success(42)
println(f().getOrNull())
+1
View File
@@ -0,0 +1 @@
println("OK")
+3
View File
@@ -0,0 +1,3 @@
@file:CompilerOptions("-Xno-inline")
println("OK")
@@ -239,7 +239,13 @@ class LauncherScriptTest : TestCaseWithTmpdir() {
}
fun testScriptWithXArguments() {
runProcess("kotlin", "-Xallow-result-return-type", "$testDataDirectory/funWithResultReturn.kts", expectedStdout = "42\n")
runProcess(
"kotlin", "-Xno-inline", "$testDataDirectory/noInline.kts",
expectedExitCode = 3,
expectedStderr = """java.lang.IllegalAccessError: tried to access method kotlin.io.ConsoleKt.println(Ljava/lang/Object;)V from class NoInline
at NoInline.<init>(noInline.kts:1)
""")
runProcess("kotlin", "$testDataDirectory/noInline.kts", expectedStdout = "OK\n")
}
fun testNoStdLib() {
@@ -292,17 +298,27 @@ println(42)
fun testHowToRunCustomScript() {
runProcess(
"kotlin", "$testDataDirectory/funWithResultReturn.myscript",
expectedExitCode = 1, expectedStderr = "error: could not find or load main class \$TESTDATA_DIR\$/funWithResultReturn.myscript\n"
"kotlin", "$testDataDirectory/noInline.myscript",
expectedExitCode = 1, expectedStderr = "error: could not find or load main class \$TESTDATA_DIR\$/noInline.myscript\n"
)
runProcess(
"kotlin", "-howtorun", "script", "$testDataDirectory/funWithResultReturn.myscript",
expectedExitCode = 1, expectedStderr = "error: unrecognized script type: funWithResultReturn.myscript; Specify path to the script file as the first argument\n"
"kotlin", "-howtorun", "script", "$testDataDirectory/noInline.myscript",
expectedExitCode = 1, expectedStderr = "error: unrecognized script type: noInline.myscript; Specify path to the script file as the first argument\n"
)
runProcess(
"kotlin", "-howtorun", ".main.kts", "$testDataDirectory/funWithResultReturn.myscript",
expectedStdout = "42\n"
"kotlin", "-howtorun", ".kts", "$testDataDirectory/noInline.myscript",
expectedExitCode = 1, expectedStderr = """error: unresolved reference: CompilerOptions (noInline.myscript:1:7)
compiler/testData/launcher/noInline.myscript:1:7: error: unresolved reference: CompilerOptions
@file:CompilerOptions("-Xno-inline")
^
"""
)
runProcess(
"kotlin", "-howtorun", ".main.kts", "$testDataDirectory/noInline.myscript",
expectedExitCode = 3,
expectedStderr = """java.lang.IllegalAccessError: tried to access method kotlin.io.ConsoleKt.println(Ljava/lang/Object;)V from class NoInline_main
at NoInline_main.<init>(noInline.myscript:3)
""")
}
fun testHowToRunClassFile() {