diff --git a/compiler/integration-tests/data/hello.compile.expected b/compiler/integration-tests/data/compileAndRunHelloApp/hello.compile.expected similarity index 100% rename from compiler/integration-tests/data/hello.compile.expected rename to compiler/integration-tests/data/compileAndRunHelloApp/hello.compile.expected diff --git a/compiler/integration-tests/data/hello.kt b/compiler/integration-tests/data/compileAndRunHelloApp/hello.kt similarity index 100% rename from compiler/integration-tests/data/hello.kt rename to compiler/integration-tests/data/compileAndRunHelloApp/hello.kt diff --git a/compiler/integration-tests/data/hello.run.expected b/compiler/integration-tests/data/compileAndRunHelloApp/hello.run.expected similarity index 100% rename from compiler/integration-tests/data/hello.run.expected rename to compiler/integration-tests/data/compileAndRunHelloApp/hello.run.expected diff --git a/compiler/integration-tests/data/compileAndRunModule/Smoke.compile.expected b/compiler/integration-tests/data/compileAndRunModule/Smoke.compile.expected new file mode 100644 index 00000000000..a14ac74940f --- /dev/null +++ b/compiler/integration-tests/data/compileAndRunModule/Smoke.compile.expected @@ -0,0 +1 @@ +Return code: 0 diff --git a/compiler/integration-tests/data/compileAndRunModule/Smoke.kt b/compiler/integration-tests/data/compileAndRunModule/Smoke.kt new file mode 100644 index 00000000000..dc2ec6c6eb9 --- /dev/null +++ b/compiler/integration-tests/data/compileAndRunModule/Smoke.kt @@ -0,0 +1,5 @@ +package Smoke + +fun main(args: Array) { + print("${args[0]}|${args[1]}|${args[2]}") +} diff --git a/compiler/integration-tests/data/compileAndRunModule/Smoke.kts b/compiler/integration-tests/data/compileAndRunModule/Smoke.kts new file mode 100644 index 00000000000..da112ebae67 --- /dev/null +++ b/compiler/integration-tests/data/compileAndRunModule/Smoke.kts @@ -0,0 +1,7 @@ +import kotlin.modules.* + +fun project() { + module("smoke") { + sources += "Smoke.kt" + } +} diff --git a/compiler/integration-tests/data/compileAndRunModule/Smoke.run.expected b/compiler/integration-tests/data/compileAndRunModule/Smoke.run.expected new file mode 100644 index 00000000000..83e2a5a6dc9 --- /dev/null +++ b/compiler/integration-tests/data/compileAndRunModule/Smoke.run.expected @@ -0,0 +1,2 @@ +OUT 1|2|3 +Return code: 0 diff --git a/compiler/integration-tests/data/help.expected b/compiler/integration-tests/data/help/help.expected similarity index 100% rename from compiler/integration-tests/data/help.expected rename to compiler/integration-tests/data/help/help.expected diff --git a/compiler/integration-tests/src/org/jetbrains/kotlin/CompilerSmokeTest.java b/compiler/integration-tests/src/org/jetbrains/kotlin/CompilerSmokeTest.java index 72d912e47a7..f8dd4c30491 100644 --- a/compiler/integration-tests/src/org/jetbrains/kotlin/CompilerSmokeTest.java +++ b/compiler/integration-tests/src/org/jetbrains/kotlin/CompilerSmokeTest.java @@ -35,4 +35,12 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase { assertEquals("compilation failed", 0, runCompiler("hello.compile", "-src", "hello.kt", "-jar", jar)); 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"); + } } diff --git a/compiler/integration-tests/src/org/jetbrains/kotlin/KotlinIntegrationTestBase.java b/compiler/integration-tests/src/org/jetbrains/kotlin/KotlinIntegrationTestBase.java index dc76dfe6a58..58bc3bdd0f4 100644 --- a/compiler/integration-tests/src/org/jetbrains/kotlin/KotlinIntegrationTestBase.java +++ b/compiler/integration-tests/src/org/jetbrains/kotlin/KotlinIntegrationTestBase.java @@ -46,12 +46,16 @@ import static org.junit.Assert.*; public abstract class KotlinIntegrationTestBase { protected File tempDir; + protected File testDataDir; @Rule public TestRule watchman = new TestWatcher() { @Override protected void starting(Description description) { tempDir = Files.createTempDir(); + + final File baseTestDataDir = new File(getKotlinProjectHome(), "compiler" + File.separator + "integration-tests" + File.separator + "data"); + testDataDir = new File(baseTestDataDir, description.getMethodName()); } @Override @@ -86,7 +90,7 @@ public abstract class KotlinIntegrationTestBase { protected int runJava(String logName, String... arguments) throws Exception { GeneralCommandLine commandLine = new GeneralCommandLine(); - commandLine.setWorkDirectory(getTestDataDirectory()); + commandLine.setWorkDirectory(testDataDir); commandLine.setExePath(getJavaRuntime().getAbsolutePath()); commandLine.addParameters(arguments); @@ -104,27 +108,27 @@ public abstract class KotlinIntegrationTestBase { } protected void check(String baseName, StringBuilder content) throws IOException { - final File tmpFile = new File(getTestDataDirectory(), baseName + ".tmp"); - final File expectedFile = new File(getTestDataDirectory(), baseName + ".expected"); + final File actualFile = new File(testDataDir, baseName + ".actual"); + final File expectedFile = new File(testDataDir, baseName + ".expected"); if (!expectedFile.isFile()) { - Files.write(content, tmpFile, Charsets.UTF_8); + Files.write(content, actualFile, Charsets.UTF_8); fail("No .expected file " + expectedFile); } else { final String goldContent = Files.toString(expectedFile, UTF_8); try { assertEquals(goldContent, content.toString()); - tmpFile.delete(); + actualFile.delete(); } catch (ComparisonFailure e) { - Files.write(content, tmpFile, Charsets.UTF_8); + Files.write(content, actualFile, Charsets.UTF_8); 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 = new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString(), commandLine.getCharset()); @@ -179,8 +183,10 @@ public abstract class KotlinIntegrationTestBase { return file; } - protected static File getTestDataDirectory() { - return new File(getKotlinProjectHome(), "compiler" + File.separator + "integration-tests" + File.separator + "data"); + protected static String getKotlinRuntimePath() { + final File file = new File(getCompilerLib(), "kotlin-runtime.jar"); + assertTrue("no kotlin runtime at " + file, file.isFile()); + return file.getAbsolutePath(); } protected static File getKotlinProjectHome() {