Don't always run code in Ant task tests
But when running code, do it via <java> task, not via custom testing code. Most of the time the compiled code need not be runned, because it's irrelevant to the Ant task itself
This commit is contained in:
@@ -1,4 +0,0 @@
|
|||||||
OUT:
|
|
||||||
Hello, a!
|
|
||||||
|
|
||||||
Return code: 0
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
|
|
||||||
ERR:
|
|
||||||
Exception in thread "main" java.lang.NoClassDefFoundError: hello/HelloPackage
|
|
||||||
Caused by: java.lang.ClassNotFoundException: hello.HelloPackage
|
|
||||||
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
|
|
||||||
at java.security.AccessController.doPrivileged(Native Method)
|
|
||||||
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
|
|
||||||
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
|
|
||||||
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
|
|
||||||
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
|
|
||||||
|
|
||||||
Return code: 1
|
|
||||||
@@ -7,6 +7,8 @@ build:
|
|||||||
[javac] Compiling [[TestData]/root1] => [[Temp]/classes]
|
[javac] Compiling [[TestData]/root1] => [[Temp]/classes]
|
||||||
[javac] Running javac...
|
[javac] Running javac...
|
||||||
[jar] Building jar: [Temp]/hello.jar
|
[jar] Building jar: [Temp]/hello.jar
|
||||||
|
[java] Hello, a!
|
||||||
|
[java] Java Hello
|
||||||
|
|
||||||
BUILD SUCCESSFUL
|
BUILD SUCCESSFUL
|
||||||
Total time: [time]
|
Total time: [time]
|
||||||
|
|||||||
@@ -12,5 +12,12 @@
|
|||||||
<jar destfile="${temp}/hello.jar">
|
<jar destfile="${temp}/hello.jar">
|
||||||
<fileset dir="${temp}/classes"/>
|
<fileset dir="${temp}/classes"/>
|
||||||
</jar>
|
</jar>
|
||||||
|
|
||||||
|
<java classname="hello.HelloPackage" fork="true">
|
||||||
|
<classpath>
|
||||||
|
<pathelement location="${temp}/hello.jar"/>
|
||||||
|
<pathelement location="${kotlin.runtime.jar}"/>
|
||||||
|
</classpath>
|
||||||
|
</java>
|
||||||
</target>
|
</target>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
OUT:
|
|
||||||
Hello, a!
|
|
||||||
Java Hello
|
|
||||||
|
|
||||||
Return code: 0
|
|
||||||
@@ -3,6 +3,7 @@ Buildfile: [TestData]/build.xml
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
[kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
|
[kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
|
||||||
|
[java] Hello, a!
|
||||||
|
|
||||||
BUILD SUCCESSFUL
|
BUILD SUCCESSFUL
|
||||||
Total time: [time]
|
Total time: [time]
|
||||||
|
|||||||
@@ -3,5 +3,12 @@
|
|||||||
|
|
||||||
<target name="build">
|
<target name="build">
|
||||||
<kotlinc src="${test.data}/hello.kt" output="${temp}/hello.jar"/>
|
<kotlinc src="${test.data}/hello.kt" output="${temp}/hello.jar"/>
|
||||||
|
|
||||||
|
<java classname="hello.HelloPackage" fork="true">
|
||||||
|
<classpath>
|
||||||
|
<pathelement location="${temp}/hello.jar"/>
|
||||||
|
<pathelement location="${kotlin.runtime.jar}"/>
|
||||||
|
</classpath>
|
||||||
|
</java>
|
||||||
</target>
|
</target>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
OUT:
|
|
||||||
Hello, a!
|
|
||||||
|
|
||||||
Return code: 0
|
|
||||||
@@ -4,6 +4,7 @@ Buildfile: [TestData]/build.xml
|
|||||||
build:
|
build:
|
||||||
[kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
|
[kotlinc] Compiling [[TestData]/hello.kt] => [[Temp]/hello.jar]
|
||||||
[kotlinc] WARNING: [TestData]/hello.kt: (15, 9) Variable 'result' is never used
|
[kotlinc] WARNING: [TestData]/hello.kt: (15, 9) Variable 'result' is never used
|
||||||
|
[java] OK
|
||||||
|
|
||||||
BUILD SUCCESSFUL
|
BUILD SUCCESSFUL
|
||||||
Total time: [time]
|
Total time: [time]
|
||||||
|
|||||||
@@ -3,5 +3,12 @@
|
|||||||
|
|
||||||
<target name="build">
|
<target name="build">
|
||||||
<kotlinc src="${test.data}/hello.kt" output="${temp}/hello.jar"/>
|
<kotlinc src="${test.data}/hello.kt" output="${temp}/hello.jar"/>
|
||||||
|
|
||||||
|
<java classname="hello.HelloPackage" fork="true">
|
||||||
|
<classpath>
|
||||||
|
<pathelement location="${temp}/hello.jar"/>
|
||||||
|
<pathelement location="${kotlin.runtime.jar}"/>
|
||||||
|
</classpath>
|
||||||
|
</java>
|
||||||
</target>
|
</target>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import sun.nio.ByteBuffered
|
|||||||
|
|
||||||
fun main(args : Array<String>) {
|
fun main(args : Array<String>) {
|
||||||
val a = Big5() // charsets.jar
|
val a = Big5() // charsets.jar
|
||||||
val c = DNSNameService() // dnsns.ajr
|
val c = DNSNameService() // dnsns.jar
|
||||||
val e : Cipher? = null // jce.jar
|
val e : Cipher? = null // jce.jar
|
||||||
val f : SunJCE? = null // sunjce_provider.jar
|
val f : SunJCE? = null // sunjce_provider.jar
|
||||||
val j : ByteBuffered? = null // rt.jar
|
val j : ByteBuffered? = null // rt.jar
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
OUT:
|
|
||||||
OK
|
|
||||||
|
|
||||||
Return code: 0
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
OUT:
|
|
||||||
Hello, a!
|
|
||||||
|
|
||||||
Return code: 0
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
OUT:
|
|
||||||
Hello!
|
|
||||||
|
|
||||||
Return code: 0
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
OUT:
|
|
||||||
Hi!
|
|
||||||
|
|
||||||
Return code: 0
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
OUT:
|
|
||||||
Hi!
|
|
||||||
|
|
||||||
Return code: 0
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
OUT:
|
|
||||||
Yo!
|
|
||||||
|
|
||||||
Return code: 0
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
OUT:
|
|
||||||
Hello!
|
|
||||||
|
|
||||||
Return code: 0
|
|
||||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.integration;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.cli.CliBaseTest;
|
import org.jetbrains.kotlin.cli.CliBaseTest;
|
||||||
|
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@@ -29,6 +30,8 @@ public abstract class AntTaskBaseTest extends KotlinIntegrationTestBase {
|
|||||||
"build.log",
|
"build.log",
|
||||||
"-jar", getAntHome() + File.separator + "lib" + File.separator + "ant-launcher.jar",
|
"-jar", getAntHome() + File.separator + "lib" + File.separator + "ant-launcher.jar",
|
||||||
"-Dkotlin.lib=" + getCompilerLib(),
|
"-Dkotlin.lib=" + getCompilerLib(),
|
||||||
|
"-Dkotlin.runtime.jar=" + ForTestCompileRuntime.runtimeJarForTests().getAbsolutePath(),
|
||||||
|
"-Dkotlin.reflect.jar=" + ForTestCompileRuntime.reflectJarForTests().getAbsolutePath(),
|
||||||
"-Dtest.data=" + getTestDataDir(),
|
"-Dtest.data=" + getTestDataDir(),
|
||||||
"-Dtemp=" + tmpdir.getTmpDir(),
|
"-Dtemp=" + tmpdir.getTmpDir(),
|
||||||
"-f", "build.xml"
|
"-f", "build.xml"
|
||||||
@@ -45,9 +48,4 @@ public abstract class AntTaskBaseTest extends KotlinIntegrationTestBase {
|
|||||||
private static String getAntHome() {
|
private static String getAntHome() {
|
||||||
return getKotlinProjectHome().getAbsolutePath() + File.separator + "dependencies" + File.separator + "ant-1.8";
|
return getKotlinProjectHome().getAbsolutePath() + File.separator + "dependencies" + File.separator + "ant-1.8";
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
protected File getOutputFileByName(@NotNull String name) {
|
|
||||||
return new File(tmpdir.getTmpDir(), name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ public class AntTaskJsTest extends AntTaskBaseTest {
|
|||||||
return new File(new File(ANT_TASK_TEST_DATA_BASE_DIR, "js"), name.getMethodName());
|
return new File(new File(ANT_TASK_TEST_DATA_BASE_DIR, "js"), name.getMethodName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private File getOutputFileByName(@NotNull String name) {
|
||||||
|
return new File(tmpdir.getTmpDir(), name);
|
||||||
|
}
|
||||||
|
|
||||||
private void doJsAntTest(String... jsFiles) throws Exception {
|
private void doJsAntTest(String... jsFiles) throws Exception {
|
||||||
doAntTest();
|
doAntTest();
|
||||||
|
|
||||||
|
|||||||
@@ -17,18 +17,13 @@
|
|||||||
package org.jetbrains.kotlin.integration;
|
package org.jetbrains.kotlin.integration;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
|
|
||||||
import org.jetbrains.kotlin.utils.UtilsPackage;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.TestName;
|
import org.junit.rules.TestName;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class AntTaskJvmTest extends AntTaskBaseTest {
|
public class AntTaskJvmTest extends AntTaskBaseTest {
|
||||||
private static final String JVM_OUT_FILE = "hello.jar";
|
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public final TestName name = new TestName();
|
public final TestName name = new TestName();
|
||||||
|
|
||||||
@@ -40,14 +35,6 @@ public class AntTaskJvmTest extends AntTaskBaseTest {
|
|||||||
|
|
||||||
private void doJvmAntTest() throws Exception {
|
private void doJvmAntTest() throws Exception {
|
||||||
doAntTest();
|
doAntTest();
|
||||||
|
|
||||||
String classpath = UtilsPackage.join(Arrays.asList(
|
|
||||||
getOutputFileByName(JVM_OUT_FILE).getAbsolutePath(),
|
|
||||||
ForTestCompileRuntime.runtimeJarForTests().getAbsolutePath(),
|
|
||||||
ForTestCompileRuntime.reflectJarForTests().getAbsolutePath()
|
|
||||||
), File.pathSeparator);
|
|
||||||
|
|
||||||
runJava("hello.run", "-cp", classpath, "hello.HelloPackage");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user