Merge two tests with almost the same logic
This commit is contained in:
-58
@@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.jvm.compiler;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptorForObject;
|
|
||||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public final class CompileKotlinAgainstBinariesCustomTest extends AbstractCompileKotlinAgainstCustomBinariesTest {
|
|
||||||
public static final String TEST_DATA_PATH = "compiler/testData/compileKotlinAgainstBinariesCustom/";
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private Collection<DeclarationDescriptor> analyzeAndGetAllDescriptors() throws IOException {
|
|
||||||
String testName = getTestName(true);
|
|
||||||
File ktFile = new File(TEST_DATA_PATH + testName, testName + ".kt");
|
|
||||||
return analyzeFileToNamespace(ktFile).getMemberScope().getAllDescriptors();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testDuplicateObjectInBinaryAndSources() throws Exception {
|
|
||||||
Collection<DeclarationDescriptor> allDescriptors = analyzeAndGetAllDescriptors();
|
|
||||||
assertEquals(allDescriptors.size(), 2);
|
|
||||||
for (DeclarationDescriptor descriptor : allDescriptors) {
|
|
||||||
assertTrue(descriptor.getName().asString().equals("Lol"));
|
|
||||||
assertTrue(descriptor instanceof VariableDescriptorForObject);
|
|
||||||
assertFalse("Object property should have valid class",
|
|
||||||
ErrorUtils.isError(((VariableDescriptorForObject) descriptor).getObjectClass()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testBrokenJarWithNoClassForObjectProperty() throws Exception {
|
|
||||||
Collection<DeclarationDescriptor> allDescriptors = analyzeAndGetAllDescriptors();
|
|
||||||
assertEquals(allDescriptors.size(), 1);
|
|
||||||
DeclarationDescriptor descriptor = allDescriptors.iterator().next();
|
|
||||||
assertTrue(descriptor.getName().asString().equals("Lol"));
|
|
||||||
assertTrue(descriptor instanceof VariableDescriptorForObject);
|
|
||||||
assertTrue("Object property should have an error class",
|
|
||||||
ErrorUtils.isError(((VariableDescriptorForObject) descriptor).getObjectClass()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-73
@@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.jvm.compiler;
|
|
||||||
|
|
||||||
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.jvm.compiler.AbstractCompileKotlinAgainstCustomBinariesTest;
|
|
||||||
|
|
||||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
@TestMetadata("compiler/testData/compileKotlinAgainstCustomBinaries")
|
|
||||||
@InnerTestClasses({CompileKotlinAgainstCustomBinariesGenerated.DuplicateLibraries.class, CompileKotlinAgainstCustomBinariesGenerated.MissingEnumReferencedInAnnotation.class})
|
|
||||||
public class CompileKotlinAgainstCustomBinariesGenerated extends AbstractCompileKotlinAgainstCustomBinariesTest {
|
|
||||||
public void testAllFilesPresentInCompileKotlinAgainstCustomBinaries() throws Exception {
|
|
||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/compileKotlinAgainstCustomBinaries"), Pattern.compile("^(.+)\\.kt$"), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/compileKotlinAgainstCustomBinaries/duplicateLibraries")
|
|
||||||
public static class DuplicateLibraries extends AbstractCompileKotlinAgainstCustomBinariesTest {
|
|
||||||
public void testAllFilesPresentInDuplicateLibraries() throws Exception {
|
|
||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/compileKotlinAgainstCustomBinaries/duplicateLibraries"), Pattern.compile("^(.+)\\.kt$"), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("DuplicateLibraries.kt")
|
|
||||||
public void testDuplicateLibraries() throws Exception {
|
|
||||||
doTest("compiler/testData/compileKotlinAgainstCustomBinaries/duplicateLibraries/DuplicateLibraries.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotation")
|
|
||||||
public static class MissingEnumReferencedInAnnotation extends AbstractCompileKotlinAgainstCustomBinariesTest {
|
|
||||||
public void testAllFilesPresentInMissingEnumReferencedInAnnotation() throws Exception {
|
|
||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotation"), Pattern.compile("^(.+)\\.kt$"), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("MissingEnumReferencedInAnnotation.kt")
|
|
||||||
public void testMissingEnumReferencedInAnnotation() throws Exception {
|
|
||||||
doTest("compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotation/MissingEnumReferencedInAnnotation.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Test suite() {
|
|
||||||
TestSuite suite = new TestSuite("CompileKotlinAgainstCustomBinariesGenerated");
|
|
||||||
suite.addTestSuite(CompileKotlinAgainstCustomBinariesGenerated.class);
|
|
||||||
suite.addTestSuite(DuplicateLibraries.class);
|
|
||||||
suite.addTestSuite(MissingEnumReferencedInAnnotation.class);
|
|
||||||
return suite;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+48
-7
@@ -26,16 +26,20 @@ import org.jetbrains.jet.JetTestUtils;
|
|||||||
import org.jetbrains.jet.TestJdkKind;
|
import org.jetbrains.jet.TestJdkKind;
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.VariableDescriptorForObject;
|
||||||
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||||
|
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||||
import org.jetbrains.jet.test.util.DescriptorValidator;
|
import org.jetbrains.jet.test.util.DescriptorValidator;
|
||||||
import org.jetbrains.jet.test.util.NamespaceComparator;
|
import org.jetbrains.jet.test.util.NamespaceComparator;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
@@ -43,10 +47,11 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
import static org.jetbrains.jet.test.util.NamespaceComparator.validateAndCompareNamespaceWithFile;
|
import static org.jetbrains.jet.test.util.NamespaceComparator.validateAndCompareNamespaceWithFile;
|
||||||
|
|
||||||
public abstract class AbstractCompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||||
protected void doTest(@NotNull String ktFilePath) throws Exception {
|
public static final String TEST_DATA_PATH = "compiler/testData/compileKotlinAgainstCustomBinaries/";
|
||||||
assertTrue(ktFilePath.endsWith(".kt"));
|
|
||||||
File ktFile = new File(ktFilePath);
|
private void doTestWithTxt() throws Exception {
|
||||||
|
File ktFile = new File(TEST_DATA_PATH + getTestName(true), getTestName(false) + ".kt");
|
||||||
|
|
||||||
NamespaceDescriptor namespace = analyzeFileToNamespace(ktFile);
|
NamespaceDescriptor namespace = analyzeFileToNamespace(ktFile);
|
||||||
|
|
||||||
@@ -57,8 +62,8 @@ public abstract class AbstractCompileKotlinAgainstCustomBinariesTest extends Tes
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
protected NamespaceDescriptor analyzeFileToNamespace(@NotNull File ktFile) throws IOException {
|
private NamespaceDescriptor analyzeFileToNamespace(@NotNull File ktFile) throws IOException {
|
||||||
Project project = getEnvironment(ktFile.getParentFile()).getProject();
|
Project project = createEnvironment(ktFile.getParentFile()).getProject();
|
||||||
|
|
||||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(
|
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(
|
||||||
JetTestUtils.loadJetFile(project, ktFile),
|
JetTestUtils.loadJetFile(project, ktFile),
|
||||||
@@ -72,7 +77,7 @@ public abstract class AbstractCompileKotlinAgainstCustomBinariesTest extends Tes
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private JetCoreEnvironment getEnvironment(@NotNull File dir) {
|
private JetCoreEnvironment createEnvironment(@NotNull File dir) {
|
||||||
List<File> jarFiles = FileUtil.findFilesByMask(Pattern.compile("^.*\\.jar$"), dir);
|
List<File> jarFiles = FileUtil.findFilesByMask(Pattern.compile("^.*\\.jar$"), dir);
|
||||||
|
|
||||||
CopyOnWriteArrayList<File> extras = Lists.newCopyOnWriteArrayList();
|
CopyOnWriteArrayList<File> extras = Lists.newCopyOnWriteArrayList();
|
||||||
@@ -85,4 +90,40 @@ public abstract class AbstractCompileKotlinAgainstCustomBinariesTest extends Tes
|
|||||||
|
|
||||||
return new JetCoreEnvironment(getTestRootDisposable(), configurationWithADirInClasspath);
|
return new JetCoreEnvironment(getTestRootDisposable(), configurationWithADirInClasspath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private Collection<DeclarationDescriptor> analyzeAndGetAllDescriptors() throws IOException {
|
||||||
|
String testName = getTestName(true);
|
||||||
|
File ktFile = new File(TEST_DATA_PATH + testName, testName + ".kt");
|
||||||
|
return analyzeFileToNamespace(ktFile).getMemberScope().getAllDescriptors();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDuplicateObjectInBinaryAndSources() throws Exception {
|
||||||
|
Collection<DeclarationDescriptor> allDescriptors = analyzeAndGetAllDescriptors();
|
||||||
|
assertEquals(allDescriptors.size(), 2);
|
||||||
|
for (DeclarationDescriptor descriptor : allDescriptors) {
|
||||||
|
assertTrue(descriptor.getName().asString().equals("Lol"));
|
||||||
|
assertTrue(descriptor instanceof VariableDescriptorForObject);
|
||||||
|
assertFalse("Object property should have valid class",
|
||||||
|
ErrorUtils.isError(((VariableDescriptorForObject) descriptor).getObjectClass()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBrokenJarWithNoClassForObjectProperty() throws Exception {
|
||||||
|
Collection<DeclarationDescriptor> allDescriptors = analyzeAndGetAllDescriptors();
|
||||||
|
assertEquals(allDescriptors.size(), 1);
|
||||||
|
DeclarationDescriptor descriptor = allDescriptors.iterator().next();
|
||||||
|
assertTrue(descriptor.getName().asString().equals("Lol"));
|
||||||
|
assertTrue(descriptor instanceof VariableDescriptorForObject);
|
||||||
|
assertTrue("Object property should have an error class",
|
||||||
|
ErrorUtils.isError(((VariableDescriptorForObject) descriptor).getObjectClass()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testDuplicateLibraries() throws Exception {
|
||||||
|
doTestWithTxt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMissingEnumReferencedInAnnotation() throws Exception {
|
||||||
|
doTestWithTxt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -208,13 +208,6 @@ public class GenerateTests {
|
|||||||
testModel("compiler/testData/compileKotlinAgainstKotlin", true, "A.kt", "doTest")
|
testModel("compiler/testData/compileKotlinAgainstKotlin", true, "A.kt", "doTest")
|
||||||
);
|
);
|
||||||
|
|
||||||
generateTest(
|
|
||||||
"compiler/tests/",
|
|
||||||
"CompileKotlinAgainstCustomBinariesGenerated",
|
|
||||||
AbstractCompileKotlinAgainstCustomBinariesTest.class,
|
|
||||||
testModel("compiler/testData/compileKotlinAgainstCustomBinaries")
|
|
||||||
);
|
|
||||||
|
|
||||||
generateTest(
|
generateTest(
|
||||||
"compiler/tests/",
|
"compiler/tests/",
|
||||||
"LazyResolveDescriptorRendererTestGenerated",
|
"LazyResolveDescriptorRendererTestGenerated",
|
||||||
|
|||||||
Reference in New Issue
Block a user