Moved args into test data of cli tests.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
-src
|
||||
$TESTDATA_DIR$/diagnosticsOrder1.kt:$TESTDATA_DIR$/diagnosticsOrder2.kt
|
||||
-output
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1 @@
|
||||
-help
|
||||
@@ -0,0 +1,4 @@
|
||||
-src
|
||||
$TESTDATA_DIR$/multipleTextRangesInDiagnosticsOrder.kt
|
||||
-output
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1,8 @@
|
||||
-src
|
||||
$TESTDATA_DIR$/simple.kt
|
||||
-classpath
|
||||
not/existing/path
|
||||
-annotations
|
||||
yet/another/not/existing/path
|
||||
-output
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1,4 @@
|
||||
-src
|
||||
not/existing/path
|
||||
-output
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1,6 @@
|
||||
-sourceFiles
|
||||
$TESTDATA_DIR$/simple2js.kt
|
||||
-output
|
||||
$TEMP_DIR$/out.js
|
||||
-outputPostfix
|
||||
not/existing/path
|
||||
@@ -0,0 +1,6 @@
|
||||
-sourceFiles
|
||||
$TESTDATA_DIR$/simple2js.kt
|
||||
-output
|
||||
$TEMP_DIR$/out.js
|
||||
-outputPrefix
|
||||
not/existing/path
|
||||
@@ -0,0 +1,3 @@
|
||||
-printArgs
|
||||
-script
|
||||
$TESTDATA_DIR$/hello.ktscript
|
||||
@@ -0,0 +1,5 @@
|
||||
-printArgs
|
||||
-sourceFiles
|
||||
$TESTDATA_DIR$/simple2js.kt,$TESTDATA_DIR$/warnings.kt
|
||||
-suppress
|
||||
warnings
|
||||
@@ -0,0 +1,4 @@
|
||||
-script
|
||||
$TESTDATA_DIR$/script.ktscript
|
||||
hi
|
||||
there
|
||||
@@ -0,0 +1,4 @@
|
||||
-src
|
||||
$TESTDATA_DIR$/simple.kt
|
||||
-output
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1,4 @@
|
||||
-sourceFiles
|
||||
$TESTDATA_DIR$/simple2js.kt
|
||||
-output
|
||||
$TEMP_DIR$/out.js
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,6 @@
|
||||
-sourceFiles
|
||||
$TESTDATA_DIR$/warnings.kt
|
||||
-suppress
|
||||
WaRnInGs
|
||||
-output
|
||||
$TEMP_DIR$/out.js
|
||||
@@ -0,0 +1,6 @@
|
||||
-src
|
||||
$TESTDATA_DIR$/warnings.kt
|
||||
-suppress
|
||||
warnings
|
||||
-output
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1,6 @@
|
||||
-src
|
||||
$TESTDATA_DIR$/warnings.kt
|
||||
-suppress
|
||||
WaRnInGs
|
||||
-output
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1,6 @@
|
||||
-src
|
||||
$TESTDATA_DIR$/wrongAbiVersion.kt
|
||||
-classpath
|
||||
$TESTDATA_DIR$/wrongAbiVersionLib
|
||||
-output
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1 @@
|
||||
-wrongArgument
|
||||
@@ -0,0 +1,6 @@
|
||||
-src
|
||||
$TESTDATA_DIR$/wrongKotlinSignature.kt
|
||||
-classpath
|
||||
$TESTDATA_DIR$/wrongKotlinSignatureLib
|
||||
-output
|
||||
$TEMP_DIR$
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
package org.jetbrains.jet.cli.jvm;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.cli.common.CLICompiler;
|
||||
@@ -28,10 +32,12 @@ import org.junit.rules.TestName;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.List;
|
||||
|
||||
public class CliBaseTest {
|
||||
protected static final String NOT_EXISTING_PATH = "not/existing/path";
|
||||
private static final String TEST_DATA_HOME = "compiler/testData/cli";
|
||||
|
||||
@Rule
|
||||
public final Tmpdir tmpdir = new Tmpdir();
|
||||
@@ -55,19 +61,36 @@ public class CliBaseTest {
|
||||
}
|
||||
}
|
||||
|
||||
private void executeCompilerCompareOutput(@NotNull CLICompiler<?> compiler, @NotNull String[] args) {
|
||||
String actual = executeCompilerGrabOutput(compiler, args)
|
||||
.replace(new File("compiler/testData/cli/").getAbsolutePath(), "$TESTDATA_DIR$")
|
||||
private void executeCompilerCompareOutput(@NotNull CLICompiler<?> compiler) throws Exception {
|
||||
String actual = executeCompilerGrabOutput(compiler, readArgs())
|
||||
.replace(new File(TEST_DATA_HOME).getAbsolutePath(), "$TESTDATA_DIR$")
|
||||
.replace("\\", "/");
|
||||
|
||||
JetTestUtils.assertEqualsToFile(new File("compiler/testData/cli/" + testName.getMethodName() + ".out"), actual);
|
||||
JetTestUtils.assertEqualsToFile(new File(TEST_DATA_HOME + "/" + testName.getMethodName() + ".out"), actual);
|
||||
}
|
||||
|
||||
protected void executeCompilerCompareOutputJVM(@NotNull String[] args) {
|
||||
executeCompilerCompareOutput(new K2JVMCompiler(), args);
|
||||
private String[] readArgs() throws IOException {
|
||||
List<String> lines = FileUtil.loadLines(TEST_DATA_HOME + "/" + testName.getMethodName() + ".args");
|
||||
|
||||
return ArrayUtil.toStringArray(ContainerUtil.mapNotNull(lines, new Function<String, String>() {
|
||||
@Override
|
||||
public String fun(String arg) {
|
||||
if (arg.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return arg
|
||||
.replace(":", File.pathSeparator)
|
||||
.replace("$TEMP_DIR$", tmpdir.getTmpDir().getPath())
|
||||
.replace("$TESTDATA_DIR$", TEST_DATA_HOME);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
protected void executeCompilerCompareOutputJS(@NotNull String[] args) {
|
||||
executeCompilerCompareOutput(new K2JSCompiler(), args);
|
||||
protected void executeCompilerCompareOutputJVM() throws Exception {
|
||||
executeCompilerCompareOutput(new K2JVMCompiler());
|
||||
}
|
||||
|
||||
protected void executeCompilerCompareOutputJS() throws Exception {
|
||||
executeCompilerCompareOutput(new K2JSCompiler());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,79 +26,53 @@ import java.io.File;
|
||||
public class CliCommonTest extends CliBaseTest {
|
||||
@Test
|
||||
public void help() throws Exception {
|
||||
executeCompilerCompareOutputJVM(new String[] {"-help"});
|
||||
executeCompilerCompareOutputJVM();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wrongArgument() {
|
||||
executeCompilerCompareOutputJVM(new String[] {"-wrongArgument"});
|
||||
public void wrongArgument() throws Exception {
|
||||
executeCompilerCompareOutputJVM();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void printArguments() {
|
||||
executeCompilerCompareOutputJVM(new String[] {"-printArgs", "-script", "compiler/testData/cli/hello.ktscript"});
|
||||
public void printArguments() throws Exception {
|
||||
executeCompilerCompareOutputJVM();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void printArgumentsWithManyValue() {
|
||||
executeCompilerCompareOutputJS(new String[] {
|
||||
"-printArgs",
|
||||
"-sourceFiles", "compiler/testData/cli/simple2js.kt,compiler/testData/cli/warnings.kt",
|
||||
"-suppress", "warnings"});
|
||||
public void printArgumentsWithManyValue() throws Exception {
|
||||
executeCompilerCompareOutputJS();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simple() throws Exception {
|
||||
String[] args = {
|
||||
"-src", "compiler/testData/cli/simple.kt",
|
||||
"-output", tmpdir.getTmpDir().getPath()};
|
||||
executeCompilerCompareOutputJVM(args);
|
||||
executeCompilerCompareOutputJVM();
|
||||
|
||||
Assert.assertTrue(new File(tmpdir.getTmpDir(), PackageClassUtils.getPackageClassName(FqName.ROOT) + ".class").isFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void diagnosticsOrder() throws Exception {
|
||||
String[] args = {
|
||||
"-src", "compiler/testData/cli/diagnosticsOrder1.kt"
|
||||
+ File.pathSeparator
|
||||
+ "compiler/testData/cli/diagnosticsOrder2.kt",
|
||||
"-output", tmpdir.getTmpDir().getPath()};
|
||||
executeCompilerCompareOutputJVM(args);
|
||||
executeCompilerCompareOutputJVM();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multipleTextRangesInDiagnosticsOrder() throws Exception {
|
||||
String[] args = {
|
||||
"-src", "compiler/testData/cli/multipleTextRangesInDiagnosticsOrder.kt",
|
||||
"-output", tmpdir.getTmpDir().getPath()};
|
||||
executeCompilerCompareOutputJVM(args);
|
||||
executeCompilerCompareOutputJVM();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suppressAllWarningsLowercase() {
|
||||
String[] args = {
|
||||
"-src", "compiler/testData/cli/warnings.kt",
|
||||
"-suppress", "warnings",
|
||||
"-output", tmpdir.getTmpDir().getPath()};
|
||||
executeCompilerCompareOutputJVM(args);
|
||||
public void suppressAllWarningsLowercase() throws Exception {
|
||||
executeCompilerCompareOutputJVM();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suppressAllWarningsMixedCase() {
|
||||
String[] args = {
|
||||
"-src", "compiler/testData/cli/warnings.kt",
|
||||
"-suppress", "WaRnInGs",
|
||||
"-output", tmpdir.getTmpDir().getPath()};
|
||||
executeCompilerCompareOutputJVM(args);
|
||||
public void suppressAllWarningsMixedCase() throws Exception {
|
||||
executeCompilerCompareOutputJVM();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suppressAllWarningsJS() {
|
||||
String[] args = {
|
||||
"-sourceFiles", "compiler/testData/cli/warnings.kt",
|
||||
"-suppress", "WaRnInGs",
|
||||
"-output", new File(tmpdir.getTmpDir(), "out.js").getPath()};
|
||||
executeCompilerCompareOutputJS(args);
|
||||
public void suppressAllWarningsJS() throws Exception {
|
||||
executeCompilerCompareOutputJS();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,42 +16,30 @@
|
||||
|
||||
package org.jetbrains.jet.cli.jvm;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import junit.framework.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class K2JsCliTest extends CliBaseTest {
|
||||
@Test
|
||||
public void simple() {
|
||||
doSimpleTest(/*expectedOutFile =*/ true);
|
||||
public void simple2js() throws Exception {
|
||||
executeCompilerCompareOutputJS();
|
||||
|
||||
Assert.assertTrue(new File(tmpdir.getTmpDir(), "out.js").isFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void outputPrefixFileNotFound() {
|
||||
doSimpleTest(/*expectedOutFile =*/ false,
|
||||
"-outputPrefix", NOT_EXISTING_PATH);
|
||||
public void outputPrefixFileNotFound() throws Exception {
|
||||
executeCompilerCompareOutputJS();
|
||||
|
||||
Assert.assertFalse(new File(tmpdir.getTmpDir(), "out.js").isFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void outputPostfixFileNotFound() {
|
||||
doSimpleTest(/*expectedOutFile =*/ false,
|
||||
"-outputPostfix", NOT_EXISTING_PATH);
|
||||
}
|
||||
public void outputPostfixFileNotFound() throws Exception {
|
||||
executeCompilerCompareOutputJS();
|
||||
|
||||
private void doSimpleTest(boolean expectedOutFile, String... additionalArgs) {
|
||||
File outputFile = new File(tmpdir.getTmpDir(), "out.js");
|
||||
List<String> args = Lists.newArrayList(
|
||||
"-sourceFiles", "compiler/testData/cli/simple2js.kt",
|
||||
"-output", outputFile.getPath());
|
||||
Collections.addAll(args, additionalArgs);
|
||||
|
||||
executeCompilerCompareOutputJS(ArrayUtil.toStringArray(args));
|
||||
|
||||
Assert.assertEquals(expectedOutFile, outputFile.isFile());
|
||||
Assert.assertFalse(new File(tmpdir.getTmpDir(), "out.js").isFile());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,44 +24,25 @@ import org.junit.Test;
|
||||
import java.io.File;
|
||||
|
||||
public class K2JvmCliTest extends CliBaseTest {
|
||||
|
||||
protected static final String ANOTHER_NOT_EXISTING_PATH = "yet/another/not/existing/path";
|
||||
|
||||
@Test
|
||||
public void wrongKotlinSignature() throws Exception {
|
||||
String[] args = {
|
||||
"-src", "compiler/testData/cli/wrongKotlinSignature.kt",
|
||||
"-classpath", "compiler/testData/cli/wrongKotlinSignatureLib",
|
||||
"-output", tmpdir.getTmpDir().getPath()};
|
||||
executeCompilerCompareOutputJVM(args);
|
||||
executeCompilerCompareOutputJVM();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wrongAbiVersion() throws Exception {
|
||||
String[] args = {
|
||||
"-src", "compiler/testData/cli/wrongAbiVersion.kt",
|
||||
"-classpath", "compiler/testData/cli/wrongAbiVersionLib",
|
||||
"-output", tmpdir.getTmpDir().getPath()};
|
||||
executeCompilerCompareOutputJVM(args);
|
||||
executeCompilerCompareOutputJVM();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonExistingClassPathAndAnnotationsPath() {
|
||||
String[] args = {
|
||||
"-src", "compiler/testData/cli/simple.kt",
|
||||
"-classpath", NOT_EXISTING_PATH,
|
||||
"-annotations", ANOTHER_NOT_EXISTING_PATH,
|
||||
"-output", tmpdir.getTmpDir().getPath()};
|
||||
executeCompilerCompareOutputJVM(args);
|
||||
public void nonExistingClassPathAndAnnotationsPath() throws Exception {
|
||||
executeCompilerCompareOutputJVM();
|
||||
|
||||
Assert.assertTrue(new File(tmpdir.getTmpDir(), PackageClassUtils.getPackageClassName(FqName.ROOT) + ".class").isFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonExistingSourcePath() {
|
||||
String[] args = {
|
||||
"-src", NOT_EXISTING_PATH,
|
||||
"-output", tmpdir.getTmpDir().getPath()};
|
||||
executeCompilerCompareOutputJVM(args);
|
||||
public void nonExistingSourcePath() throws Exception {
|
||||
executeCompilerCompareOutputJVM();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ import java.util.List;
|
||||
public class ScriptTest extends CliBaseTest {
|
||||
@Test
|
||||
public void script() throws Exception {
|
||||
executeCompilerCompareOutputJVM(new String[] {"-script", "compiler/testData/cli/script.ktscript", "hi", "there"});
|
||||
executeCompilerCompareOutputJVM();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user