Separated test data depending on target platform (JS/JVM)

This commit is contained in:
Evgeny Gerashchenko
2013-11-20 21:00:25 +04:00
parent f06e46951f
commit d937909ebf
54 changed files with 23 additions and 22 deletions
@@ -0,0 +1,5 @@
-printArgs
-sourceFiles
$TESTDATA_DIR$/simple2js.kt,$TESTDATA_DIR$/../warnings.kt
-suppress
warnings
@@ -1,3 +1,3 @@
INFO: Invoking compiler org.jetbrains.jet.cli.js.K2JSCompiler with arguments -suppress warnings -printArgs -sourceFiles compiler/testData/cli/simple2js.kt,compiler/testData/cli/warnings.kt
INFO: Invoking compiler org.jetbrains.jet.cli.js.K2JSCompiler with arguments -suppress warnings -printArgs -sourceFiles compiler/testData/cli/js/simple2js.kt,compiler/testData/cli/js/../warnings.kt
ERROR: Specify output file via -output
COMPILATION_ERROR
@@ -1,5 +1,5 @@
-sourceFiles
$TESTDATA_DIR$/warnings.kt
$TESTDATA_DIR$/../warnings.kt
-suppress
WaRnInGs
-output
@@ -0,0 +1,3 @@
INFO: Invoking compiler org.jetbrains.jet.cli.jvm.K2JVMCompiler with arguments -printArgs -script compiler/testData/cli/jvm/hello.ktscript
hello
OK
@@ -1,5 +1,5 @@
-src
$TESTDATA_DIR$/warnings.kt
$TESTDATA_DIR$/../warnings.kt
-suppress
warnings
-output
@@ -1,5 +1,5 @@
-src
$TESTDATA_DIR$/warnings.kt
$TESTDATA_DIR$/../warnings.kt
-suppress
WaRnInGs
-output
-3
View File
@@ -1,3 +0,0 @@
INFO: Invoking compiler org.jetbrains.jet.cli.jvm.K2JVMCompiler with arguments -printArgs -script compiler/testData/cli/hello.ktscript
hello
OK
@@ -1,5 +0,0 @@
-printArgs
-sourceFiles
$TESTDATA_DIR$/simple2js.kt,$TESTDATA_DIR$/warnings.kt
-suppress
warnings
@@ -37,7 +37,8 @@ import java.io.PrintStream;
import java.util.List;
public class CliBaseTest {
private static final String TEST_DATA_HOME = "compiler/testData/cli";
private static final String JS_TEST_DATA = "compiler/testData/cli/js";
private static final String JVM_TEST_DATA = "compiler/testData/cli/jvm";
@Rule
public final Tmpdir tmpdir = new Tmpdir();
@@ -61,16 +62,16 @@ public class CliBaseTest {
}
}
private void executeCompilerCompareOutput(@NotNull CLICompiler<?> compiler) throws Exception {
String actual = executeCompilerGrabOutput(compiler, readArgs())
.replace(new File(TEST_DATA_HOME).getAbsolutePath(), "$TESTDATA_DIR$")
private void executeCompilerCompareOutput(@NotNull CLICompiler<?> compiler, @NotNull String testDataDir) throws Exception {
String actual = executeCompilerGrabOutput(compiler, readArgs(testDataDir))
.replace(new File(testDataDir).getAbsolutePath(), "$TESTDATA_DIR$")
.replace("\\", "/");
JetTestUtils.assertEqualsToFile(new File(TEST_DATA_HOME + "/" + testName.getMethodName() + ".out"), actual);
JetTestUtils.assertEqualsToFile(new File(testDataDir + "/" + testName.getMethodName() + ".out"), actual);
}
private String[] readArgs() throws IOException {
List<String> lines = FileUtil.loadLines(TEST_DATA_HOME + "/" + testName.getMethodName() + ".args");
private String[] readArgs(@NotNull final String testDataDir) throws IOException {
List<String> lines = FileUtil.loadLines(testDataDir + "/" + testName.getMethodName() + ".args");
return ArrayUtil.toStringArray(ContainerUtil.mapNotNull(lines, new Function<String, String>() {
@Override
@@ -81,16 +82,16 @@ public class CliBaseTest {
return arg
.replace(":", File.pathSeparator)
.replace("$TEMP_DIR$", tmpdir.getTmpDir().getPath())
.replace("$TESTDATA_DIR$", TEST_DATA_HOME);
.replace("$TESTDATA_DIR$", testDataDir);
}
}));
}
protected void executeCompilerCompareOutputJVM() throws Exception {
executeCompilerCompareOutput(new K2JVMCompiler());
executeCompilerCompareOutput(new K2JVMCompiler(), JVM_TEST_DATA);
}
protected void executeCompilerCompareOutputJS() throws Exception {
executeCompilerCompareOutput(new K2JSCompiler());
executeCompilerCompareOutput(new K2JSCompiler(), JS_TEST_DATA);
}
}