compilation failed integration test

This commit is contained in:
Leonid Shalupov
2012-05-07 17:33:05 +04:00
parent a7a73d8946
commit c6e2a5a9f6
4 changed files with 23 additions and 5 deletions
@@ -0,0 +1,4 @@
OUT ERROR: [TestData]\hello.kt: (4, 5) Unresolved reference: a
OUT WARNING: [TestData]\hello.kt: (4, 5) The expression is unused
ERR exec() finished with COMPILATION_ERROR return code
Return code: 1
@@ -0,0 +1,5 @@
package Hello
fun main(args : Array<String>) {
a
}
@@ -43,4 +43,11 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
assertEquals("compilation failed", 0, runCompiler("Smoke.compile", "-module", "Smoke.kts", "-jar", jar));
runJava("Smoke.run", "-cp", jar + File.pathSeparator + getKotlinRuntimePath(), "Smoke.namespace", "1", "2", "3");
}
@Test
public void compilationFailed() throws Exception {
final String jar = tempDir.getAbsolutePath() + File.separator + "smoke.jar";
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-src", "hello.kt", "-jar", jar));
}
}
@@ -101,28 +101,30 @@ public abstract class KotlinIntegrationTestBase {
assertEquals("Non-zero exit code", 0, exitCode);
}
else {
check(logName, executionLog);
check(logName, executionLog.toString());
}
return exitCode;
}
protected void check(String baseName, StringBuilder content) throws IOException {
protected void check(String baseName, String content) throws IOException {
final File actualFile = new File(testDataDir, baseName + ".actual");
final File expectedFile = new File(testDataDir, baseName + ".expected");
final String normalizedContent = StringUtil.replace(content, testDataDir.getAbsolutePath(), "[TestData]", true);
if (!expectedFile.isFile()) {
Files.write(content, actualFile, Charsets.UTF_8);
Files.write(normalizedContent, actualFile, Charsets.UTF_8);
fail("No .expected file " + expectedFile);
}
else {
final String goldContent = Files.toString(expectedFile, UTF_8);
try {
assertEquals(goldContent, content.toString());
assertEquals(goldContent, normalizedContent);
actualFile.delete();
}
catch (ComparisonFailure e) {
Files.write(content, actualFile, Charsets.UTF_8);
Files.write(normalizedContent, actualFile, Charsets.UTF_8);
throw e;
}
}