Ant task: pass kotlin-runtime to javac's classpath; simplify tests
'kotlinCompiler' test is deleted because it's a very roundabout way to compile Kotlin and Java sources, and there's no point in testing it. 'javacCompiler' test is deleted for similar reasons: using javac's "compiler" option is not an advertised way to use Kotlin Ant task, and anyway it will work with any CompilerAdapter instance, so it's hard to break it (apart from deleting "withKotlin" adapter). There are tests which check compilation/running of the same code but with the recommended method. The pretext for deletion of these tests is to make Ant tests generated, and that would be easier if they wouldn't depend on any outer variables
This commit is contained in:
@@ -16,14 +16,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.integration;
|
||||
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.cli.CliBaseTest;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -33,8 +29,8 @@ public abstract class AntTaskBaseTest extends KotlinIntegrationTestBase {
|
||||
protected static final int SUCCESSFUL = 0;
|
||||
protected static final int FAILED = 1;
|
||||
|
||||
protected void doAntTest(int expectedExitCode, String... extraArgs) throws Exception {
|
||||
assertEquals("Compilation failed", expectedExitCode, runAnt("build.log", "build.xml", extraArgs));
|
||||
protected void doAntTest(int expectedExitCode) throws Exception {
|
||||
assertEquals("Compilation failed", expectedExitCode, runAnt("build.log", "build.xml"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,20 +39,18 @@ public abstract class AntTaskBaseTest extends KotlinIntegrationTestBase {
|
||||
.replaceAll("Total time: .+\n", "Total time: [time]\n");
|
||||
}
|
||||
|
||||
private int runAnt(String logName, String scriptName, String... extraArgs) throws Exception {
|
||||
String[] basicArgs = {
|
||||
private int runAnt(@NotNull String logName, @NotNull String scriptName) throws Exception {
|
||||
return runJava(
|
||||
logName,
|
||||
"-jar", getAntHome() + File.separator + "lib" + File.separator + "ant-launcher.jar",
|
||||
"-Dkotlin.lib=" + getCompilerLib(),
|
||||
"-Dtest.data=" + getTestDataDir(),
|
||||
"-Dtemp=" + tmpdir.getTmpDir(),
|
||||
"-f", scriptName
|
||||
};
|
||||
List<String> strings = new ArrayList<String>();
|
||||
strings.addAll(Arrays.asList(basicArgs));
|
||||
strings.addAll(Arrays.asList(extraArgs));
|
||||
return runJava(logName, ArrayUtil.toStringArray(strings));
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getAntHome() {
|
||||
return getKotlinProjectHome().getAbsolutePath() + File.separator + "dependencies" + File.separator + "ant-1.8";
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ public class AntTaskJvmTest extends AntTaskBaseTest {
|
||||
return new File(new File(ANT_TASK_TEST_DATA_BASE_DIR, "jvm"), name.getMethodName());
|
||||
}
|
||||
|
||||
private void doJvmAntTest(String... extraJavaArgs) throws Exception {
|
||||
doAntTest(SUCCESSFUL, extraJavaArgs);
|
||||
private void doJvmAntTest() throws Exception {
|
||||
doAntTest(SUCCESSFUL);
|
||||
|
||||
String classpath = UtilsPackage.join(Arrays.asList(
|
||||
getOutputFileByName(JVM_OUT_FILE).getAbsolutePath(),
|
||||
@@ -50,17 +50,6 @@ public class AntTaskJvmTest extends AntTaskBaseTest {
|
||||
runJava("hello.run", "-cp", classpath, "hello.HelloPackage");
|
||||
}
|
||||
|
||||
private static String getClassPathForAnt() {
|
||||
return UtilsPackage.join(Arrays.asList(
|
||||
getCompilerLib() + File.separator + "kotlin-compiler.jar",
|
||||
getCompilerLib() + File.separator + "kotlin-ant.jar"
|
||||
), File.pathSeparator);
|
||||
}
|
||||
|
||||
private static String getIdeaSdkHome() {
|
||||
return getKotlinProjectHome().getAbsolutePath() + File.separator + "ideaSDK";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void helloWorld() throws Exception {
|
||||
doJvmAntTest();
|
||||
@@ -111,23 +100,8 @@ public class AntTaskJvmTest extends AntTaskBaseTest {
|
||||
doJvmAntTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void javacCompiler() throws Exception {
|
||||
doJvmAntTest("-cp", getClassPathForAnt(),
|
||||
"-Dkotlin.home", getCompilerLib().getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void externalAnnotations() throws Exception {
|
||||
doJvmAntTest("-cp", getClassPathForAnt(),
|
||||
"-Didea.sdk", getIdeaSdkHome(),
|
||||
"-Dkotlin.home", getCompilerLib().getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void kotlinCompiler() throws Exception {
|
||||
doJvmAntTest("-cp", getClassPathForAnt(),
|
||||
"-Didea.sdk", getIdeaSdkHome(),
|
||||
"-Dkotlin.home", getCompilerLib().getAbsolutePath());
|
||||
doJvmAntTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user