Removed the exec(String...) method in KotlinCompiler
It's important to be aware of what stream the messages will be written to, so such a default implementation is harmful
This commit is contained in:
@@ -72,7 +72,7 @@ public class KotlinCompiler {
|
||||
*/
|
||||
public static void doMain(KotlinCompiler compiler, String[] args) {
|
||||
try {
|
||||
ExitCode rc = compiler.exec(args);
|
||||
ExitCode rc = compiler.exec(System.out, args);
|
||||
if (rc != OK) {
|
||||
System.err.println("exec() finished with " + rc + " return code");
|
||||
System.exit(rc.getCode());
|
||||
@@ -83,10 +83,6 @@ public class KotlinCompiler {
|
||||
}
|
||||
}
|
||||
|
||||
public ExitCode exec(String... args) {
|
||||
return exec(System.out, args);
|
||||
}
|
||||
|
||||
public ExitCode exec(PrintStream errStream, String... args) {
|
||||
CompilerArguments arguments = createArguments();
|
||||
if (!parseArguments(errStream, arguments, args)) {
|
||||
|
||||
@@ -18,11 +18,9 @@ package org.jetbrains.jet.compiler;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import junit.framework.TestCase;
|
||||
import org.jetbrains.jet.CompileCompilerDependenciesTest;
|
||||
import org.jetbrains.jet.cli.KotlinCompiler;
|
||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileJdkHeaders;
|
||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
|
||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
import org.junit.Assert;
|
||||
|
||||
@@ -47,11 +45,11 @@ public class CompileEnvironmentTest extends TestCase {
|
||||
File stdlib = ForTestCompileRuntime.runtimeJarForTests();
|
||||
File jdkHeaders = ForTestCompileJdkHeaders.jdkHeadersForTests();
|
||||
File resultJar = new File(tempDir, "result.jar");
|
||||
KotlinCompiler.ExitCode rv = new KotlinCompiler().exec(
|
||||
"-module", JetParsingTest.getTestDataDir() + "/compiler/smoke/Smoke.kts",
|
||||
"-jar", resultJar.getAbsolutePath(),
|
||||
"-stdlib", stdlib.getAbsolutePath(),
|
||||
"-jdkHeaders", jdkHeaders.getAbsolutePath());
|
||||
KotlinCompiler.ExitCode rv = new KotlinCompiler().exec(System.out,
|
||||
"-module", JetParsingTest.getTestDataDir() + "/compiler/smoke/Smoke.kts",
|
||||
"-jar", resultJar.getAbsolutePath(),
|
||||
"-stdlib", stdlib.getAbsolutePath(),
|
||||
"-jdkHeaders", jdkHeaders.getAbsolutePath());
|
||||
Assert.assertEquals("compilation completed with non-zero code", KotlinCompiler.ExitCode.OK, rv);
|
||||
FileInputStream fileInputStream = new FileInputStream(resultJar);
|
||||
try {
|
||||
@@ -80,11 +78,9 @@ public class CompileEnvironmentTest extends TestCase {
|
||||
File out = new File(tempDir, "out");
|
||||
File stdlib = ForTestCompileRuntime.runtimeJarForTests();
|
||||
File jdkHeaders = ForTestCompileJdkHeaders.jdkHeadersForTests();
|
||||
KotlinCompiler.ExitCode exitCode = new KotlinCompiler().exec(
|
||||
"-src", JetParsingTest.getTestDataDir() + "/compiler/smoke/Smoke.kt",
|
||||
"-output", out.getAbsolutePath(),
|
||||
"-stdlib", stdlib.getAbsolutePath(),
|
||||
"-jdkHeaders", jdkHeaders.getAbsolutePath());
|
||||
KotlinCompiler.ExitCode exitCode = new KotlinCompiler()
|
||||
.exec(System.out, "-src", JetParsingTest.getTestDataDir() + "/compiler/smoke/Smoke.kt", "-output",
|
||||
out.getAbsolutePath(), "-stdlib", stdlib.getAbsolutePath(), "-jdkHeaders", jdkHeaders.getAbsolutePath());
|
||||
Assert.assertEquals(KotlinCompiler.ExitCode.OK, exitCode);
|
||||
assertEquals(1, out.listFiles().length);
|
||||
assertEquals(1, out.listFiles()[0].listFiles().length);
|
||||
|
||||
@@ -60,7 +60,8 @@ public abstract class AbstractLibrariesTest extends PlatformTestCase {
|
||||
});
|
||||
librarySourceDir = LocalFileSystem.getInstance().findFileByPath(TEST_DATA_PATH + "/library");
|
||||
assertNotNull(librarySourceDir);
|
||||
KotlinCompiler.ExitCode compilerExec = new KotlinCompiler().exec("-src", librarySourceDir.getPath(), "-output", libraryIoDir.getAbsolutePath());
|
||||
KotlinCompiler.ExitCode compilerExec =
|
||||
new KotlinCompiler().exec(System.out, "-src", librarySourceDir.getPath(), "-output", libraryIoDir.getAbsolutePath());
|
||||
assertEquals(KotlinCompiler.ExitCode.OK, compilerExec);
|
||||
libraryDir = LocalFileSystem.getInstance().findFileByIoFile(libraryIoDir);
|
||||
assertNotNull(libraryDir);
|
||||
|
||||
Reference in New Issue
Block a user