module compilation integration tests + changed test data layout
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
Return code: 0
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package Smoke
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
print("${args[0]}|${args[1]}|${args[2]}")
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import kotlin.modules.*
|
||||||
|
|
||||||
|
fun project() {
|
||||||
|
module("smoke") {
|
||||||
|
sources += "Smoke.kt"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
OUT 1|2|3
|
||||||
|
Return code: 0
|
||||||
@@ -35,4 +35,12 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
|
|||||||
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-src", "hello.kt", "-jar", jar));
|
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-src", "hello.kt", "-jar", jar));
|
||||||
runJava("hello.run", "-cp", jar, "Hello.namespace");
|
runJava("hello.run", "-cp", jar, "Hello.namespace");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void compileAndRunModule() throws Exception {
|
||||||
|
final String jar = tempDir.getAbsolutePath() + File.separator + "smoke.jar";
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,12 +46,16 @@ import static org.junit.Assert.*;
|
|||||||
|
|
||||||
public abstract class KotlinIntegrationTestBase {
|
public abstract class KotlinIntegrationTestBase {
|
||||||
protected File tempDir;
|
protected File tempDir;
|
||||||
|
protected File testDataDir;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public TestRule watchman = new TestWatcher() {
|
public TestRule watchman = new TestWatcher() {
|
||||||
@Override
|
@Override
|
||||||
protected void starting(Description description) {
|
protected void starting(Description description) {
|
||||||
tempDir = Files.createTempDir();
|
tempDir = Files.createTempDir();
|
||||||
|
|
||||||
|
final File baseTestDataDir = new File(getKotlinProjectHome(), "compiler" + File.separator + "integration-tests" + File.separator + "data");
|
||||||
|
testDataDir = new File(baseTestDataDir, description.getMethodName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -86,7 +90,7 @@ public abstract class KotlinIntegrationTestBase {
|
|||||||
|
|
||||||
protected int runJava(String logName, String... arguments) throws Exception {
|
protected int runJava(String logName, String... arguments) throws Exception {
|
||||||
GeneralCommandLine commandLine = new GeneralCommandLine();
|
GeneralCommandLine commandLine = new GeneralCommandLine();
|
||||||
commandLine.setWorkDirectory(getTestDataDirectory());
|
commandLine.setWorkDirectory(testDataDir);
|
||||||
commandLine.setExePath(getJavaRuntime().getAbsolutePath());
|
commandLine.setExePath(getJavaRuntime().getAbsolutePath());
|
||||||
commandLine.addParameters(arguments);
|
commandLine.addParameters(arguments);
|
||||||
|
|
||||||
@@ -104,27 +108,27 @@ public abstract class KotlinIntegrationTestBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void check(String baseName, StringBuilder content) throws IOException {
|
protected void check(String baseName, StringBuilder content) throws IOException {
|
||||||
final File tmpFile = new File(getTestDataDirectory(), baseName + ".tmp");
|
final File actualFile = new File(testDataDir, baseName + ".actual");
|
||||||
final File expectedFile = new File(getTestDataDirectory(), baseName + ".expected");
|
final File expectedFile = new File(testDataDir, baseName + ".expected");
|
||||||
|
|
||||||
if (!expectedFile.isFile()) {
|
if (!expectedFile.isFile()) {
|
||||||
Files.write(content, tmpFile, Charsets.UTF_8);
|
Files.write(content, actualFile, Charsets.UTF_8);
|
||||||
fail("No .expected file " + expectedFile);
|
fail("No .expected file " + expectedFile);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final String goldContent = Files.toString(expectedFile, UTF_8);
|
final String goldContent = Files.toString(expectedFile, UTF_8);
|
||||||
try {
|
try {
|
||||||
assertEquals(goldContent, content.toString());
|
assertEquals(goldContent, content.toString());
|
||||||
tmpFile.delete();
|
actualFile.delete();
|
||||||
}
|
}
|
||||||
catch (ComparisonFailure e) {
|
catch (ComparisonFailure e) {
|
||||||
Files.write(content, tmpFile, Charsets.UTF_8);
|
Files.write(content, actualFile, Charsets.UTF_8);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int runProcess(final GeneralCommandLine commandLine, final StringBuilder executionLog) throws ExecutionException {
|
protected static int runProcess(final GeneralCommandLine commandLine, final StringBuilder executionLog) throws ExecutionException {
|
||||||
OSProcessHandler handler =
|
OSProcessHandler handler =
|
||||||
new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString(), commandLine.getCharset());
|
new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString(), commandLine.getCharset());
|
||||||
|
|
||||||
@@ -179,8 +183,10 @@ public abstract class KotlinIntegrationTestBase {
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static File getTestDataDirectory() {
|
protected static String getKotlinRuntimePath() {
|
||||||
return new File(getKotlinProjectHome(), "compiler" + File.separator + "integration-tests" + File.separator + "data");
|
final File file = new File(getCompilerLib(), "kotlin-runtime.jar");
|
||||||
|
assertTrue("no kotlin runtime at " + file, file.isFile());
|
||||||
|
return file.getAbsolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static File getKotlinProjectHome() {
|
protected static File getKotlinProjectHome() {
|
||||||
|
|||||||
Reference in New Issue
Block a user