Made incremental compilation test auto-generated.

This commit is contained in:
Evgeny Gerashchenko
2014-05-29 18:30:34 +04:00
parent f62842343d
commit 205f99bf60
4 changed files with 123 additions and 63 deletions
+1
View File
@@ -23,6 +23,7 @@
<orderEntry type="module" module-name="util" scope="TEST" />
<orderEntry type="library" scope="TEST" name="kotlin-runtime" level="project" />
<orderEntry type="module" module-name="j2k-tests" scope="TEST" />
<orderEntry type="library" scope="TEST" name="jps-test" level="project" />
</component>
</module>
@@ -113,6 +113,7 @@ import org.jetbrains.jet.plugin.stubs.AbstractMultiFileHighlightingTest
import org.jetbrains.jet.cfg.AbstractPseudoValueTest
import org.jetbrains.jet.plugin.structureView.AbstractKotlinFileStructureTest
import org.jetbrains.jet.j2k.test.AbstractJavaToKotlinConverterTest
import org.jetbrains.jet.jps.build.AbstractIncrementalJpsTest
fun main(args: Array<String>) {
System.setProperty("java.awt.headless", "true")
@@ -641,6 +642,12 @@ fun main(args: Array<String>) {
model("ast", extension = "java")
}
}
testGroup("jps-plugin/test", "jps-plugin/testData") {
testClass(javaClass<AbstractIncrementalJpsTest>()) {
model("incremental", extension = null, recursive = false)
}
}
}
private class TestGroup(val testsRoot: String, val testDataRoot: String) {
@@ -30,22 +30,14 @@ import org.jetbrains.jet.config.IncrementalCompilation
import java.util.ArrayList
import kotlin.test.fail
public class IncrementalJpsTest : JpsBuildTestCase() {
private val testDataDir: File
get() = File(AbstractKotlinJpsBuildTestCase.TEST_DATA_PATH + "incremental/" + getTestName(true))
public abstract class AbstractIncrementalJpsTest : JpsBuildTestCase() {
private var testDataDir: File by Delegates.notNull()
var workDir: File by Delegates.notNull()
override fun setUp() {
super.setUp()
System.setProperty("kotlin.jps.tests", "true")
workDir = FileUtil.createTempDirectory("jps-build", null)
FileUtil.copyDir(testDataDir, File(workDir, "src"), { it.getName().endsWith(".kt") || it.getName().endsWith(".java") })
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myProject!!)
.setOutputUrl(JpsPathUtil.pathToUrl(getAbsolutePath("out")))
}
override fun tearDown() {
@@ -99,11 +91,19 @@ public class IncrementalJpsTest : JpsBuildTestCase() {
}
}
private fun doTest() {
protected fun doTest(testDataPath: String) {
if (!IncrementalCompilation.ENABLED) {
return
}
testDataDir = File(testDataPath)
workDir = FileUtil.createTempDirectory("jps-build", null)
FileUtil.copyDir(testDataDir, File(workDir, "src"), { it.getName().endsWith(".kt") || it.getName().endsWith(".java") })
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myProject!!)
.setOutputUrl(JpsPathUtil.pathToUrl(getAbsolutePath("out")))
addModule("module", array(getAbsolutePath("src")), null, null, addJdk("my jdk"))
AbstractKotlinJpsBuildTestCase.addKotlinRuntimeDependency(myProject!!)
@@ -132,58 +132,6 @@ public class IncrementalJpsTest : JpsBuildTestCase() {
override fun doGetProjectDir(): File? = workDir
fun testIndependentClasses() {
doTest()
}
fun testSimpleClassDependency() {
doTest()
}
fun testTopLevelMembersInTwoPackages() {
doTest()
}
fun testReturnTypeChanged() {
doTest()
}
fun testTopLevelFunctionSameSignature() {
doTest()
}
fun testClassSignatureChanged() {
doTest()
}
fun testConstantValue() {
doTest()
}
fun testConstantUnchanged() {
doTest()
}
fun testPackageFileAdded() {
doTest()
}
fun testPackageFileRemoved() {
doTest()
}
fun testPackageFilesChangedInTurn() {
doTest()
}
fun testPackageFileChangedThenOtherRemoved() {
doTest()
}
fun testPackageFileChangedPackage() {
doTest()
}
private class MyLogger(val rootPath: String) : ProjectBuilderLoggerBase() {
private val logBuf = StringBuilder()
public val log: String
@@ -0,0 +1,104 @@
/*
* Copyright 2010-2014 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.jet.jps.build;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import java.io.File;
import java.util.regex.Pattern;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.InnerTestClasses;
import org.jetbrains.jet.test.TestMetadata;
import org.jetbrains.jet.jps.build.AbstractIncrementalJpsTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("jps-plugin/testData/incremental")
public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest {
public void testAllFilesPresentInIncremental() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("jps-plugin/testData/incremental"), Pattern.compile("^([^\\.]+)$"), false);
}
@TestMetadata("classSignatureChanged")
public void testClassSignatureChanged() throws Exception {
doTest("jps-plugin/testData/incremental/classSignatureChanged/");
}
@TestMetadata("constantUnchanged")
public void testConstantUnchanged() throws Exception {
doTest("jps-plugin/testData/incremental/constantUnchanged/");
}
@TestMetadata("constantValue")
public void testConstantValue() throws Exception {
doTest("jps-plugin/testData/incremental/constantValue/");
}
@TestMetadata("independentClasses")
public void testIndependentClasses() throws Exception {
doTest("jps-plugin/testData/incremental/independentClasses/");
}
@TestMetadata("packageFileAdded")
public void testPackageFileAdded() throws Exception {
doTest("jps-plugin/testData/incremental/packageFileAdded/");
}
@TestMetadata("packageFileChangedPackage")
public void testPackageFileChangedPackage() throws Exception {
doTest("jps-plugin/testData/incremental/packageFileChangedPackage/");
}
@TestMetadata("packageFileChangedThenOtherRemoved")
public void testPackageFileChangedThenOtherRemoved() throws Exception {
doTest("jps-plugin/testData/incremental/packageFileChangedThenOtherRemoved/");
}
@TestMetadata("packageFileRemoved")
public void testPackageFileRemoved() throws Exception {
doTest("jps-plugin/testData/incremental/packageFileRemoved/");
}
@TestMetadata("packageFilesChangedInTurn")
public void testPackageFilesChangedInTurn() throws Exception {
doTest("jps-plugin/testData/incremental/packageFilesChangedInTurn/");
}
@TestMetadata("returnTypeChanged")
public void testReturnTypeChanged() throws Exception {
doTest("jps-plugin/testData/incremental/returnTypeChanged/");
}
@TestMetadata("simpleClassDependency")
public void testSimpleClassDependency() throws Exception {
doTest("jps-plugin/testData/incremental/simpleClassDependency/");
}
@TestMetadata("topLevelFunctionSameSignature")
public void testTopLevelFunctionSameSignature() throws Exception {
doTest("jps-plugin/testData/incremental/topLevelFunctionSameSignature/");
}
@TestMetadata("topLevelMembersInTwoPackages")
public void testTopLevelMembersInTwoPackages() throws Exception {
doTest("jps-plugin/testData/incremental/topLevelMembersInTwoPackages/");
}
}