Finally drop attaching stdlib sources everywhere

This commit is contained in:
Maxim Shafirov
2012-01-24 17:20:19 +04:00
parent 00667b14e7
commit 81ef081a87
17 changed files with 155 additions and 186 deletions
@@ -1,6 +1,5 @@
package org.jetbrains.jet.codegen;
import com.google.common.io.ByteStreams;
import com.google.common.io.Files;
import com.intellij.openapi.util.Pair;
import org.jetbrains.jet.JetTestUtils;
@@ -15,12 +14,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Stack;
import java.util.*;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
@@ -31,7 +25,7 @@ import java.util.jar.JarOutputStream;
*
* @author Stepan Koltsov
*/
class ForTestCompileStdlib {
public class ForTestCompileStdlib {
public static final File stdlibJarForTests = new File(
JetTestUtils.tmpDirForTest(ForTestCompileStdlib.class), "stdlib.jar");
@@ -107,7 +101,7 @@ class ForTestCompileStdlib {
private static void compileKotlinPartOfStdlib(File destdir) throws IOException {
// lame
KotlinCompiler.main("-excludeStdlib", "-output", destdir.getPath(), "-src", "./stdlib/ktSrc");
KotlinCompiler.main("-output", destdir.getPath(), "-src", "./stdlib/ktSrc");
}
private static List<File> javaFilesInDir(File dir) {
@@ -37,9 +37,11 @@ public class StdlibTest extends CodegenTestCase {
protected ClassFileFactory generateClassesInFile() {
try {
CompileSession session = new CompileSession(myEnvironment);
CompileEnvironment.initializeKotlinRuntime(myEnvironment);
session.addSources(myFile.getVirtualFile());
session.addStdLibSources(true);
session.addSources(myFile.getVirtualFile());
CompileEnvironment.ensureRuntime(myEnvironment);
if (!session.analyze(System.out)) {
throw new RuntimeException();
@@ -5,7 +5,6 @@ import com.intellij.openapi.vfs.local.CoreLocalFileSystem;
import gnu.trove.THashSet;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.jetbrains.jet.compiler.CompileEnvironment;
import org.jetbrains.jet.compiler.CompileSession;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.psi.JetClass;
@@ -20,19 +19,15 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLDecoder;
import java.util.Set;
/**
* @author alex.tkachman
*/
public abstract class TestlibTestBase extends CodegenTestCase {
public class TestlibTest extends CodegenTestCase {
/** Binary or source */
private final boolean binary;
protected TestlibTestBase(boolean binary) {
this.binary = binary;
public static TestSuite suite() {
return new TestlibTest().buildSuite();
}
protected TestSuite buildSuite() {
@@ -58,12 +53,8 @@ public abstract class TestlibTestBase extends CodegenTestCase {
private TestSuite doBuildSuite() {
try {
CompileSession session = new CompileSession(myEnvironment);
if (binary) {
myEnvironment.addToClasspath(ForTestCompileStdlib.stdlibJarForTests());
} else {
CompileEnvironment.initializeKotlinRuntime(myEnvironment);
}
myEnvironment.addToClasspath(ForTestCompileStdlib.stdlibJarForTests());
File junitJar = new File("testlib/lib/junit-4.9.jar");
@@ -77,10 +68,6 @@ public abstract class TestlibTestBase extends CodegenTestCase {
VirtualFile path = localFileSystem.findFileByPath(JetParsingTest.getTestDataDir() + "/../../testlib/test");
session.addSources(path);
if (!binary) {
session.addStdLibSources(true);
}
if (!session.analyze(System.out)) {
throw new RuntimeException();
}
@@ -89,13 +76,9 @@ public abstract class TestlibTestBase extends CodegenTestCase {
URLClassLoader dependenciesClassLoader = new URLClassLoader(new URL[] { junitJar.toURI().toURL() });
GeneratedClassLoader loader;
if (binary) {
URLClassLoader parentClassLoader = new URLClassLoader(new URL[]{
ForTestCompileStdlib.stdlibJarForTests().toURI().toURL() }, dependenciesClassLoader);
loader = new GeneratedClassLoader(classFileFactory, parentClassLoader);
} else {
loader = new GeneratedClassLoader(classFileFactory, dependenciesClassLoader);
}
URLClassLoader parentClassLoader = new URLClassLoader(new URL[]{
ForTestCompileStdlib.stdlibJarForTests().toURI().toURL()}, dependenciesClassLoader);
loader = new GeneratedClassLoader(classFileFactory, parentClassLoader);
JetTypeMapper typeMapper = new JetTypeMapper(classFileFactory.state.getStandardLibrary(), session.getMyBindingContext());
TestSuite suite = new TestSuite("StandardLibrary");
@@ -1,18 +0,0 @@
package org.jetbrains.jet.codegen;
import junit.framework.TestSuite;
/**
* @author Stepan Koltsov
*/
public class TestlibWithStdlibBinaryTest extends TestlibTestBase {
protected TestlibWithStdlibBinaryTest() {
super(true);
}
public static TestSuite suite() {
return new TestlibWithStdlibBinaryTest().buildSuite();
}
}
@@ -1,18 +0,0 @@
package org.jetbrains.jet.codegen;
import junit.framework.TestSuite;
/**
* @author Stepan Koltsov
*/
public class TestlibWithStdlibSrcTest extends TestlibTestBase {
protected TestlibWithStdlibSrcTest() {
super(false);
}
public static TestSuite suite() {
return new TestlibWithStdlibSrcTest().buildSuite();
}
}