Allow to reference internal API in stdlib tests
This commit is contained in:
+7
@@ -56,6 +56,13 @@ public class ForTestCompileRuntime {
|
|||||||
return assertExists(new File("dist/kotlinc/lib/kotlin-script-runtime.jar"));
|
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
|
@NotNull
|
||||||
private static File assertExists(@NotNull File file) {
|
private static File assertExists(@NotNull File file) {
|
||||||
if (!file.exists()) {
|
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.CompilerConfiguration;
|
||||||
import org.jetbrains.kotlin.config.ContentRootsKt;
|
import org.jetbrains.kotlin.config.ContentRootsKt;
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||||
|
import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityManager;
|
||||||
import org.jetbrains.kotlin.psi.KtClass;
|
import org.jetbrains.kotlin.psi.KtClass;
|
||||||
import org.jetbrains.kotlin.psi.KtDeclaration;
|
import org.jetbrains.kotlin.psi.KtDeclaration;
|
||||||
import org.jetbrains.kotlin.psi.KtFile;
|
import org.jetbrains.kotlin.psi.KtFile;
|
||||||
@@ -51,7 +52,11 @@ public class StdlibTest extends KotlinTestWithEnvironment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected KotlinCoreEnvironment createEnvironment() {
|
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");
|
File junitJar = new File("libraries/lib/junit-4.11.jar");
|
||||||
assertTrue(junitJar.exists());
|
assertTrue(junitJar.exists());
|
||||||
@@ -63,7 +68,14 @@ public class StdlibTest extends KotlinTestWithEnvironment {
|
|||||||
new PrintingMessageCollector(System.err, MessageRenderer.PLAIN_FULL_PATHS, false)
|
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 {
|
public void testStdlib() throws ClassNotFoundException {
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ class FilesTest {
|
|||||||
assertEquals(File("../../test"), File("test").relativeTo(File("dir/dir")))
|
assertEquals(File("../../test"), File("test").relativeTo(File("dir/dir")))
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
@Suppress("INVISIBLE_MEMBER")
|
||||||
private fun checkFilePathComponents(f: File, root: File, elements: List<String>) {
|
private fun checkFilePathComponents(f: File, root: File, elements: List<String>) {
|
||||||
assertEquals(root, f.root)
|
assertEquals(root, f.root)
|
||||||
val components = f.toComponents()
|
val components = f.toComponents()
|
||||||
@@ -212,7 +212,6 @@ class FilesTest {
|
|||||||
checkFilePathComponents(File("."), File(""), listOf("."))
|
checkFilePathComponents(File("."), File(""), listOf("."))
|
||||||
checkFilePathComponents(File(".."), File(""), listOf(".."))
|
checkFilePathComponents(File(".."), File(""), listOf(".."))
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
@test fun fileRoot() {
|
@test fun fileRoot() {
|
||||||
val rooted = File("/foo/bar")
|
val rooted = File("/foo/bar")
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ class CoercionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Suppress("DEPRECATION_ERROR")
|
|
||||||
fun coercionsDouble() {
|
fun coercionsDouble() {
|
||||||
expect(5.0) { 5.0.coerceAtLeast(1.0) }
|
expect(5.0) { 5.0.coerceAtLeast(1.0) }
|
||||||
expect(5.0) { 1.0.coerceAtLeast(5.0) }
|
expect(5.0) { 1.0.coerceAtLeast(5.0) }
|
||||||
|
|||||||
Reference in New Issue
Block a user