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
|
||||
public static ExitCode doMainNoExit(@NotNull CLICompiler compiler, @NotNull String[] args) {
|
||||
try {
|
||||
ExitCode rc = compiler.exec(System.out, args);
|
||||
ExitCode rc = compiler.exec(System.err, args);
|
||||
if (rc != OK) {
|
||||
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);
|
||||
}
|
||||
|
||||
@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");
|
||||
testDataDir = new File(baseTestDataDir, description.getMethodName());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static {
|
||||
System.setProperty("java.awt.headless", "true");
|
||||
}
|
||||
|
||||
protected int runCompiler(String logName, String... arguments) throws Exception {
|
||||
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>();
|
||||
javaArgs.add("-cp");
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
OUT:
|
||||
ERROR: [TestData]/hello.kt: (4, 5) Unresolved reference: a
|
||||
|
||||
ERR:
|
||||
ERROR: [TestData]/hello.kt: (4, 5) Unresolved reference: a
|
||||
exec() finished with COMPILATION_ERROR return code
|
||||
|
||||
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:
|
||||
ERROR: [TestData]/test.kt: (4, 20) Expecting an element
|
||||
exec() finished with COMPILATION_ERROR return code
|
||||
|
||||
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();
|
||||
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"));
|
||||
|
||||
try {
|
||||
JetTestUtils.assertEqualsToFile(outFile, normalizedOutput);
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.err.println("exitcode " + exitCode);
|
||||
System.err.println("exit code " + exitCode);
|
||||
System.err.println("<stdout>" + stdout + "</stdout>");
|
||||
System.err.println("<stderr>" + stderr + "</stderr>");
|
||||
|
||||
|
||||
@@ -48,9 +48,9 @@ public class CliBaseTest {
|
||||
@NotNull
|
||||
private static Pair<String, ExitCode> executeCompilerGrabOutput(@NotNull CLICompiler<?> compiler, @NotNull List<String> args) {
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
PrintStream origOut = System.out;
|
||||
PrintStream origErr = System.err;
|
||||
try {
|
||||
System.setOut(new PrintStream(bytes));
|
||||
System.setErr(new PrintStream(bytes));
|
||||
ExitCode exitCode = CLICompiler.doMainNoExit(compiler, ArrayUtil.toStringArray(args));
|
||||
return Pair.create(bytes.toString("utf-8"), exitCode);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class CliBaseTest {
|
||||
throw UtilsPackage.rethrow(e);
|
||||
}
|
||||
finally {
|
||||
System.setOut(origOut);
|
||||
System.setErr(origErr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.jetbrains.jet.cli;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
@@ -34,16 +34,6 @@ public class CliCommonTest extends CliBaseTest {
|
||||
executeCompilerCompareOutputJVM();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void printArguments() throws Exception {
|
||||
executeCompilerCompareOutputJVM();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void printArgumentsWithManyValue() throws Exception {
|
||||
executeCompilerCompareOutputJS();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simple() throws Exception {
|
||||
executeCompilerCompareOutputJVM();
|
||||
|
||||
@@ -79,11 +79,6 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes
|
||||
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")
|
||||
public void testSignatureClash() throws Exception {
|
||||
doJvmTest("compiler/testData/cli/jvm/signatureClash.args");
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
package org.jetbrains.jet.cli.jvm;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.jet.cli.CliBaseTest;
|
||||
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
@@ -47,11 +47,6 @@ public class K2JvmCliTest extends CliBaseTest {
|
||||
executeCompilerCompareOutputJVM();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void script() throws Exception {
|
||||
executeCompilerCompareOutputJVM();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classpath() throws Exception {
|
||||
executeCompilerCompareOutputJVM();
|
||||
|
||||
Reference in New Issue
Block a user