Flush stdout and stderr before shutdown in scripts
Although a test is present, it doesn't check the behavior because it seems that in the test environment both streams are necessarily flushed #KT-9546 Fixed
This commit is contained in:
+8
-1
@@ -238,7 +238,14 @@ object KotlinToJVMBytecodeCompiler {
|
||||
val scriptConstructor = getScriptConstructor(scriptClass)
|
||||
|
||||
try {
|
||||
scriptConstructor.newInstance(*arrayOf<Any>(scriptArgs.toTypedArray()))
|
||||
try {
|
||||
scriptConstructor.newInstance(*arrayOf<Any>(scriptArgs.toTypedArray()))
|
||||
}
|
||||
finally {
|
||||
// NB: these lines are required (see KT-9546) but aren't covered by tests
|
||||
System.out.flush()
|
||||
System.err.flush()
|
||||
}
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
reportExceptionFromScript(e)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
OUT:
|
||||
AB
|
||||
C
|
||||
Return code: 0
|
||||
@@ -0,0 +1,3 @@
|
||||
print("A")
|
||||
println("B")
|
||||
print("C")
|
||||
@@ -65,6 +65,10 @@ public class CompilerSmokeTest extends CompilerSmokeTestBase {
|
||||
runCompiler("script", "-script", "script.kts");
|
||||
}
|
||||
|
||||
public void testScriptFlushBeforeShutdown() throws Exception {
|
||||
runCompiler("script", "-script", "script.kts");
|
||||
}
|
||||
|
||||
public void testCompileScript() throws Exception {
|
||||
String jar = tmpdir.getAbsolutePath() + File.separator + "script.jar";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user