From a0b780c7bbb1c96dfdc7be3b8f22f1e11c4e05a3 Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Thu, 7 Mar 2013 14:37:10 +0400 Subject: [PATCH] Moved sourceJava cases to generated test. --- .../sourceJava}/ErrorTypes.java | 0 .../sourceJava}/ErrorTypes.txt | 0 .../ReturnInnerSubclassOfSupersInner.java | 2 ++ .../ReturnInnerSubclassOfSupersInner.txt | 0 .../sourceJava}/ReturnNotSubtype.java | 0 .../sourceJava}/ReturnNotSubtype.txt | 0 .../WrongNumberOfGenericParameters.java | 0 .../WrongNumberOfGenericParameters.txt | 0 .../jvm/compiler/AbstractLoadJavaTest.java | 12 +++++-- .../jet/jvm/compiler/LoadJavaCustomTest.java | 16 ---------- .../jvm/compiler/LoadJavaTestGenerated.java | 31 ++++++++++++++++++- .../jet/generators/tests/GenerateTests.java | 3 +- 12 files changed, 43 insertions(+), 21 deletions(-) rename compiler/testData/{loadJavaCustom/errorTypes/test => loadJava/sourceJava}/ErrorTypes.java (100%) rename compiler/testData/{loadJavaCustom/errorTypes => loadJava/sourceJava}/ErrorTypes.txt (100%) rename compiler/testData/{loadJavaCustom/returnInnerSubclassOfSupersInner/test => loadJava/sourceJava}/ReturnInnerSubclassOfSupersInner.java (73%) rename compiler/testData/{loadJavaCustom/returnInnerSubclassOfSupersInner => loadJava/sourceJava}/ReturnInnerSubclassOfSupersInner.txt (100%) rename compiler/testData/{loadJavaCustom/returnNotSubtype/test => loadJava/sourceJava}/ReturnNotSubtype.java (100%) rename compiler/testData/{loadJavaCustom/returnNotSubtype => loadJava/sourceJava}/ReturnNotSubtype.txt (100%) rename compiler/testData/{loadJavaCustom/errors/test => loadJava/sourceJava}/WrongNumberOfGenericParameters.java (100%) rename compiler/testData/{loadJavaCustom/errors => loadJava/sourceJava}/WrongNumberOfGenericParameters.txt (100%) diff --git a/compiler/testData/loadJavaCustom/errorTypes/test/ErrorTypes.java b/compiler/testData/loadJava/sourceJava/ErrorTypes.java similarity index 100% rename from compiler/testData/loadJavaCustom/errorTypes/test/ErrorTypes.java rename to compiler/testData/loadJava/sourceJava/ErrorTypes.java diff --git a/compiler/testData/loadJavaCustom/errorTypes/ErrorTypes.txt b/compiler/testData/loadJava/sourceJava/ErrorTypes.txt similarity index 100% rename from compiler/testData/loadJavaCustom/errorTypes/ErrorTypes.txt rename to compiler/testData/loadJava/sourceJava/ErrorTypes.txt diff --git a/compiler/testData/loadJavaCustom/returnInnerSubclassOfSupersInner/test/ReturnInnerSubclassOfSupersInner.java b/compiler/testData/loadJava/sourceJava/ReturnInnerSubclassOfSupersInner.java similarity index 73% rename from compiler/testData/loadJavaCustom/returnInnerSubclassOfSupersInner/test/ReturnInnerSubclassOfSupersInner.java rename to compiler/testData/loadJava/sourceJava/ReturnInnerSubclassOfSupersInner.java index d5104edfb6f..953ba941ff8 100644 --- a/compiler/testData/loadJavaCustom/returnInnerSubclassOfSupersInner/test/ReturnInnerSubclassOfSupersInner.java +++ b/compiler/testData/loadJava/sourceJava/ReturnInnerSubclassOfSupersInner.java @@ -1,6 +1,8 @@ package test; //Note: this test could be written in simple load java test, but KT-3128 prevents from writing Kotlin counterpart for it +//See the same test data in compiledJava test data. +//Test data is duplicated because Java PSI used to have some differences when loading parallel generic hierarchies from cls and source code. public interface ReturnInnerSubclassOfSupersInner { class Super { class Inner { diff --git a/compiler/testData/loadJavaCustom/returnInnerSubclassOfSupersInner/ReturnInnerSubclassOfSupersInner.txt b/compiler/testData/loadJava/sourceJava/ReturnInnerSubclassOfSupersInner.txt similarity index 100% rename from compiler/testData/loadJavaCustom/returnInnerSubclassOfSupersInner/ReturnInnerSubclassOfSupersInner.txt rename to compiler/testData/loadJava/sourceJava/ReturnInnerSubclassOfSupersInner.txt diff --git a/compiler/testData/loadJavaCustom/returnNotSubtype/test/ReturnNotSubtype.java b/compiler/testData/loadJava/sourceJava/ReturnNotSubtype.java similarity index 100% rename from compiler/testData/loadJavaCustom/returnNotSubtype/test/ReturnNotSubtype.java rename to compiler/testData/loadJava/sourceJava/ReturnNotSubtype.java diff --git a/compiler/testData/loadJavaCustom/returnNotSubtype/ReturnNotSubtype.txt b/compiler/testData/loadJava/sourceJava/ReturnNotSubtype.txt similarity index 100% rename from compiler/testData/loadJavaCustom/returnNotSubtype/ReturnNotSubtype.txt rename to compiler/testData/loadJava/sourceJava/ReturnNotSubtype.txt diff --git a/compiler/testData/loadJavaCustom/errors/test/WrongNumberOfGenericParameters.java b/compiler/testData/loadJava/sourceJava/WrongNumberOfGenericParameters.java similarity index 100% rename from compiler/testData/loadJavaCustom/errors/test/WrongNumberOfGenericParameters.java rename to compiler/testData/loadJava/sourceJava/WrongNumberOfGenericParameters.java diff --git a/compiler/testData/loadJavaCustom/errors/WrongNumberOfGenericParameters.txt b/compiler/testData/loadJava/sourceJava/WrongNumberOfGenericParameters.txt similarity index 100% rename from compiler/testData/loadJavaCustom/errors/WrongNumberOfGenericParameters.txt rename to compiler/testData/loadJava/sourceJava/WrongNumberOfGenericParameters.txt diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/AbstractLoadJavaTest.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/AbstractLoadJavaTest.java index 68c7a302702..1138559bfc8 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/AbstractLoadJavaTest.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/AbstractLoadJavaTest.java @@ -18,6 +18,7 @@ package org.jetbrains.jet.jvm.compiler; import com.google.common.base.Predicates; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.psi.PsiFile; import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; @@ -89,11 +90,16 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir { checkJavaNamespace(expectedFile, javaNamespaceAndContext.first, javaNamespaceAndContext.second); } - protected void doTestSourceJava(@NotNull String expectedFileName, @NotNull String javaRoot) throws Exception { - File expectedFile = new File(expectedFileName); + protected void doTestSourceJava(@NotNull String javaFileName) throws Exception { + File originalJavaFile = new File(javaFileName); + File expectedFile = new File(javaFileName.replaceFirst("\\.java$", ".txt")); + + File testPackageDir = new File(tmpdir, "test"); + assertTrue(testPackageDir.mkdir()); + FileUtil.copy(originalJavaFile, new File(testPackageDir, originalJavaFile.getName())); Pair javaNamespaceAndContext = loadTestNamespaceAndBindingContextFromJavaRoot( - new File(javaRoot), getTestRootDisposable(), ConfigurationKind.JDK_ONLY); + tmpdir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY); checkJavaNamespace(expectedFile, javaNamespaceAndContext.first, javaNamespaceAndContext.second); } diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaCustomTest.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaCustomTest.java index 0b958d7d222..8f18c36ad7b 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaCustomTest.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaCustomTest.java @@ -35,22 +35,6 @@ public final class LoadJavaCustomTest extends AbstractLoadJavaTest { javaDir + "/awt/Frame.java"); } - public void testReturnInnerSubclassOfSupersInnerNoCompile() throws Exception { - // Test is here because Java PSI used to have some differences when loading parallel generic hierarchies from cls and source code. - String dir = PATH + "/returnInnerSubclassOfSupersInner/"; - doTestSourceJava(dir + "ReturnInnerSubclassOfSupersInner.txt", dir); - } - - public void testReturnNotSubtype() throws Exception { - String dir = PATH + "/returnNotSubtype/"; - doTestSourceJava(dir + "ReturnNotSubtype.txt", dir); - } - - public void testErrorTypes() throws Exception { - String dir = PATH + "/errorTypes/"; - doTestSourceJava(dir + "ErrorTypes.txt", dir); - } - public static class SubclassingKotlinInJavaTest extends AbstractLoadJavaTest { public void testSubclassingKotlinInJava() throws Exception { doTestJavaAgainstKotlin(PATH + "/" + getTestName(true)); diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java index 424a65885d1..57660c374f6 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java @@ -30,7 +30,7 @@ import org.jetbrains.jet.jvm.compiler.AbstractLoadJavaTest; /** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") -@InnerTestClasses({LoadJavaTestGenerated.CompiledJavaCompareWithKotlin.class, LoadJavaTestGenerated.CompiledJava.class}) +@InnerTestClasses({LoadJavaTestGenerated.CompiledJavaCompareWithKotlin.class, LoadJavaTestGenerated.CompiledJava.class, LoadJavaTestGenerated.SourceJava.class}) public class LoadJavaTestGenerated extends AbstractLoadJavaTest { @TestMetadata("compiler/testData/loadJava/compiledJavaCompareWithKotlin") @InnerTestClasses({CompiledJavaCompareWithKotlin.Annotation.class, CompiledJavaCompareWithKotlin.Constructor.class, CompiledJavaCompareWithKotlin.JavaBean.class, CompiledJavaCompareWithKotlin.KotlinSignature.class, CompiledJavaCompareWithKotlin.Library.class, CompiledJavaCompareWithKotlin.Modality.class, CompiledJavaCompareWithKotlin.NotNull.class, CompiledJavaCompareWithKotlin.Vararg.class}) @@ -1090,10 +1090,39 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { } } + @TestMetadata("compiler/testData/loadJava/sourceJava") + public static class SourceJava extends AbstractLoadJavaTest { + public void testAllFilesPresentInSourceJava() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/sourceJava"), Pattern.compile("^(.+)\\.java$"), true); + } + + @TestMetadata("ErrorTypes.java") + public void testErrorTypes() throws Exception { + doTestSourceJava("compiler/testData/loadJava/sourceJava/ErrorTypes.java"); + } + + @TestMetadata("ReturnInnerSubclassOfSupersInner.java") + public void testReturnInnerSubclassOfSupersInner() throws Exception { + doTestSourceJava("compiler/testData/loadJava/sourceJava/ReturnInnerSubclassOfSupersInner.java"); + } + + @TestMetadata("ReturnNotSubtype.java") + public void testReturnNotSubtype() throws Exception { + doTestSourceJava("compiler/testData/loadJava/sourceJava/ReturnNotSubtype.java"); + } + + @TestMetadata("WrongNumberOfGenericParameters.java") + public void testWrongNumberOfGenericParameters() throws Exception { + doTestSourceJava("compiler/testData/loadJava/sourceJava/WrongNumberOfGenericParameters.java"); + } + + } + public static Test suite() { TestSuite suite = new TestSuite("LoadJavaTestGenerated"); suite.addTest(CompiledJavaCompareWithKotlin.innerSuite()); suite.addTest(CompiledJava.innerSuite()); + suite.addTestSuite(SourceJava.class); return suite; } } diff --git a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java index 6aa1a15abb7..d92cb181d42 100644 --- a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java +++ b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java @@ -148,7 +148,8 @@ public class GenerateTests { "LoadJavaTestGenerated", AbstractLoadJavaTest.class, testModel("compiler/testData/loadJava/compiledJavaCompareWithKotlin", true, "java", "doTest"), - testModel("compiler/testData/loadJava/compiledJava", true, "java", "doTestCompiledJava") + testModel("compiler/testData/loadJava/compiledJava", true, "java", "doTestCompiledJava"), + testModel("compiler/testData/loadJava/sourceJava", true, "java", "doTestSourceJava") ); generateTest(