Allow to reference internal API in stdlib tests

This commit is contained in:
Ilya Gorbunov
2016-10-19 21:32:03 +03:00
parent 8d76617094
commit 1c7196a1fb
4 changed files with 22 additions and 5 deletions
@@ -56,6 +56,13 @@ public class ForTestCompileRuntime {
return assertExists(new File("dist/kotlinc/lib/kotlin-script-runtime.jar"));
}
// TODO: Do not use these classes, remove them after stdlib tests are merged in the same build as the compiler
@NotNull
@Deprecated
public static File[] runtimeClassesForTests() {
return new File[] { assertExists(new File("dist/classes/builtins")), assertExists(new File("dist/classes/stdlib")) };
}
@NotNull
private static File assertExists(@NotNull File file) {
if (!file.exists()) {
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.config.CompilerConfiguration;
import org.jetbrains.kotlin.config.ContentRootsKt;
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityManager;
import org.jetbrains.kotlin.psi.KtClass;
import org.jetbrains.kotlin.psi.KtDeclaration;
import org.jetbrains.kotlin.psi.KtFile;
@@ -51,7 +52,11 @@ public class StdlibTest extends KotlinTestWithEnvironment {
@Override
protected KotlinCoreEnvironment createEnvironment() {
CompilerConfiguration configuration = KotlinTestUtils.newConfiguration(ConfigurationKind.ALL, TestJdkKind.FULL_JDK);
@SuppressWarnings("deprecation")
File[] runtimeClasspath = ForTestCompileRuntime.runtimeClassesForTests();
CompilerConfiguration configuration = KotlinTestUtils.newConfiguration(ConfigurationKind.JDK_NO_RUNTIME, TestJdkKind.FULL_JDK, runtimeClasspath);
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.kotlinTestJarForTests());
File junitJar = new File("libraries/lib/junit-4.11.jar");
assertTrue(junitJar.exists());
@@ -63,7 +68,14 @@ public class StdlibTest extends KotlinTestWithEnvironment {
new PrintingMessageCollector(System.err, MessageRenderer.PLAIN_FULL_PATHS, false)
);
return KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
ModuleVisibilityManager moduleVisibilityManager = ModuleVisibilityManager.SERVICE.getInstance(environment.getProject());
for (File path: runtimeClasspath) {
moduleVisibilityManager.addFriendPath(path.getPath());
}
return environment;
}
public void testStdlib() throws ClassNotFoundException {
+1 -2
View File
@@ -184,7 +184,7 @@ class FilesTest {
assertEquals(File("../../test"), File("test").relativeTo(File("dir/dir")))
}
/*
@Suppress("INVISIBLE_MEMBER")
private fun checkFilePathComponents(f: File, root: File, elements: List<String>) {
assertEquals(root, f.root)
val components = f.toComponents()
@@ -212,7 +212,6 @@ class FilesTest {
checkFilePathComponents(File("."), File(""), listOf("."))
checkFilePathComponents(File(".."), File(""), listOf(".."))
}
*/
@test fun fileRoot() {
val rooted = File("/foo/bar")
@@ -65,7 +65,6 @@ class CoercionTest {
}
@Test
@Suppress("DEPRECATION_ERROR")
fun coercionsDouble() {
expect(5.0) { 5.0.coerceAtLeast(1.0) }
expect(5.0) { 1.0.coerceAtLeast(5.0) }