Rewrite integration tests to JUnit3, make Ant JVM task tests generated
This commit is contained in:
+9
-7
@@ -22,25 +22,27 @@ import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public abstract class AntTaskBaseTest extends KotlinIntegrationTestBase {
|
public abstract class AbstractAntTaskTest extends KotlinIntegrationTestBase {
|
||||||
protected static final File ANT_TASK_TEST_DATA_BASE_DIR = new File(INTEGRATION_TEST_DATA_BASE_DIR, "ant");
|
protected void doTest(String testFile) throws Exception {
|
||||||
|
String testDataDir = new File(testFile).getAbsolutePath();
|
||||||
|
|
||||||
protected void doAntTest() throws Exception {
|
|
||||||
runJava(
|
runJava(
|
||||||
|
testDataDir,
|
||||||
"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.runtime.jar=" + ForTestCompileRuntime.runtimeJarForTests().getAbsolutePath(),
|
||||||
"-Dkotlin.reflect.jar=" + ForTestCompileRuntime.reflectJarForTests().getAbsolutePath(),
|
"-Dkotlin.reflect.jar=" + ForTestCompileRuntime.reflectJarForTests().getAbsolutePath(),
|
||||||
"-Dtest.data=" + getTestDataDir(),
|
"-Dtest.data=" + testDataDir,
|
||||||
"-Dtemp=" + tmpdir.getTmpDir(),
|
"-Dtemp=" + tmpdir,
|
||||||
"-f", "build.xml"
|
"-f", "build.xml"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String normalizeOutput(String content) {
|
@NotNull
|
||||||
return CliBaseTest.removePerfOutput(super.normalizeOutput(content))
|
protected String normalizeOutput(@NotNull File testDataDir, @NotNull String content) {
|
||||||
|
return CliBaseTest.removePerfOutput(super.normalizeOutput(testDataDir, content))
|
||||||
.replaceAll("Total time: .+\n", "Total time: [time]\n");
|
.replaceAll("Total time: .+\n", "Total time: [time]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,9 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.js.test.rhino.RhinoFunctionResultChecker;
|
import org.jetbrains.kotlin.js.test.rhino.RhinoFunctionResultChecker;
|
||||||
import org.jetbrains.kotlin.js.test.rhino.RhinoUtils;
|
import org.jetbrains.kotlin.js.test.rhino.RhinoUtils;
|
||||||
import org.junit.Rule;
|
import org.jetbrains.kotlin.test.JetTestUtils;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.rules.TestName;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -33,27 +31,25 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
public class AntTaskJsTest extends AbstractAntTaskTest {
|
||||||
|
|
||||||
public class AntTaskJsTest extends AntTaskBaseTest {
|
|
||||||
private static final String JS_OUT_FILE = "out.js";
|
private static final String JS_OUT_FILE = "out.js";
|
||||||
|
|
||||||
@Rule
|
|
||||||
public final TestName name = new TestName();
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
private String getTestDataDir() {
|
||||||
protected File getTestDataDir() {
|
return JetTestUtils.getTestDataPathBase() + "/integration/ant/js/" + getTestName(true);
|
||||||
return new File(new File(ANT_TASK_TEST_DATA_BASE_DIR, "js"), name.getMethodName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private File getOutputFileByName(@NotNull String name) {
|
private File getOutputFileByName(@NotNull String name) {
|
||||||
return new File(tmpdir.getTmpDir(), name);
|
return new File(tmpdir, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doTest() throws Exception {
|
||||||
|
doTest(getTestDataDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doJsAntTest(String... jsFiles) throws Exception {
|
private void doJsAntTest(String... jsFiles) throws Exception {
|
||||||
doAntTest();
|
doTest();
|
||||||
|
|
||||||
List<String> fileNames = new ArrayList<String>(Arrays.asList(jsFiles));
|
List<String> fileNames = new ArrayList<String>(Arrays.asList(jsFiles));
|
||||||
fileNames.add(JS_OUT_FILE);
|
fileNames.add(JS_OUT_FILE);
|
||||||
@@ -92,123 +88,99 @@ public class AntTaskJsTest extends AntTaskBaseTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSimple() throws Exception {
|
||||||
public void simple() throws Exception {
|
|
||||||
doJsAntTest();
|
doJsAntTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSimpleWithMain() throws Exception {
|
||||||
public void simpleWithMain() throws Exception {
|
|
||||||
doJsAntTest();
|
doJsAntTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSimpleWithStdlib() throws Exception {
|
||||||
public void simpleWithStdlib() throws Exception {
|
|
||||||
doJsAntTest();
|
doJsAntTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSimpleWithStdlibAndAnotherLib() throws Exception {
|
||||||
public void simpleWithStdlibAndAnotherLib() throws Exception {
|
|
||||||
doJsAntTest("jslib-example.js");
|
doJsAntTest("jslib-example.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSimpleWithStdlibAndFolderAsAnotherLib() throws Exception {
|
||||||
public void simpleWithStdlibAndFolderAsAnotherLib() throws Exception {
|
|
||||||
doJsAntTest("jslib-example.js");
|
doJsAntTest("jslib-example.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSimpleWithoutStdlibAndFolderAsAnotherLib() throws Exception {
|
||||||
public void simpleWithoutStdlibAndFolderAsAnotherLib() throws Exception {
|
|
||||||
doJsAntTest("jslib-example.js");
|
doJsAntTest("jslib-example.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSimpleWithoutStdlibAndJsFileAsAnotherLib() throws Exception {
|
||||||
public void simpleWithoutStdlibAndJsFileAsAnotherLib() throws Exception {
|
|
||||||
doJsAntTest("jslib-example.js");
|
doJsAntTest("jslib-example.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSimpleWithStdlibAndJsFileAsAnotherLib() throws Exception {
|
||||||
public void simpleWithStdlibAndJsFileAsAnotherLib() throws Exception {
|
|
||||||
doJsAntTest("jslib-example.js");
|
doJsAntTest("jslib-example.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSimpleWithStdlibAndTwoJsFilesAsLibraries() throws Exception {
|
||||||
public void simpleWithStdlibAndTwoJsFilesAsLibraries() throws Exception {
|
|
||||||
doJsAntTest("jslib-example1.js", "jslib-example2.js");
|
doJsAntTest("jslib-example1.js", "jslib-example2.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSimpleWithStdlibAndJsFilesWithTwoModulesAsLibrary() throws Exception {
|
||||||
public void simpleWithStdlibAndJsFilesWithTwoModulesAsLibrary() throws Exception {
|
|
||||||
doJsAntTest("jslib-example.js");
|
doJsAntTest("jslib-example.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSimpleWithMainFQArgs() throws Exception {
|
||||||
public void simpleWithMainFQArgs() throws Exception {
|
|
||||||
doJsAntTest();
|
doJsAntTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSimpleWithVarargMain() throws Exception {
|
||||||
public void simpleWithVarargMain() throws Exception {
|
|
||||||
doJsAntTest();
|
doJsAntTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testManySources() throws Exception {
|
||||||
public void manySources() throws Exception {
|
|
||||||
doJsAntTest();
|
doJsAntTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testAdditionalArguments() throws Exception {
|
||||||
public void additionalArguments() throws Exception {
|
|
||||||
doJsAntTest();
|
doJsAntTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSuppressWarnings() throws Exception {
|
||||||
public void suppressWarnings() throws Exception {
|
|
||||||
doJsAntTest();
|
doJsAntTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testVerbose() throws Exception {
|
||||||
public void verbose() throws Exception {
|
|
||||||
doJsAntTest();
|
doJsAntTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testVersion() throws Exception {
|
||||||
public void version() throws Exception {
|
|
||||||
doJsAntTest();
|
doJsAntTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testOutputWithoutDirectory() throws Exception {
|
||||||
public void outputWithoutDirectory() throws Exception {
|
|
||||||
doJsAntTest();
|
doJsAntTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testNoSrcParam() throws Exception {
|
||||||
public void noSrcParam() throws Exception {
|
doTest();
|
||||||
doAntTest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testNoOutputParam() throws Exception {
|
||||||
public void noOutputParam() throws Exception {
|
doTest();
|
||||||
doAntTest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testOutputPrefix() throws Exception {
|
||||||
public void outputPrefix() throws Exception {
|
|
||||||
doJsAntTestForPostfixPrefix("prefix", null);
|
doJsAntTestForPostfixPrefix("prefix", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testOutputPostfix() throws Exception {
|
||||||
public void outputPostfix() throws Exception {
|
|
||||||
doJsAntTestForPostfixPrefix(null, "postfix");
|
doJsAntTestForPostfixPrefix(null, "postfix");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testBothPrefixAndPostfix() throws Exception {
|
||||||
public void bothPrefixAndPostfix() throws Exception {
|
|
||||||
doJsAntTestForPostfixPrefix("prefix", "postfix");
|
doJsAntTestForPostfixPrefix("prefix", "postfix");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSourceMap() throws Exception {
|
||||||
public void sourceMap() throws Exception {
|
|
||||||
doJsAntTest();
|
doJsAntTest();
|
||||||
|
|
||||||
File sourceMap = getOutputFileByName(JS_OUT_FILE + ".map");
|
File sourceMap = getOutputFileByName(JS_OUT_FILE + ".map");
|
||||||
|
|||||||
@@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.integration;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.rules.TestName;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class AntTaskJvmTest extends AntTaskBaseTest {
|
|
||||||
@Rule
|
|
||||||
public final TestName name = new TestName();
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected File getTestDataDir() {
|
|
||||||
return new File(new File(ANT_TASK_TEST_DATA_BASE_DIR, "jvm"), name.getMethodName());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doJvmAntTest() throws Exception {
|
|
||||||
doAntTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void helloWorld() throws Exception {
|
|
||||||
doJvmAntTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void additionalArguments() throws Exception {
|
|
||||||
doJvmAntTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void doNotFailOnError() throws Exception {
|
|
||||||
doJvmAntTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void jvmClasspath() throws Exception {
|
|
||||||
doJvmAntTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void manySourceRoots() throws Exception {
|
|
||||||
doJvmAntTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void suppressWarnings() throws Exception {
|
|
||||||
doJvmAntTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void verbose() throws Exception {
|
|
||||||
doJvmAntTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void version() throws Exception {
|
|
||||||
doJvmAntTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void noClasspathGiven() throws Exception {
|
|
||||||
doJvmAntTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void withKotlinNoJavaSources() throws Exception {
|
|
||||||
doJvmAntTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void externalAnnotations() throws Exception {
|
|
||||||
doJvmAntTest();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2015 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.integration;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||||
|
import org.jetbrains.kotlin.test.JetTestUtils;
|
||||||
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("compiler/testData/integration/ant/jvm")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public class AntTaskTestGenerated extends AbstractAntTaskTest {
|
||||||
|
@TestMetadata("additionalArguments")
|
||||||
|
public void testAdditionalArguments() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/additionalArguments/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAllFilesPresentInJvm() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/integration/ant/jvm"), Pattern.compile("^([^\\.]+)$"), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("doNotFailOnError")
|
||||||
|
public void testDoNotFailOnError() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/doNotFailOnError/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("helloWorld")
|
||||||
|
public void testHelloWorld() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/helloWorld/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmClasspath")
|
||||||
|
public void testJvmClasspath() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/jvmClasspath/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noClasspathGiven")
|
||||||
|
public void testNoClasspathGiven() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/noClasspathGiven/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("suppressWarnings")
|
||||||
|
public void testSuppressWarnings() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/suppressWarnings/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("verbose")
|
||||||
|
public void testVerbose() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/verbose/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("version")
|
||||||
|
public void testVersion() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/version/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("withKotlinNoJavaSources")
|
||||||
|
public void testWithKotlinNoJavaSources() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/integration/ant/jvm/withKotlinNoJavaSources/");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,12 +17,8 @@
|
|||||||
package org.jetbrains.kotlin.integration;
|
package org.jetbrains.kotlin.integration;
|
||||||
|
|
||||||
import com.intellij.util.ArrayUtil;
|
import com.intellij.util.ArrayUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.kotlin.test.JetTestUtils;
|
||||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
|
|
||||||
import org.jetbrains.kotlin.utils.UtilsPackage;
|
import org.jetbrains.kotlin.utils.UtilsPackage;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.rules.TestName;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -30,16 +26,9 @@ import java.util.Arrays;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class CompilerSmokeTest extends KotlinIntegrationTestBase {
|
public class CompilerSmokeTest extends KotlinIntegrationTestBase {
|
||||||
@Rule
|
private int run(String logName, String... args) throws Exception {
|
||||||
public final TestName name = new TestName();
|
return runJava(JetTestUtils.getTestDataPathBase() + "/integration/smoke/" + getTestName(true), logName, args);
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected File getTestDataDir() {
|
|
||||||
return new File(new File(INTEGRATION_TEST_DATA_BASE_DIR, "smoke"), name.getMethodName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int runCompiler(String logName, String... arguments) throws Exception {
|
private int runCompiler(String logName, String... arguments) throws Exception {
|
||||||
@@ -55,54 +44,47 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
|
|||||||
|
|
||||||
Collections.addAll(javaArgs, arguments);
|
Collections.addAll(javaArgs, arguments);
|
||||||
|
|
||||||
return runJava(logName, ArrayUtil.toStringArray(javaArgs));
|
return run(logName, ArrayUtil.toStringArray(javaArgs));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testHelloApp() throws Exception {
|
||||||
public void helloApp() throws Exception {
|
String jar = tmpdir.getAbsolutePath() + File.separator + "hello.jar";
|
||||||
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar";
|
|
||||||
|
|
||||||
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-include-runtime", "hello.kt", "-d", jar));
|
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-include-runtime", "hello.kt", "-d", jar));
|
||||||
runJava("hello.run", "-cp", jar, "Hello.HelloPackage");
|
run("hello.run", "-cp", jar, "Hello.HelloPackage");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testHelloAppFQMain() throws Exception {
|
||||||
public void helloAppFQMain() throws Exception {
|
String jar = tmpdir.getAbsolutePath() + File.separator + "hello.jar";
|
||||||
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar";
|
|
||||||
|
|
||||||
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-include-runtime", "hello.kt", "-d", jar));
|
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-include-runtime", "hello.kt", "-d", jar));
|
||||||
runJava("hello.run", "-cp", jar, "Hello.HelloPackage");
|
run("hello.run", "-cp", jar, "Hello.HelloPackage");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testHelloAppVarargMain() throws Exception {
|
||||||
public void helloAppVarargMain() throws Exception {
|
String jar = tmpdir.getAbsolutePath() + File.separator + "hello.jar";
|
||||||
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar";
|
|
||||||
|
|
||||||
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-include-runtime", "hello.kt", "-d", jar));
|
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-include-runtime", "hello.kt", "-d", jar));
|
||||||
runJava("hello.run", "-cp", jar, "Hello.HelloPackage");
|
run("hello.run", "-cp", jar, "Hello.HelloPackage");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testCompilationFailed() throws Exception {
|
||||||
public void compilationFailed() throws Exception {
|
String jar = tmpdir.getAbsolutePath() + File.separator + "smoke.jar";
|
||||||
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar";
|
|
||||||
|
|
||||||
runCompiler("hello.compile", "hello.kt", "-d", jar);
|
runCompiler("hello.compile", "hello.kt", "-d", jar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSyntaxErrors() throws Exception {
|
||||||
public void syntaxErrors() throws Exception {
|
String jar = tmpdir.getAbsolutePath() + File.separator + "smoke.jar";
|
||||||
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar";
|
|
||||||
|
|
||||||
runCompiler("test.compile", "test.kt", "-d", jar);
|
runCompiler("test.compile", "test.kt", "-d", jar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testSimpleScript() throws Exception {
|
||||||
public void simpleScript() throws Exception {
|
|
||||||
runCompiler("script", "-script", "script.kts", "hi", "there");
|
runCompiler("script", "-script", "script.kts", "hi", "there");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void testScriptWithClasspath() throws Exception {
|
||||||
public void scriptWithClasspath() throws Exception {
|
|
||||||
runCompiler("script", "-cp", new File("lib/javax.inject.jar").getAbsolutePath(), "-script", "script.kts");
|
runCompiler("script", "-cp", new File("lib/javax.inject.jar").getAbsolutePath(), "-script", "script.kts");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.integration;
|
package org.jetbrains.kotlin.integration;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
import com.google.common.io.Files;
|
|
||||||
import com.intellij.execution.ExecutionException;
|
import com.intellij.execution.ExecutionException;
|
||||||
import com.intellij.execution.OutputListener;
|
import com.intellij.execution.OutputListener;
|
||||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||||
@@ -31,33 +29,22 @@ import kotlin.text.MatchResult;
|
|||||||
import kotlin.text.Regex;
|
import kotlin.text.Regex;
|
||||||
import org.intellij.lang.annotations.Language;
|
import org.intellij.lang.annotations.Language;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.cli.common.KotlinVersion;
|
import org.jetbrains.kotlin.cli.common.KotlinVersion;
|
||||||
import org.jetbrains.kotlin.test.JetTestUtils;
|
import org.jetbrains.kotlin.test.JetTestUtils;
|
||||||
import org.jetbrains.kotlin.test.Tmpdir;
|
import org.jetbrains.kotlin.test.TestCaseWithTmpdir;
|
||||||
import org.jetbrains.kotlin.utils.PathUtil;
|
import org.jetbrains.kotlin.utils.PathUtil;
|
||||||
import org.junit.ComparisonFailure;
|
|
||||||
import org.junit.Rule;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
public abstract class KotlinIntegrationTestBase extends TestCaseWithTmpdir {
|
||||||
|
|
||||||
public abstract class KotlinIntegrationTestBase {
|
|
||||||
protected static final File INTEGRATION_TEST_DATA_BASE_DIR = new File(JetTestUtils.getTestDataPathBase(), "integration");
|
|
||||||
|
|
||||||
@Rule
|
|
||||||
public final Tmpdir tmpdir = new Tmpdir();
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.setProperty("java.awt.headless", "true");
|
System.setProperty("java.awt.headless", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
protected int runJava(@NotNull String testDataDir, @Nullable String logName, @NotNull String... arguments) throws Exception {
|
||||||
protected abstract File getTestDataDir();
|
GeneralCommandLine commandLine = new GeneralCommandLine().withWorkDirectory(testDataDir);
|
||||||
|
|
||||||
protected int runJava(String logName, String... arguments) throws Exception {
|
|
||||||
GeneralCommandLine commandLine = new GeneralCommandLine().withWorkDirectory(getTestDataDir());
|
|
||||||
commandLine.setExePath(getJavaRuntime().getAbsolutePath());
|
commandLine.setExePath(getJavaRuntime().getAbsolutePath());
|
||||||
commandLine.addParameters(arguments);
|
commandLine.addParameters(arguments);
|
||||||
|
|
||||||
@@ -68,7 +55,7 @@ public abstract class KotlinIntegrationTestBase {
|
|||||||
assertEquals("Non-zero exit code", 0, exitCode);
|
assertEquals("Non-zero exit code", 0, exitCode);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
check(logName, executionLog.toString());
|
check(testDataDir, logName, executionLog.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return exitCode;
|
return exitCode;
|
||||||
@@ -88,9 +75,10 @@ public abstract class KotlinIntegrationTestBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String normalizeOutput(String content) {
|
@NotNull
|
||||||
content = normalizePath(content, getTestDataDir(), "[TestData]");
|
protected String normalizeOutput(@NotNull File testDataDir, @NotNull String content) {
|
||||||
content = normalizePath(content, tmpdir.getTmpDir(), "[Temp]");
|
content = normalizePath(content, testDataDir, "[TestData]");
|
||||||
|
content = normalizePath(content, tmpdir, "[Temp]");
|
||||||
content = normalizePath(content, getCompilerLib(), "[CompilerLib]");
|
content = normalizePath(content, getCompilerLib(), "[CompilerLib]");
|
||||||
content = normalizePath(content, getKotlinProjectHome(), "[KotlinProjectHome]");
|
content = normalizePath(content, getKotlinProjectHome(), "[KotlinProjectHome]");
|
||||||
content = content.replaceAll(KotlinVersion.VERSION, "[KotlinVersion]");
|
content = content.replaceAll(KotlinVersion.VERSION, "[KotlinVersion]");
|
||||||
@@ -98,26 +86,11 @@ public abstract class KotlinIntegrationTestBase {
|
|||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void check(String baseName, String content) throws IOException {
|
private void check(String testDataDir, String baseName, String content) throws IOException {
|
||||||
File actualFile = new File(getTestDataDir(), baseName + ".actual");
|
File expectedFile = new File(testDataDir, baseName + ".expected");
|
||||||
File expectedFile = new File(getTestDataDir(), baseName + ".expected");
|
String normalizedContent = normalizeOutput(new File(testDataDir), content);
|
||||||
|
|
||||||
String normalizedContent = normalizeOutput(content);
|
JetTestUtils.assertEqualsToFile(expectedFile, normalizedContent);
|
||||||
|
|
||||||
if (!expectedFile.isFile()) {
|
|
||||||
Files.write(normalizedContent, actualFile, Charsets.UTF_8);
|
|
||||||
fail("No .expected file " + expectedFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
JetTestUtils.assertEqualsToFile(expectedFile, normalizedContent);
|
|
||||||
//noinspection ResultOfMethodCallIgnored
|
|
||||||
actualFile.delete();
|
|
||||||
}
|
|
||||||
catch (ComparisonFailure e) {
|
|
||||||
Files.write(normalizedContent, actualFile, Charsets.UTF_8);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int runProcess(GeneralCommandLine commandLine, StringBuilder executionLog) throws ExecutionException {
|
private static int runProcess(GeneralCommandLine commandLine, StringBuilder executionLog) throws ExecutionException {
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ import org.jetbrains.kotlin.idea.structureView.AbstractKotlinFileStructureTest
|
|||||||
import org.jetbrains.kotlin.idea.stubs.AbstractMultiFileHighlightingTest
|
import org.jetbrains.kotlin.idea.stubs.AbstractMultiFileHighlightingTest
|
||||||
import org.jetbrains.kotlin.idea.stubs.AbstractResolveByStubTest
|
import org.jetbrains.kotlin.idea.stubs.AbstractResolveByStubTest
|
||||||
import org.jetbrains.kotlin.idea.stubs.AbstractStubBuilderTest
|
import org.jetbrains.kotlin.idea.stubs.AbstractStubBuilderTest
|
||||||
|
import org.jetbrains.kotlin.integration.AbstractAntTaskTest
|
||||||
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterForWebDemoTest
|
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterForWebDemoTest
|
||||||
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterMultiFileTest
|
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterMultiFileTest
|
||||||
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterSingleFileTest
|
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterSingleFileTest
|
||||||
@@ -272,6 +273,10 @@ fun main(args: Array<String>) {
|
|||||||
model("repl", extension = "repl")
|
model("repl", extension = "repl")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testClass(javaClass<AbstractAntTaskTest>()) {
|
||||||
|
model("integration/ant/jvm", extension = null, recursive = false, excludeParentDirs = true)
|
||||||
|
}
|
||||||
|
|
||||||
testClass(javaClass<AbstractControlFlowTest>()) {
|
testClass(javaClass<AbstractControlFlowTest>()) {
|
||||||
model("cfg")
|
model("cfg")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user