Send compiler output to stderr instead of stdout
Test only stderr in kotlinc test now and move the '-script' test to integration tests where both stdout and stderr is tested
This commit is contained in:
@@ -210,7 +210,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public static ExitCode doMainNoExit(@NotNull CLICompiler compiler, @NotNull String[] args) {
|
public static ExitCode doMainNoExit(@NotNull CLICompiler compiler, @NotNull String[] args) {
|
||||||
try {
|
try {
|
||||||
ExitCode rc = compiler.exec(System.out, args);
|
ExitCode rc = compiler.exec(System.err, args);
|
||||||
if (rc != OK) {
|
if (rc != OK) {
|
||||||
System.err.println("exec() finished with " + rc + " return code");
|
System.err.println("exec() finished with " + rc + " return code");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,4 +69,8 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
|
|||||||
runCompiler("test.compile", "-src", "test.kt", "-jar", jar);
|
runCompiler("test.compile", "-src", "test.kt", "-jar", jar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void simpleScript() throws Exception {
|
||||||
|
runCompiler("script", "-script", "script.kts", "hi", "there");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,13 +62,18 @@ public abstract class KotlinIntegrationTestBase {
|
|||||||
new File(getKotlinProjectHome(), "compiler" + File.separator + "integration-tests" + File.separator + "testData");
|
new File(getKotlinProjectHome(), "compiler" + File.separator + "integration-tests" + File.separator + "testData");
|
||||||
testDataDir = new File(baseTestDataDir, description.getMethodName());
|
testDataDir = new File(baseTestDataDir, description.getMethodName());
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static {
|
||||||
|
System.setProperty("java.awt.headless", "true");
|
||||||
|
}
|
||||||
|
|
||||||
protected int runCompiler(String logName, String... arguments) throws Exception {
|
protected int runCompiler(String logName, String... arguments) throws Exception {
|
||||||
File lib = getCompilerLib();
|
File lib = getCompilerLib();
|
||||||
|
|
||||||
String classpath = lib.getAbsolutePath() + File.separator + "kotlin-compiler.jar";
|
String classpath = lib.getAbsolutePath() + File.separator +
|
||||||
|
"kotlin-compiler.jar" + File.pathSeparator +
|
||||||
|
getKotlinRuntimePath();
|
||||||
|
|
||||||
Collection<String> javaArgs = new ArrayList<String>();
|
Collection<String> javaArgs = new ArrayList<String>();
|
||||||
javaArgs.add("-cp");
|
javaArgs.add("-cp");
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
OUT:
|
|
||||||
ERROR: [TestData]/hello.kt: (4, 5) Unresolved reference: a
|
|
||||||
|
|
||||||
ERR:
|
ERR:
|
||||||
|
ERROR: [TestData]/hello.kt: (4, 5) Unresolved reference: a
|
||||||
exec() finished with COMPILATION_ERROR return code
|
exec() finished with COMPILATION_ERROR return code
|
||||||
|
|
||||||
Return code: 1
|
Return code: 1
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
OUT:
|
||||||
|
hi
|
||||||
|
there
|
||||||
|
|
||||||
|
Return code: 0
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
OUT:
|
|
||||||
ERROR: [TestData]/test.kt: (4, 20) Expecting an element
|
|
||||||
|
|
||||||
ERR:
|
ERR:
|
||||||
|
ERROR: [TestData]/test.kt: (4, 20) Expecting an element
|
||||||
exec() finished with COMPILATION_ERROR return code
|
exec() finished with COMPILATION_ERROR return code
|
||||||
|
|
||||||
Return code: 1
|
Return code: 1
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
-script
|
|
||||||
$TESTDATA_DIR$/script.kts
|
|
||||||
hi
|
|
||||||
there
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
hi
|
|
||||||
there
|
|
||||||
OK
|
|
||||||
@@ -42,14 +42,14 @@ public abstract class AbstractKotlincExecutableTest extends TestCaseWithTmpdir {
|
|||||||
String stderr = processOutput.getStderr();
|
String stderr = processOutput.getStderr();
|
||||||
int exitCode = processOutput.getExitCode();
|
int exitCode = processOutput.getExitCode();
|
||||||
|
|
||||||
String normalizedOutput = CliBaseTest.getNormalizedCompilerOutput(stdout, ExitCode.values()[exitCode], testDataDir);
|
String normalizedOutput = CliBaseTest.getNormalizedCompilerOutput(stderr, ExitCode.values()[exitCode], testDataDir);
|
||||||
File outFile = new File(argsFilePath.replace(".args", ".out"));
|
File outFile = new File(argsFilePath.replace(".args", ".out"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JetTestUtils.assertEqualsToFile(outFile, normalizedOutput);
|
JetTestUtils.assertEqualsToFile(outFile, normalizedOutput);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
System.err.println("exitcode " + exitCode);
|
System.err.println("exit code " + exitCode);
|
||||||
System.err.println("<stdout>" + stdout + "</stdout>");
|
System.err.println("<stdout>" + stdout + "</stdout>");
|
||||||
System.err.println("<stderr>" + stderr + "</stderr>");
|
System.err.println("<stderr>" + stderr + "</stderr>");
|
||||||
|
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ public class CliBaseTest {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private static Pair<String, ExitCode> executeCompilerGrabOutput(@NotNull CLICompiler<?> compiler, @NotNull List<String> args) {
|
private static Pair<String, ExitCode> executeCompilerGrabOutput(@NotNull CLICompiler<?> compiler, @NotNull List<String> args) {
|
||||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||||
PrintStream origOut = System.out;
|
PrintStream origErr = System.err;
|
||||||
try {
|
try {
|
||||||
System.setOut(new PrintStream(bytes));
|
System.setErr(new PrintStream(bytes));
|
||||||
ExitCode exitCode = CLICompiler.doMainNoExit(compiler, ArrayUtil.toStringArray(args));
|
ExitCode exitCode = CLICompiler.doMainNoExit(compiler, ArrayUtil.toStringArray(args));
|
||||||
return Pair.create(bytes.toString("utf-8"), exitCode);
|
return Pair.create(bytes.toString("utf-8"), exitCode);
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ public class CliBaseTest {
|
|||||||
throw UtilsPackage.rethrow(e);
|
throw UtilsPackage.rethrow(e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
System.setOut(origOut);
|
System.setErr(origErr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.cli;
|
package org.jetbrains.jet.cli;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -34,16 +34,6 @@ public class CliCommonTest extends CliBaseTest {
|
|||||||
executeCompilerCompareOutputJVM();
|
executeCompilerCompareOutputJVM();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void printArguments() throws Exception {
|
|
||||||
executeCompilerCompareOutputJVM();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void printArgumentsWithManyValue() throws Exception {
|
|
||||||
executeCompilerCompareOutputJS();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void simple() throws Exception {
|
public void simple() throws Exception {
|
||||||
executeCompilerCompareOutputJVM();
|
executeCompilerCompareOutputJVM();
|
||||||
|
|||||||
@@ -79,11 +79,6 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes
|
|||||||
doJvmTest("compiler/testData/cli/jvm/printArguments.args");
|
doJvmTest("compiler/testData/cli/jvm/printArguments.args");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("script.args")
|
|
||||||
public void testScript() throws Exception {
|
|
||||||
doJvmTest("compiler/testData/cli/jvm/script.args");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("signatureClash.args")
|
@TestMetadata("signatureClash.args")
|
||||||
public void testSignatureClash() throws Exception {
|
public void testSignatureClash() throws Exception {
|
||||||
doJvmTest("compiler/testData/cli/jvm/signatureClash.args");
|
doJvmTest("compiler/testData/cli/jvm/signatureClash.args");
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.cli.jvm;
|
package org.jetbrains.jet.cli.jvm;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.jetbrains.jet.cli.CliBaseTest;
|
import org.jetbrains.jet.cli.CliBaseTest;
|
||||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -47,11 +47,6 @@ public class K2JvmCliTest extends CliBaseTest {
|
|||||||
executeCompilerCompareOutputJVM();
|
executeCompilerCompareOutputJVM();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void script() throws Exception {
|
|
||||||
executeCompilerCompareOutputJVM();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void classpath() throws Exception {
|
public void classpath() throws Exception {
|
||||||
executeCompilerCompareOutputJVM();
|
executeCompilerCompareOutputJVM();
|
||||||
|
|||||||
Reference in New Issue
Block a user