added configuration kind parameter to tests
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.jet.jvm.compiler;
|
package org.jetbrains.jet.jvm.compiler;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.ConfigurationKind;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||||
import org.jetbrains.jet.test.generator.SimpleTestClassModel;
|
import org.jetbrains.jet.test.generator.SimpleTestClassModel;
|
||||||
@@ -46,9 +47,9 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
|||||||
File javaFile = new File(javaFileName);
|
File javaFile = new File(javaFileName);
|
||||||
File ktFile = new File(javaFile.getPath().replaceFirst("\\.java$", ".kt"));
|
File ktFile = new File(javaFile.getPath().replaceFirst("\\.java$", ".kt"));
|
||||||
File txtFile = new File(javaFile.getPath().replaceFirst("\\.java$", ".txt"));
|
File txtFile = new File(javaFile.getPath().replaceFirst("\\.java$", ".txt"));
|
||||||
NamespaceDescriptor nsa = analyzeKotlinAndLoadTestNamespace(ktFile, myTestRootDisposable);
|
NamespaceDescriptor nsa = analyzeKotlinAndLoadTestNamespace(ktFile, myTestRootDisposable, ConfigurationKind.JDK_AND_ANNOTATIONS);
|
||||||
NamespaceDescriptor nsb = compileJavaAndLoadTestNamespaceFromBinary(Collections.singletonList(javaFile),
|
NamespaceDescriptor nsb = compileJavaAndLoadTestNamespaceFromBinary(Collections.singletonList(javaFile),
|
||||||
tmpdir, myTestRootDisposable);
|
tmpdir, myTestRootDisposable, ConfigurationKind.JDK_AND_ANNOTATIONS);
|
||||||
compareNamespaces(nsa, nsb, DONT_INCLUDE_METHODS_OF_OBJECT, txtFile);
|
compareNamespaces(nsa, nsb, DONT_INCLUDE_METHODS_OF_OBJECT, txtFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.jvm.compiler;
|
|||||||
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.ConfigurationKind;
|
||||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||||
@@ -56,7 +57,7 @@ public class CompileJavaAgainstKotlinTest extends TestCaseWithTmpdir {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void runTest() throws Throwable {
|
protected void runTest() throws Throwable {
|
||||||
compileKotlinToDirAndGetAnalyzeExhaust(ktFile, tmpdir, getTestRootDisposable());
|
compileKotlinToDirAndGetAnalyzeExhaust(ktFile, tmpdir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY);
|
||||||
|
|
||||||
List<String> options = Arrays.asList(
|
List<String> options = Arrays.asList(
|
||||||
"-classpath", tmpdir.getPath() + System.getProperty("path.separator") + "out/production/stdlib",
|
"-classpath", tmpdir.getPath() + System.getProperty("path.separator") + "out/production/stdlib",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.jvm.compiler;
|
|||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.ConfigurationKind;
|
||||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||||
@@ -54,13 +55,13 @@ public final class LoadCompiledKotlinTest extends TestCaseWithTmpdir {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runTest() throws Exception {
|
public void runTest() throws Exception {
|
||||||
AnalyzeExhaust exhaust = compileKotlinToDirAndGetAnalyzeExhaust(testFile, tmpdir, getTestRootDisposable());
|
AnalyzeExhaust exhaust = compileKotlinToDirAndGetAnalyzeExhaust(testFile, tmpdir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY);
|
||||||
|
|
||||||
NamespaceDescriptor namespaceFromSource = exhaust.getBindingContext().get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR,
|
NamespaceDescriptor namespaceFromSource = exhaust.getBindingContext().get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR,
|
||||||
TEST_PACKAGE_FQNAME);
|
TEST_PACKAGE_FQNAME);
|
||||||
assert namespaceFromSource != null;
|
assert namespaceFromSource != null;
|
||||||
Assert.assertEquals("test", namespaceFromSource.getName().getName());
|
Assert.assertEquals("test", namespaceFromSource.getName().getName());
|
||||||
NamespaceDescriptor namespaceFromClass = LoadDescriptorUtil.loadTestNamespaceFromBinaries(tmpdir, getTestRootDisposable());
|
NamespaceDescriptor namespaceFromClass = LoadDescriptorUtil.loadTestNamespaceFromBinaries(tmpdir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY);
|
||||||
compareNamespaces(namespaceFromSource, namespaceFromClass, NamespaceComparator.DONT_INCLUDE_METHODS_OF_OBJECT, txtFile);
|
compareNamespaces(namespaceFromSource, namespaceFromClass, NamespaceComparator.DONT_INCLUDE_METHODS_OF_OBJECT, txtFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,20 +69,22 @@ public final class LoadDescriptorUtil {
|
|||||||
public static NamespaceDescriptor compileKotlinAndLoadTestNamespaceDescriptorFromBinary(
|
public static NamespaceDescriptor compileKotlinAndLoadTestNamespaceDescriptorFromBinary(
|
||||||
@NotNull File kotlinFile,
|
@NotNull File kotlinFile,
|
||||||
@NotNull File outDir,
|
@NotNull File outDir,
|
||||||
@NotNull Disposable disposable
|
@NotNull Disposable disposable,
|
||||||
|
@NotNull ConfigurationKind configurationKind
|
||||||
)
|
)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
compileKotlinToDirAndGetAnalyzeExhaust(kotlinFile, outDir, disposable);
|
compileKotlinToDirAndGetAnalyzeExhaust(kotlinFile, outDir, disposable, configurationKind);
|
||||||
return loadTestNamespaceFromBinaries(outDir, disposable);
|
return loadTestNamespaceFromBinaries(outDir, disposable, ConfigurationKind.JDK_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static AnalyzeExhaust compileKotlinToDirAndGetAnalyzeExhaust(
|
public static AnalyzeExhaust compileKotlinToDirAndGetAnalyzeExhaust(
|
||||||
@NotNull File kotlinFile,
|
@NotNull File kotlinFile,
|
||||||
@NotNull File outDir,
|
@NotNull File outDir,
|
||||||
@NotNull Disposable disposable
|
@NotNull Disposable disposable,
|
||||||
|
@NotNull ConfigurationKind configurationKind
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
JetFileAndExhaust fileAndExhaust = JetFileAndExhaust.createJetFileAndAnalyze(kotlinFile, disposable);
|
JetFileAndExhaust fileAndExhaust = JetFileAndExhaust.createJetFileAndAnalyze(kotlinFile, disposable, configurationKind);
|
||||||
GenerationState state = GenerationUtils.compileFilesGetGenerationState(fileAndExhaust.getJetFile().getProject(), fileAndExhaust.getExhaust(), Collections.singletonList(
|
GenerationState state = GenerationUtils.compileFilesGetGenerationState(fileAndExhaust.getJetFile().getProject(), fileAndExhaust.getExhaust(), Collections.singletonList(
|
||||||
fileAndExhaust.getJetFile()));
|
fileAndExhaust.getJetFile()));
|
||||||
ClassFileFactory classFileFactory = state.getFactory();
|
ClassFileFactory classFileFactory = state.getFactory();
|
||||||
@@ -91,11 +93,11 @@ public final class LoadDescriptorUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static NamespaceDescriptor loadTestNamespaceFromBinaries(@NotNull File outDir, @NotNull Disposable disposable) {
|
public static NamespaceDescriptor loadTestNamespaceFromBinaries(@NotNull File outDir, @NotNull Disposable disposable, @NotNull ConfigurationKind configurationKind) {
|
||||||
Disposer.dispose(disposable);
|
Disposer.dispose(disposable);
|
||||||
|
|
||||||
CompilerConfiguration configuration = CompileCompilerDependenciesTest.compilerConfigurationForTests(
|
CompilerConfiguration configuration = CompileCompilerDependenciesTest.compilerConfigurationForTests(
|
||||||
ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, JetTestUtils.getAnnotationsJar(), outDir,
|
configurationKind, TestJdkKind.MOCK_JDK, JetTestUtils.getAnnotationsJar(), outDir,
|
||||||
ForTestCompileRuntime.runtimeJarForTests());
|
ForTestCompileRuntime.runtimeJarForTests());
|
||||||
JetCoreEnvironment jetCoreEnvironment = new JetCoreEnvironment(disposable, configuration);
|
JetCoreEnvironment jetCoreEnvironment = new JetCoreEnvironment(disposable, configuration);
|
||||||
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(BuiltinsScopeExtensionMode.ALL,
|
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(BuiltinsScopeExtensionMode.ALL,
|
||||||
@@ -111,11 +113,12 @@ public final class LoadDescriptorUtil {
|
|||||||
public static NamespaceDescriptor compileJavaAndLoadTestNamespaceFromBinary(
|
public static NamespaceDescriptor compileJavaAndLoadTestNamespaceFromBinary(
|
||||||
@NotNull Collection<File> javaFiles,
|
@NotNull Collection<File> javaFiles,
|
||||||
@NotNull File outDir,
|
@NotNull File outDir,
|
||||||
@NotNull Disposable disposable
|
@NotNull Disposable disposable,
|
||||||
|
@NotNull ConfigurationKind configurationKind
|
||||||
)
|
)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
compileJavaWithAnnotationsJar(javaFiles, outDir);
|
compileJavaWithAnnotationsJar(javaFiles, outDir);
|
||||||
return loadTestNamespaceFromBinaries(outDir, disposable);
|
return loadTestNamespaceFromBinaries(outDir, disposable, configurationKind);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void compileJavaWithAnnotationsJar(@NotNull Collection<File> javaFiles, @NotNull File outDir) throws IOException {
|
private static void compileJavaWithAnnotationsJar(@NotNull Collection<File> javaFiles, @NotNull File outDir) throws IOException {
|
||||||
@@ -127,8 +130,8 @@ public final class LoadDescriptorUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static NamespaceDescriptor analyzeKotlinAndLoadTestNamespace(@NotNull File ktFile, @NotNull Disposable disposable) throws Exception {
|
public static NamespaceDescriptor analyzeKotlinAndLoadTestNamespace(@NotNull File ktFile, @NotNull Disposable disposable, @NotNull ConfigurationKind configurationKind) throws Exception {
|
||||||
JetFileAndExhaust fileAndExhaust = JetFileAndExhaust.createJetFileAndAnalyze(ktFile, disposable);
|
JetFileAndExhaust fileAndExhaust = JetFileAndExhaust.createJetFileAndAnalyze(ktFile, disposable, configurationKind);
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
return fileAndExhaust.getExhaust().getBindingContext().get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, TEST_PACKAGE_FQNAME);
|
return fileAndExhaust.getExhaust().getBindingContext().get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, TEST_PACKAGE_FQNAME);
|
||||||
}
|
}
|
||||||
@@ -136,9 +139,9 @@ public final class LoadDescriptorUtil {
|
|||||||
private static class JetFileAndExhaust {
|
private static class JetFileAndExhaust {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static JetFileAndExhaust createJetFileAndAnalyze(@NotNull File kotlinFile, @NotNull Disposable disposable)
|
public static JetFileAndExhaust createJetFileAndAnalyze(@NotNull File kotlinFile, @NotNull Disposable disposable, @NotNull ConfigurationKind configurationKind)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
JetCoreEnvironment jetCoreEnvironment = createEnvironmentWithMockJdkAndIdeaAnnotations(disposable, ConfigurationKind.JDK_ONLY);
|
JetCoreEnvironment jetCoreEnvironment = createEnvironmentWithMockJdkAndIdeaAnnotations(disposable, configurationKind);
|
||||||
JetFile jetFile = createFile(jetCoreEnvironment.getProject(), FileUtil.loadFile(kotlinFile, true));
|
JetFile jetFile = createFile(jetCoreEnvironment.getProject(), FileUtil.loadFile(kotlinFile, true));
|
||||||
AnalyzeExhaust exhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
|
AnalyzeExhaust exhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
|
||||||
jetFile, Collections.<AnalyzerScriptParameter>emptyList(), BuiltinsScopeExtensionMode.ALL);
|
jetFile, Collections.<AnalyzerScriptParameter>emptyList(), BuiltinsScopeExtensionMode.ALL);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public final class LoadJavaCustomTest extends KotlinTestWithEnvironment {
|
|||||||
});
|
});
|
||||||
File expected = new File(expectedFileName);
|
File expected = new File(expectedFileName);
|
||||||
File tmpDir = JetTestUtils.tmpDir(expected.getName());
|
File tmpDir = JetTestUtils.tmpDir(expected.getName());
|
||||||
NamespaceDescriptor javaNamespaceDescriptor = compileJavaAndLoadTestNamespaceFromBinary(files, tmpDir, getTestRootDisposable());
|
NamespaceDescriptor javaNamespaceDescriptor = compileJavaAndLoadTestNamespaceFromBinary(files, tmpDir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY);
|
||||||
//NOTE: comparing namespace to file (hack)
|
//NOTE: comparing namespace to file (hack)
|
||||||
NamespaceComparator.compareNamespaces(javaNamespaceDescriptor, javaNamespaceDescriptor, NamespaceComparator.DONT_INCLUDE_METHODS_OF_OBJECT, expected);
|
NamespaceComparator.compareNamespaces(javaNamespaceDescriptor, javaNamespaceDescriptor, NamespaceComparator.DONT_INCLUDE_METHODS_OF_OBJECT, expected);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user