Autogenerate codegen multi-file tests
Based on boxMultiFile/ directory
This commit is contained in:
committed by
Alexander Udalov
parent
a61b3ec461
commit
22bf8b25b8
@@ -84,7 +84,7 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
||||
protected String loadFileByFullPath(@NotNull String fullPath) {
|
||||
try {
|
||||
File file = new File(fullPath);
|
||||
final String content = FileUtil.loadFile(file, true);
|
||||
String content = FileUtil.loadFile(file, true);
|
||||
myFiles = CodegenTestFiles.create(file.getName(), content, myEnvironment.getProject());
|
||||
return content;
|
||||
} catch (IOException e) {
|
||||
@@ -96,6 +96,14 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
||||
myFiles = CodegenTestFiles.create(myEnvironment.getProject(), names);
|
||||
}
|
||||
|
||||
protected void loadFilesByFullPath(@NotNull String... fullNames) {
|
||||
String[] names = new String[fullNames.length];
|
||||
for (int i = 0; i < fullNames.length; i++) {
|
||||
names[i] = fullNames[i].substring("compiler/testData/codegen/".length());
|
||||
}
|
||||
loadFiles(names);
|
||||
}
|
||||
|
||||
protected void loadFile() {
|
||||
loadFile(getPrefix() + "/" + getTestName(true) + ".kt");
|
||||
}
|
||||
@@ -115,6 +123,11 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
||||
blackBox();
|
||||
}
|
||||
|
||||
protected void blackBoxMultiFileByFullPath(@NotNull String... filenames) {
|
||||
loadFilesByFullPath(filenames);
|
||||
blackBox();
|
||||
}
|
||||
|
||||
private void blackBox() {
|
||||
ClassFileFactory factory = generateClassesInFile();
|
||||
GeneratedClassLoader loader = createClassLoader(factory);
|
||||
|
||||
@@ -16,11 +16,17 @@
|
||||
|
||||
package org.jetbrains.jet.codegen.generated;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.codegen.CodegenTestCase;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
|
||||
public void doTest(@NotNull String filename) {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
@@ -36,4 +42,21 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
|
||||
myEnvironment = JetTestUtils.createEnvironmentWithFullJdk(getTestRootDisposable());
|
||||
blackBoxFileByFullPath(filename);
|
||||
}
|
||||
|
||||
public void doTestMultiFile(@NotNull String folderName) {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.ALL);
|
||||
|
||||
final List<String> files = new ArrayList<String>(2);
|
||||
FileUtil.processFilesRecursively(new File(folderName), new Processor<File>() {
|
||||
@Override
|
||||
public boolean process(File file) {
|
||||
if (file.getName().endsWith(".kt")) {
|
||||
files.add(file.getPath());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
blackBoxMultiFileByFullPath(files.toArray(new String[files.size()]));
|
||||
}
|
||||
}
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.codegen.generated;
|
||||
|
||||
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.codegen.generated.AbstractBlackBoxCodegenTest;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/codegen/boxMultiFile")
|
||||
public class BlackBoxMultiFileCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInBoxMultiFile() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/boxMultiFile"), Pattern.compile("^(.+)$"), false);
|
||||
}
|
||||
|
||||
@TestMetadata("internalVisibility")
|
||||
public void testInternalVisibility() throws Exception {
|
||||
doTestMultiFile("compiler/testData/codegen/boxMultiFile/internalVisibility");
|
||||
}
|
||||
|
||||
@TestMetadata("kt1515")
|
||||
public void testKt1515() throws Exception {
|
||||
doTestMultiFile("compiler/testData/codegen/boxMultiFile/kt1515");
|
||||
}
|
||||
|
||||
@TestMetadata("kt1528")
|
||||
public void testKt1528() throws Exception {
|
||||
doTestMultiFile("compiler/testData/codegen/boxMultiFile/kt1528");
|
||||
}
|
||||
|
||||
@TestMetadata("kt1845")
|
||||
public void testKt1845() throws Exception {
|
||||
doTestMultiFile("compiler/testData/codegen/boxMultiFile/kt1845");
|
||||
}
|
||||
|
||||
@TestMetadata("kt2060")
|
||||
public void testKt2060() throws Exception {
|
||||
doTestMultiFile("compiler/testData/codegen/boxMultiFile/kt2060");
|
||||
}
|
||||
|
||||
@TestMetadata("kt2257")
|
||||
public void testKt2257() throws Exception {
|
||||
doTestMultiFile("compiler/testData/codegen/boxMultiFile/kt2257");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedPackages")
|
||||
public void testNestedPackages() throws Exception {
|
||||
doTestMultiFile("compiler/testData/codegen/boxMultiFile/nestedPackages");
|
||||
}
|
||||
|
||||
@TestMetadata("sameFileName")
|
||||
public void testSameFileName() throws Exception {
|
||||
doTestMultiFile("compiler/testData/codegen/boxMultiFile/sameFileName");
|
||||
}
|
||||
|
||||
@TestMetadata("simple")
|
||||
public void testSimple() throws Exception {
|
||||
doTestMultiFile("compiler/testData/codegen/boxMultiFile/simple");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class SimpleTestClassModel implements TestClassModel {
|
||||
File[] listFiles = rootFile.listFiles();
|
||||
if (listFiles != null) {
|
||||
for (File file : listFiles) {
|
||||
if (!file.isDirectory() && filenamePattern.matcher(file.getName()).matches()) {
|
||||
if (filenamePattern.matcher(file.getName()).matches()) {
|
||||
result.add(new SimpleTestMethodModel(rootFile, file, doTestMethodName, filenamePattern));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,8 @@ public class GenerateTests {
|
||||
testModel("compiler/testData/diagnostics/tests/script", true, "ktscript", "doTest")
|
||||
);
|
||||
|
||||
GenerateRangesCodegenTestData.main(args);
|
||||
|
||||
generateTest(
|
||||
"compiler/tests/",
|
||||
"BlackBoxCodegenTestGenerated",
|
||||
@@ -74,7 +76,12 @@ public class GenerateTests {
|
||||
testModel("compiler/testData/codegen/box", "doTest")
|
||||
);
|
||||
|
||||
GenerateRangesCodegenTestData.main(args);
|
||||
generateTest(
|
||||
"compiler/tests/",
|
||||
"BlackBoxMultiFileCodegenTestGenerated",
|
||||
AbstractBlackBoxCodegenTest.class,
|
||||
new SimpleTestClassModel(new File("compiler/testData/codegen/boxMultiFile"), false, Pattern.compile("^(.+)$"), "doTestMultiFile")
|
||||
);
|
||||
|
||||
generateTest(
|
||||
"compiler/tests/",
|
||||
|
||||
Reference in New Issue
Block a user