diff --git a/compiler/integration-tests/src/org/jetbrains/kotlin/KotlinIntegrationTestBase.java b/compiler/integration-tests/src/org/jetbrains/kotlin/KotlinIntegrationTestBase.java index 067044153e1..7ac3f89692b 100644 --- a/compiler/integration-tests/src/org/jetbrains/kotlin/KotlinIntegrationTestBase.java +++ b/compiler/integration-tests/src/org/jetbrains/kotlin/KotlinIntegrationTestBase.java @@ -19,13 +19,10 @@ package org.jetbrains.kotlin; import com.google.common.base.Charsets; import com.google.common.io.Files; import com.intellij.execution.ExecutionException; +import com.intellij.execution.OutputListener; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.process.OSProcessHandler; -import com.intellij.execution.process.ProcessAdapter; -import com.intellij.execution.process.ProcessEvent; -import com.intellij.execution.process.ProcessOutputTypes; import com.intellij.openapi.application.PathManager; -import com.intellij.openapi.util.Key; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; @@ -119,6 +116,7 @@ public abstract class KotlinIntegrationTestBase { content = normalizePath(content, testDataDir, "[TestData]"); content = normalizePath(content, tmpdir.getTmpDir(), "[Temp]"); content = normalizePath(content, getCompilerLib(), "[CompilerLib]"); + content = StringUtil.convertLineSeparators(content); return content; } @@ -135,6 +133,7 @@ public abstract class KotlinIntegrationTestBase { else { try { JetTestUtils.assertEqualsToFile(expectedFile, normalizedContent); + //noinspection ResultOfMethodCallIgnored actualFile.delete(); } catch (ComparisonFailure e) { @@ -148,41 +147,30 @@ public abstract class KotlinIntegrationTestBase { OSProcessHandler handler = new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString(), commandLine.getCharset()); - final StringBuilder outContent = new StringBuilder(); - final StringBuilder errContent = new StringBuilder(); + StringBuilder outContent = new StringBuilder(); + StringBuilder errContent = new StringBuilder(); - handler.addProcessListener(new ProcessAdapter() { - @Override - public void onTextAvailable(ProcessEvent event, Key outputType) { - if (outputType == ProcessOutputTypes.SYSTEM) { - System.out.print(event.getText()); - } - else if (outputType == ProcessOutputTypes.STDOUT) { - appendToContent(outContent, "OUT ", event.getText()); - } - else if (outputType == ProcessOutputTypes.STDERR) { - appendToContent(errContent, "ERR ", event.getText()); - } - } - - private synchronized void appendToContent(StringBuilder content, String prefix, String line) { - content.append(prefix); - content.append(StringUtil.trimTrailing(line)); - content.append("\n"); - } - }); + handler.addProcessListener(new OutputListener(outContent, errContent)); handler.startNotify(); handler.waitFor(); int exitCode = handler.getProcess().exitValue(); - executionLog.append(outContent); - executionLog.append(errContent); - executionLog.append("Return code: ").append(exitCode).append("\n"); + appendIfNotEmpty(executionLog, "OUT:\n", outContent); + appendIfNotEmpty(executionLog, "\nERR:\n", errContent); + + executionLog.append("\nReturn code: ").append(exitCode).append("\n"); return exitCode; } + private static void appendIfNotEmpty(StringBuilder executionLog, String prefix, StringBuilder content) { + if (content.length() > 0) { + executionLog.append(prefix); + executionLog.append(content); + } + } + protected static File getJavaRuntime() { File javaHome = new File(System.getProperty("java.home")); String javaExe = SystemInfo.isWindows ? "java.exe" : "java"; diff --git a/compiler/integration-tests/testData/antTaskJvm/build.log.expected b/compiler/integration-tests/testData/antTaskJvm/build.log.expected index c71b096d7e8..34c09a5fcbf 100644 --- a/compiler/integration-tests/testData/antTaskJvm/build.log.expected +++ b/compiler/integration-tests/testData/antTaskJvm/build.log.expected @@ -1,8 +1,10 @@ -OUT Buildfile: [TestData]/build.xml -OUT -OUT build: -OUT [kotlinc] Compiling [[[TestData]/hello.kt]] => [[Temp]/hello.jar] -OUT -OUT BUILD SUCCESSFUL -OUT Total time: [time] +OUT: +Buildfile: [TestData]/build.xml + +build: + [kotlinc] Compiling [[[TestData]/hello.kt]] => [[Temp]/hello.jar] + +BUILD SUCCESSFUL +Total time: [time] + Return code: 0 diff --git a/compiler/integration-tests/testData/antTaskJvm/hello.run.expected b/compiler/integration-tests/testData/antTaskJvm/hello.run.expected index a408df3552b..96c6fc52793 100644 --- a/compiler/integration-tests/testData/antTaskJvm/hello.run.expected +++ b/compiler/integration-tests/testData/antTaskJvm/hello.run.expected @@ -1,2 +1,4 @@ -OUT Hello, a! +OUT: +Hello, a! + Return code: 0 diff --git a/compiler/integration-tests/testData/antTaskJvmManyRoots/build.log.expected b/compiler/integration-tests/testData/antTaskJvmManyRoots/build.log.expected index 7607db6a4ad..7dcbaeb2979 100644 --- a/compiler/integration-tests/testData/antTaskJvmManyRoots/build.log.expected +++ b/compiler/integration-tests/testData/antTaskJvmManyRoots/build.log.expected @@ -1,8 +1,10 @@ -OUT Buildfile: [TestData]/build.xml -OUT -OUT build: -OUT [kotlinc] Compiling [[[TestData]/root1, [TestData]/root2]] => [[Temp]/hello.jar] -OUT -OUT BUILD SUCCESSFUL -OUT Total time: [time] +OUT: +Buildfile: [TestData]/build.xml + +build: + [kotlinc] Compiling [[[TestData]/root1, [TestData]/root2]] => [[Temp]/hello.jar] + +BUILD SUCCESSFUL +Total time: [time] + Return code: 0 diff --git a/compiler/integration-tests/testData/antTaskJvmManyRoots/hello.run.expected b/compiler/integration-tests/testData/antTaskJvmManyRoots/hello.run.expected index a408df3552b..96c6fc52793 100644 --- a/compiler/integration-tests/testData/antTaskJvmManyRoots/hello.run.expected +++ b/compiler/integration-tests/testData/antTaskJvmManyRoots/hello.run.expected @@ -1,2 +1,4 @@ -OUT Hello, a! +OUT: +Hello, a! + Return code: 0 diff --git a/compiler/integration-tests/testData/compilationFailed/hello.compile.expected b/compiler/integration-tests/testData/compilationFailed/hello.compile.expected index 9b29ffd47d5..3a2a7c38bc3 100644 --- a/compiler/integration-tests/testData/compilationFailed/hello.compile.expected +++ b/compiler/integration-tests/testData/compilationFailed/hello.compile.expected @@ -1,3 +1,7 @@ -OUT ERROR: [TestData]/hello.kt: (4, 5) Unresolved reference: a -ERR exec() finished with COMPILATION_ERROR return code +OUT: +ERROR: [TestData]/hello.kt: (4, 5) Unresolved reference: a + +ERR: +exec() finished with COMPILATION_ERROR return code + Return code: 1 diff --git a/compiler/integration-tests/testData/compileAndRunHelloApp/hello.run.expected b/compiler/integration-tests/testData/compileAndRunHelloApp/hello.run.expected index fc47ec99014..fd58d467c30 100644 --- a/compiler/integration-tests/testData/compileAndRunHelloApp/hello.run.expected +++ b/compiler/integration-tests/testData/compileAndRunHelloApp/hello.run.expected @@ -1,2 +1,4 @@ -OUT Hello! +OUT: +Hello! + Return code: 0 diff --git a/compiler/integration-tests/testData/compileAndRunModule/Smoke.run.expected b/compiler/integration-tests/testData/compileAndRunModule/Smoke.run.expected index 83e2a5a6dc9..6960c2f4ace 100644 --- a/compiler/integration-tests/testData/compileAndRunModule/Smoke.run.expected +++ b/compiler/integration-tests/testData/compileAndRunModule/Smoke.run.expected @@ -1,2 +1,3 @@ -OUT 1|2|3 +OUT: +1|2|3 Return code: 0 diff --git a/compiler/integration-tests/testData/externalAnnotations/build.log.expected b/compiler/integration-tests/testData/externalAnnotations/build.log.expected index bc21d11bbfc..a49d8d0e5d7 100644 --- a/compiler/integration-tests/testData/externalAnnotations/build.log.expected +++ b/compiler/integration-tests/testData/externalAnnotations/build.log.expected @@ -1,12 +1,14 @@ -OUT Buildfile: [TestData]/build.xml -OUT -OUT build: -OUT [mkdir] Created dir: [Temp]/classes -OUT [javac] Compiling 1 source file to [Temp]/classes -OUT [javac] Compiling [[[TestData]/root1]] => [[Temp]/classes] -OUT [javac] Running javac... -OUT [jar] Building jar: [Temp]/hello.jar -OUT -OUT BUILD SUCCESSFUL -OUT Total time: [time] +OUT: +Buildfile: [TestData]/build.xml + +build: + [mkdir] Created dir: [Temp]/classes + [javac] Compiling 1 source file to [Temp]/classes + [javac] Compiling [[[TestData]/root1]] => [[Temp]/classes] + [javac] Running javac... + [jar] Building jar: [Temp]/hello.jar + +BUILD SUCCESSFUL +Total time: [time] + Return code: 0 diff --git a/compiler/integration-tests/testData/externalAnnotations/hello.run.expected b/compiler/integration-tests/testData/externalAnnotations/hello.run.expected index de564d891df..f36d0378368 100644 --- a/compiler/integration-tests/testData/externalAnnotations/hello.run.expected +++ b/compiler/integration-tests/testData/externalAnnotations/hello.run.expected @@ -1,3 +1,5 @@ -OUT Hello, a! -OUT Java Hello +OUT: +Hello, a! +Java Hello + Return code: 0 diff --git a/compiler/integration-tests/testData/javacCompiler/build.log.expected b/compiler/integration-tests/testData/javacCompiler/build.log.expected index bc21d11bbfc..a49d8d0e5d7 100644 --- a/compiler/integration-tests/testData/javacCompiler/build.log.expected +++ b/compiler/integration-tests/testData/javacCompiler/build.log.expected @@ -1,12 +1,14 @@ -OUT Buildfile: [TestData]/build.xml -OUT -OUT build: -OUT [mkdir] Created dir: [Temp]/classes -OUT [javac] Compiling 1 source file to [Temp]/classes -OUT [javac] Compiling [[[TestData]/root1]] => [[Temp]/classes] -OUT [javac] Running javac... -OUT [jar] Building jar: [Temp]/hello.jar -OUT -OUT BUILD SUCCESSFUL -OUT Total time: [time] +OUT: +Buildfile: [TestData]/build.xml + +build: + [mkdir] Created dir: [Temp]/classes + [javac] Compiling 1 source file to [Temp]/classes + [javac] Compiling [[[TestData]/root1]] => [[Temp]/classes] + [javac] Running javac... + [jar] Building jar: [Temp]/hello.jar + +BUILD SUCCESSFUL +Total time: [time] + Return code: 0 diff --git a/compiler/integration-tests/testData/javacCompiler/hello.run.expected b/compiler/integration-tests/testData/javacCompiler/hello.run.expected index a3346aed731..3f9a7b7bf67 100644 --- a/compiler/integration-tests/testData/javacCompiler/hello.run.expected +++ b/compiler/integration-tests/testData/javacCompiler/hello.run.expected @@ -1,3 +1,5 @@ -OUT Hello, a! -OUT Java +OUT: +Hello, a! +Java + Return code: 0 diff --git a/compiler/integration-tests/testData/k2jsManySources/build.log.expected b/compiler/integration-tests/testData/k2jsManySources/build.log.expected index 2f64f91c577..cd08097efff 100644 --- a/compiler/integration-tests/testData/k2jsManySources/build.log.expected +++ b/compiler/integration-tests/testData/k2jsManySources/build.log.expected @@ -1,8 +1,10 @@ -OUT Buildfile: [TestData]/build.xml -OUT -OUT build: -OUT [kotlin2js] Compiling [[TestData]/root1,[TestData]/bar.kt,[TestData]/root2/Foo.kt] => [[Temp]/out.js] -OUT -OUT BUILD SUCCESSFUL -OUT Total time: [time] +OUT: +Buildfile: [TestData]/build.xml + +build: +[kotlin2js] Compiling [[TestData]/root1,[TestData]/bar.kt,[TestData]/root2/Foo.kt] => [[Temp]/out.js] + +BUILD SUCCESSFUL +Total time: [time] + Return code: 0 diff --git a/compiler/integration-tests/testData/k2jsSimple/build.log.expected b/compiler/integration-tests/testData/k2jsSimple/build.log.expected index c29fac465a5..438f56679ca 100644 --- a/compiler/integration-tests/testData/k2jsSimple/build.log.expected +++ b/compiler/integration-tests/testData/k2jsSimple/build.log.expected @@ -1,8 +1,10 @@ -OUT Buildfile: [TestData]/build.xml -OUT -OUT build: -OUT [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] -OUT -OUT BUILD SUCCESSFUL -OUT Total time: [time] +OUT: +Buildfile: [TestData]/build.xml + +build: +[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] + +BUILD SUCCESSFUL +Total time: [time] + Return code: 0 diff --git a/compiler/integration-tests/testData/k2jsWithMain/build.log.expected b/compiler/integration-tests/testData/k2jsWithMain/build.log.expected index c29fac465a5..438f56679ca 100644 --- a/compiler/integration-tests/testData/k2jsWithMain/build.log.expected +++ b/compiler/integration-tests/testData/k2jsWithMain/build.log.expected @@ -1,8 +1,10 @@ -OUT Buildfile: [TestData]/build.xml -OUT -OUT build: -OUT [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] -OUT -OUT BUILD SUCCESSFUL -OUT Total time: [time] +OUT: +Buildfile: [TestData]/build.xml + +build: +[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] + +BUILD SUCCESSFUL +Total time: [time] + Return code: 0 diff --git a/compiler/integration-tests/testData/k2jsWithPostfix/build.log.expected b/compiler/integration-tests/testData/k2jsWithPostfix/build.log.expected index c29fac465a5..438f56679ca 100644 --- a/compiler/integration-tests/testData/k2jsWithPostfix/build.log.expected +++ b/compiler/integration-tests/testData/k2jsWithPostfix/build.log.expected @@ -1,8 +1,10 @@ -OUT Buildfile: [TestData]/build.xml -OUT -OUT build: -OUT [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] -OUT -OUT BUILD SUCCESSFUL -OUT Total time: [time] +OUT: +Buildfile: [TestData]/build.xml + +build: +[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] + +BUILD SUCCESSFUL +Total time: [time] + Return code: 0 diff --git a/compiler/integration-tests/testData/k2jsWithPrefix/build.log.expected b/compiler/integration-tests/testData/k2jsWithPrefix/build.log.expected index c29fac465a5..438f56679ca 100644 --- a/compiler/integration-tests/testData/k2jsWithPrefix/build.log.expected +++ b/compiler/integration-tests/testData/k2jsWithPrefix/build.log.expected @@ -1,8 +1,10 @@ -OUT Buildfile: [TestData]/build.xml -OUT -OUT build: -OUT [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] -OUT -OUT BUILD SUCCESSFUL -OUT Total time: [time] +OUT: +Buildfile: [TestData]/build.xml + +build: +[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] + +BUILD SUCCESSFUL +Total time: [time] + Return code: 0 diff --git a/compiler/integration-tests/testData/k2jsWithPrefixAndPostfix/build.log.expected b/compiler/integration-tests/testData/k2jsWithPrefixAndPostfix/build.log.expected index c29fac465a5..438f56679ca 100644 --- a/compiler/integration-tests/testData/k2jsWithPrefixAndPostfix/build.log.expected +++ b/compiler/integration-tests/testData/k2jsWithPrefixAndPostfix/build.log.expected @@ -1,8 +1,10 @@ -OUT Buildfile: [TestData]/build.xml -OUT -OUT build: -OUT [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] -OUT -OUT BUILD SUCCESSFUL -OUT Total time: [time] +OUT: +Buildfile: [TestData]/build.xml + +build: +[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] + +BUILD SUCCESSFUL +Total time: [time] + Return code: 0 diff --git a/compiler/integration-tests/testData/k2jsWithSourcemap/build.log.expected b/compiler/integration-tests/testData/k2jsWithSourcemap/build.log.expected index c29fac465a5..438f56679ca 100644 --- a/compiler/integration-tests/testData/k2jsWithSourcemap/build.log.expected +++ b/compiler/integration-tests/testData/k2jsWithSourcemap/build.log.expected @@ -1,8 +1,10 @@ -OUT Buildfile: [TestData]/build.xml -OUT -OUT build: -OUT [kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] -OUT -OUT BUILD SUCCESSFUL -OUT Total time: [time] +OUT: +Buildfile: [TestData]/build.xml + +build: +[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] + +BUILD SUCCESSFUL +Total time: [time] + Return code: 0 diff --git a/compiler/integration-tests/testData/k2jsWithoutOutputParam/build.log.expected b/compiler/integration-tests/testData/k2jsWithoutOutputParam/build.log.expected index 20045e2e76d..995c1550e2c 100644 --- a/compiler/integration-tests/testData/k2jsWithoutOutputParam/build.log.expected +++ b/compiler/integration-tests/testData/k2jsWithoutOutputParam/build.log.expected @@ -1,9 +1,13 @@ -OUT Buildfile: [TestData]/build.xml -OUT -OUT build: -ERR -ERR BUILD FAILED -ERR [TestData]/build.xml:5: "output" should be specified -ERR -ERR Total time: [time] +OUT: +Buildfile: [TestData]/build.xml + +build: + +ERR: + +BUILD FAILED +[TestData]/build.xml:5: "output" should be specified + +Total time: [time] + Return code: 1 diff --git a/compiler/integration-tests/testData/k2jsWithoutSrcParam/build.log.expected b/compiler/integration-tests/testData/k2jsWithoutSrcParam/build.log.expected index 70834e184c6..e27b44df889 100644 --- a/compiler/integration-tests/testData/k2jsWithoutSrcParam/build.log.expected +++ b/compiler/integration-tests/testData/k2jsWithoutSrcParam/build.log.expected @@ -1,9 +1,13 @@ -OUT Buildfile: [TestData]/build.xml -OUT -OUT build: -ERR -ERR BUILD FAILED -ERR [TestData]/build.xml:5: "src" should be specified -ERR -ERR Total time: [time] +OUT: +Buildfile: [TestData]/build.xml + +build: + +ERR: + +BUILD FAILED +[TestData]/build.xml:5: "src" should be specified + +Total time: [time] + Return code: 1 diff --git a/compiler/integration-tests/testData/kotlinCompiler/build.log.expected b/compiler/integration-tests/testData/kotlinCompiler/build.log.expected index 25ee1864938..62250d3a0ad 100644 --- a/compiler/integration-tests/testData/kotlinCompiler/build.log.expected +++ b/compiler/integration-tests/testData/kotlinCompiler/build.log.expected @@ -1,11 +1,13 @@ -OUT Buildfile: [TestData]/build.xml -OUT -OUT build: -OUT [mkdir] Created dir: [Temp]/classes -OUT [kotlinc] Compiling [[[TestData]/root1]] => [[Temp]/classes] -OUT [javac] Compiling 1 source file to [Temp]/classes -OUT [jar] Building jar: [Temp]/hello.jar -OUT -OUT BUILD SUCCESSFUL -OUT Total time: [time] +OUT: +Buildfile: [TestData]/build.xml + +build: + [mkdir] Created dir: [Temp]/classes + [kotlinc] Compiling [[[TestData]/root1]] => [[Temp]/classes] + [javac] Compiling 1 source file to [Temp]/classes + [jar] Building jar: [Temp]/hello.jar + +BUILD SUCCESSFUL +Total time: [time] + Return code: 0 diff --git a/compiler/integration-tests/testData/kotlinCompiler/hello.run.expected b/compiler/integration-tests/testData/kotlinCompiler/hello.run.expected index de564d891df..f36d0378368 100644 --- a/compiler/integration-tests/testData/kotlinCompiler/hello.run.expected +++ b/compiler/integration-tests/testData/kotlinCompiler/hello.run.expected @@ -1,3 +1,5 @@ -OUT Hello, a! -OUT Java Hello +OUT: +Hello, a! +Java Hello + Return code: 0 diff --git a/compiler/integration-tests/testData/syntaxErrors/test.compile.expected b/compiler/integration-tests/testData/syntaxErrors/test.compile.expected index 9e7cf8182e1..eb371a9470c 100644 --- a/compiler/integration-tests/testData/syntaxErrors/test.compile.expected +++ b/compiler/integration-tests/testData/syntaxErrors/test.compile.expected @@ -1,3 +1,7 @@ -OUT ERROR: [TestData]/test.kt: (4, 20) Expecting an element -ERR exec() finished with COMPILATION_ERROR return code +OUT: +ERROR: [TestData]/test.kt: (4, 20) Expecting an element + +ERR: +exec() finished with COMPILATION_ERROR return code + Return code: 1