CLI tests: rename CliBaseTest to AbstractCliTest
This commit is contained in:
committed by
Alexander Udalov
parent
762504d5e4
commit
a53166b732
+1
-1
@@ -45,7 +45,7 @@ import java.io.PrintStream;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class CliBaseTest extends TestCaseWithTmpdir {
|
public abstract class AbstractCliTest extends TestCaseWithTmpdir {
|
||||||
static final String JS_TEST_DATA = "compiler/testData/cli/js";
|
static final String JS_TEST_DATA = "compiler/testData/cli/js";
|
||||||
static final String JVM_TEST_DATA = "compiler/testData/cli/jvm";
|
static final String JVM_TEST_DATA = "compiler/testData/cli/jvm";
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ public abstract class AbstractKotlincExecutableTest extends TestCaseWithTmpdir {
|
|||||||
File kotlincFile = new File(PathUtil.getKotlinPathsForDistDirectory().getHomePath(), "bin/" + executableFileName);
|
File kotlincFile = new File(PathUtil.getKotlinPathsForDistDirectory().getHomePath(), "bin/" + executableFileName);
|
||||||
assertTrue("kotlinc executable not found, probably you need to invoke 'dist' Ant target: " + kotlincFile.getAbsolutePath(), kotlincFile.exists());
|
assertTrue("kotlinc executable not found, probably you need to invoke 'dist' Ant target: " + kotlincFile.getAbsolutePath(), kotlincFile.exists());
|
||||||
|
|
||||||
List<String> args = CliBaseTest.readArgs(argsFilePath, testDataDir, tmpdir.getAbsolutePath());
|
List<String> args = AbstractCliTest.readArgs(argsFilePath, testDataDir, tmpdir.getAbsolutePath());
|
||||||
args.add(0, kotlincFile.getAbsolutePath());
|
args.add(0, kotlincFile.getAbsolutePath());
|
||||||
ProcessOutput processOutput = ExecUtil.execAndGetOutput(args, null);
|
ProcessOutput processOutput = ExecUtil.execAndGetOutput(args, null);
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ public abstract class AbstractKotlincExecutableTest extends TestCaseWithTmpdir {
|
|||||||
String stderr = processOutput.getStderr();
|
String stderr = processOutput.getStderr();
|
||||||
int exitCode = processOutput.getExitCode();
|
int exitCode = processOutput.getExitCode();
|
||||||
|
|
||||||
String normalizedOutput = CliBaseTest.getNormalizedCompilerOutput(stderr, ExitCode.values()[exitCode], testDataDir);
|
String normalizedOutput = AbstractCliTest.getNormalizedCompilerOutput(stderr, ExitCode.values()[exitCode], testDataDir);
|
||||||
File outFile = new File(argsFilePath.replace(".args", ".out"));
|
File outFile = new File(argsFilePath.replace(".args", ".out"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -58,10 +58,10 @@ public abstract class AbstractKotlincExecutableTest extends TestCaseWithTmpdir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void doJvmTest(@NotNull String argsFilePath) throws Exception {
|
protected void doJvmTest(@NotNull String argsFilePath) throws Exception {
|
||||||
doTest(argsFilePath, "kotlinc-jvm", CliBaseTest.JVM_TEST_DATA);
|
doTest(argsFilePath, "kotlinc-jvm", AbstractCliTest.JVM_TEST_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doJsTest(@NotNull String argsFilePath) throws Exception {
|
protected void doJsTest(@NotNull String argsFilePath) throws Exception {
|
||||||
doTest(argsFilePath, "kotlinc-js", CliBaseTest.JS_TEST_DATA);
|
doTest(argsFilePath, "kotlinc-js", AbstractCliTest.JS_TEST_DATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class WrongBytecodeVersionTest : UsefulTestCase() {
|
|||||||
changeVersionInBytecode(classFile)
|
changeVersionInBytecode(classFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
val (output, exitCode) = CliBaseTest.executeCompilerGrabOutput(K2JVMCompiler(), listOf(
|
val (output, exitCode) = AbstractCliTest.executeCompilerGrabOutput(K2JVMCompiler(), listOf(
|
||||||
usageSource.path,
|
usageSource.path,
|
||||||
"-classpath", tmpdir.path,
|
"-classpath", tmpdir.path,
|
||||||
"-d", tmpdir.path
|
"-d", tmpdir.path
|
||||||
@@ -53,7 +53,7 @@ class WrongBytecodeVersionTest : UsefulTestCase() {
|
|||||||
|
|
||||||
assertEquals("Compilation error expected", ExitCode.COMPILATION_ERROR, exitCode)
|
assertEquals("Compilation error expected", ExitCode.COMPILATION_ERROR, exitCode)
|
||||||
|
|
||||||
val normalized = CliBaseTest.getNormalizedCompilerOutput(output, exitCode, tmpdir.path, JvmBytecodeBinaryVersion.INSTANCE)
|
val normalized = AbstractCliTest.getNormalizedCompilerOutput(output, exitCode, tmpdir.path, JvmBytecodeBinaryVersion.INSTANCE)
|
||||||
|
|
||||||
KotlinTestUtils.assertEqualsToFile(File(directory, "output.txt"), normalized)
|
KotlinTestUtils.assertEqualsToFile(File(directory, "output.txt"), normalized)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.cli.js;
|
package org.jetbrains.kotlin.cli.js;
|
||||||
|
|
||||||
import org.jetbrains.kotlin.cli.CliBaseTest;
|
import org.jetbrains.kotlin.cli.AbstractCliTest;
|
||||||
|
|
||||||
public class K2JsCliTest extends CliBaseTest {
|
public class K2JsCliTest extends AbstractCliTest {
|
||||||
public void testSimple2js() throws Exception {
|
public void testSimple2js() throws Exception {
|
||||||
executeCompilerCompareOutputJS();
|
executeCompilerCompareOutputJS();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.cli.jvm;
|
package org.jetbrains.kotlin.cli.jvm;
|
||||||
|
|
||||||
import org.jetbrains.kotlin.cli.CliBaseTest;
|
import org.jetbrains.kotlin.cli.AbstractCliTest;
|
||||||
|
|
||||||
public class K2JvmCliTest extends CliBaseTest {
|
public class K2JvmCliTest extends AbstractCliTest {
|
||||||
public void testWrongAbiVersion() throws Exception {
|
public void testWrongAbiVersion() throws Exception {
|
||||||
executeCompilerCompareOutputJVM();
|
executeCompilerCompareOutputJVM();
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-8
@@ -23,7 +23,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
|||||||
import kotlin.Pair;
|
import kotlin.Pair;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.analyzer.AnalysisResult;
|
import org.jetbrains.kotlin.analyzer.AnalysisResult;
|
||||||
import org.jetbrains.kotlin.cli.CliBaseTest;
|
import org.jetbrains.kotlin.cli.AbstractCliTest;
|
||||||
import org.jetbrains.kotlin.cli.common.ExitCode;
|
import org.jetbrains.kotlin.cli.common.ExitCode;
|
||||||
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport;
|
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport;
|
||||||
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector;
|
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector;
|
||||||
@@ -77,7 +77,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private String normalizeOutput(@NotNull Pair<String, ExitCode> output) {
|
private String normalizeOutput(@NotNull Pair<String, ExitCode> output) {
|
||||||
return CliBaseTest.getNormalizedCompilerOutput(output.getFirst(), output.getSecond(), getTestDataDirectory().getPath());
|
return AbstractCliTest.getNormalizedCompilerOutput(output.getFirst(), output.getSecond(), getTestDataDirectory().getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doTestWithTxt(@NotNull File... extraClassPath) throws Exception {
|
private void doTestWithTxt(@NotNull File... extraClassPath) throws Exception {
|
||||||
@@ -159,7 +159,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
|||||||
|
|
||||||
File libSrc = new File(getTestDataDirectory(), "library/test/lib.kt");
|
File libSrc = new File(getTestDataDirectory(), "library/test/lib.kt");
|
||||||
|
|
||||||
Pair<String, ExitCode> outputLib = CliBaseTest.executeCompilerGrabOutput(new K2JVMCompiler(), Arrays.asList(
|
Pair<String, ExitCode> outputLib = AbstractCliTest.executeCompilerGrabOutput(new K2JVMCompiler(), Arrays.asList(
|
||||||
libSrc.getPath(),
|
libSrc.getPath(),
|
||||||
"-classpath", tmpdir.getPath(),
|
"-classpath", tmpdir.getPath(),
|
||||||
"-d", tmpdir.getPath()
|
"-d", tmpdir.getPath()
|
||||||
@@ -167,7 +167,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
|||||||
|
|
||||||
File mainSrc = new File(getTestDataDirectory(), "main.kt");
|
File mainSrc = new File(getTestDataDirectory(), "main.kt");
|
||||||
|
|
||||||
Pair<String, ExitCode> outputMain = CliBaseTest.executeCompilerGrabOutput(new K2JVMCompiler(), Arrays.asList(
|
Pair<String, ExitCode> outputMain = AbstractCliTest.executeCompilerGrabOutput(new K2JVMCompiler(), Arrays.asList(
|
||||||
mainSrc.getPath(),
|
mainSrc.getPath(),
|
||||||
"-classpath", tmpdir.getPath(),
|
"-classpath", tmpdir.getPath(),
|
||||||
"-d", tmpdir.getPath()
|
"-d", tmpdir.getPath()
|
||||||
@@ -240,7 +240,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
|||||||
|
|
||||||
File source = new File(getTestDataDirectory(), "source.kt");
|
File source = new File(getTestDataDirectory(), "source.kt");
|
||||||
|
|
||||||
Pair<String, ExitCode> output = CliBaseTest.executeCompilerGrabOutput(new K2JVMCompiler(), Arrays.asList(
|
Pair<String, ExitCode> output = AbstractCliTest.executeCompilerGrabOutput(new K2JVMCompiler(), Arrays.asList(
|
||||||
source.getPath(),
|
source.getPath(),
|
||||||
"-classpath", tmpdir.getPath(),
|
"-classpath", tmpdir.getPath(),
|
||||||
"-d", tmpdir.getPath()
|
"-d", tmpdir.getPath()
|
||||||
@@ -256,7 +256,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
|||||||
|
|
||||||
File source = new File(getTestDataDirectory(), "source.kt");
|
File source = new File(getTestDataDirectory(), "source.kt");
|
||||||
|
|
||||||
Pair<String, ExitCode> output = CliBaseTest.executeCompilerGrabOutput(new K2JVMCompiler(), Arrays.asList(
|
Pair<String, ExitCode> output = AbstractCliTest.executeCompilerGrabOutput(new K2JVMCompiler(), Arrays.asList(
|
||||||
source.getPath(),
|
source.getPath(),
|
||||||
"-classpath", library.getPath(),
|
"-classpath", library.getPath(),
|
||||||
"-d", tmpdir.getPath()
|
"-d", tmpdir.getPath()
|
||||||
@@ -269,7 +269,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
|||||||
public void testInlineFunWithoutDebugInfo() throws Exception {
|
public void testInlineFunWithoutDebugInfo() throws Exception {
|
||||||
File inlineSource = new File(getTestDataDirectory(), "sourceInline.kt");
|
File inlineSource = new File(getTestDataDirectory(), "sourceInline.kt");
|
||||||
|
|
||||||
CliBaseTest.executeCompilerGrabOutput(new K2JVMCompiler(), Arrays.asList(
|
AbstractCliTest.executeCompilerGrabOutput(new K2JVMCompiler(), Arrays.asList(
|
||||||
inlineSource.getPath(),
|
inlineSource.getPath(),
|
||||||
"-d", tmpdir.getPath()
|
"-d", tmpdir.getPath()
|
||||||
));
|
));
|
||||||
@@ -303,7 +303,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
File resultSource = new File(getTestDataDirectory(), "source.kt");
|
File resultSource = new File(getTestDataDirectory(), "source.kt");
|
||||||
CliBaseTest.executeCompilerGrabOutput(new K2JVMCompiler(), Arrays.asList(
|
AbstractCliTest.executeCompilerGrabOutput(new K2JVMCompiler(), Arrays.asList(
|
||||||
resultSource.getPath(),
|
resultSource.getPath(),
|
||||||
"-classpath", tmpdir.getPath(),
|
"-classpath", tmpdir.getPath(),
|
||||||
"-d", tmpdir.getPath()
|
"-d", tmpdir.getPath()
|
||||||
|
|||||||
Reference in New Issue
Block a user