trying to fix ReplInterpreterTest on teamcity
This commit is contained in:
@@ -32,6 +32,13 @@ public class ReplClassLoader extends ClassLoader {
|
|||||||
|
|
||||||
private Map<JvmClassName, byte[]> classes = Maps.newLinkedHashMap();
|
private Map<JvmClassName, byte[]> classes = Maps.newLinkedHashMap();
|
||||||
|
|
||||||
|
public ReplClassLoader(@NotNull ClassLoader parent) {
|
||||||
|
super(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReplClassLoader() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<?> findClass(String name) throws ClassNotFoundException {
|
protected Class<?> findClass(String name) throws ClassNotFoundException {
|
||||||
byte[] classBytes = classes.get(JvmClassName.byFqNameWithoutInnerClasses(name));
|
byte[] classBytes = classes.get(JvmClassName.byFqNameWithoutInnerClasses(name));
|
||||||
|
|||||||
@@ -58,9 +58,12 @@ import org.jetbrains.jet.plugin.JetLanguage;
|
|||||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||||
import org.jetbrains.jet.utils.Progress;
|
import org.jetbrains.jet.utils.Progress;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -73,7 +76,7 @@ public class ReplInterpreter {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private JetScope lastLineScope;
|
private JetScope lastLineScope;
|
||||||
private List<EarlierLine> earlierLines = Lists.newArrayList();
|
private List<EarlierLine> earlierLines = Lists.newArrayList();
|
||||||
private final ReplClassLoader classLoader = new ReplClassLoader();
|
private final ReplClassLoader classLoader;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final InjectorForTopDownAnalyzerForJvm injector;
|
private final InjectorForTopDownAnalyzerForJvm injector;
|
||||||
@@ -84,7 +87,8 @@ public class ReplInterpreter {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private final ModuleDescriptor module;
|
private final ModuleDescriptor module;
|
||||||
|
|
||||||
public ReplInterpreter(@NotNull Disposable disposable, @NotNull CompilerDependencies compilerDependencies) {
|
public ReplInterpreter(@NotNull Disposable disposable, @NotNull CompilerDependencies compilerDependencies, @NotNull List<File> extraClasspath) {
|
||||||
|
// TODO: add extraClasspath to jetCoreEnvironment
|
||||||
jetCoreEnvironment = new JetCoreEnvironment(disposable, compilerDependencies);
|
jetCoreEnvironment = new JetCoreEnvironment(disposable, compilerDependencies);
|
||||||
Project project = jetCoreEnvironment.getProject();
|
Project project = jetCoreEnvironment.getProject();
|
||||||
trace = new BindingTraceContext();
|
trace = new BindingTraceContext();
|
||||||
@@ -95,6 +99,21 @@ public class ReplInterpreter {
|
|||||||
true,
|
true,
|
||||||
Collections.<AnalyzerScriptParameter>emptyList());
|
Collections.<AnalyzerScriptParameter>emptyList());
|
||||||
injector = new InjectorForTopDownAnalyzerForJvm(project, topDownAnalysisParameters, trace, module, compilerDependencies);
|
injector = new InjectorForTopDownAnalyzerForJvm(project, topDownAnalysisParameters, trace, module, compilerDependencies);
|
||||||
|
|
||||||
|
if (extraClasspath.size() > 0) {
|
||||||
|
URL[] urls = new URL[extraClasspath.size()];
|
||||||
|
for (int i = 0; i < extraClasspath.size(); ++i) {
|
||||||
|
try {
|
||||||
|
urls[i] = extraClasspath.get(i).toURI().toURL();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw ExceptionUtils.rethrow(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
classLoader = new ReplClassLoader(new URLClassLoader(urls));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
classLoader = new ReplClassLoader();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object eval(@NotNull String line) {
|
public Object eval(@NotNull String line) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.junit.Assert;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stepan Koltsov
|
* @author Stepan Koltsov
|
||||||
@@ -52,7 +53,7 @@ public class ReplInterpreterTest {
|
|||||||
|
|
||||||
private void testFile(@NotNull String relativePath) {
|
private void testFile(@NotNull String relativePath) {
|
||||||
CompilerDependencies compilerDependencies = CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.JDK_HEADERS, false);
|
CompilerDependencies compilerDependencies = CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.JDK_HEADERS, false);
|
||||||
ReplInterpreter repl = new ReplInterpreter(disposable, compilerDependencies);
|
ReplInterpreter repl = new ReplInterpreter(disposable, compilerDependencies, Collections.singletonList(new File("out/production/runtime")));
|
||||||
|
|
||||||
ReplSessionTestFile file = ReplSessionTestFile.load(new File("compiler/testData/repl/" + relativePath));
|
ReplSessionTestFile file = ReplSessionTestFile.load(new File("compiler/testData/repl/" + relativePath));
|
||||||
for (Pair<String, String> t : file.getLines()) {
|
for (Pair<String, String> t : file.getLines()) {
|
||||||
@@ -76,7 +77,6 @@ public class ReplInterpreterTest {
|
|||||||
testFile("simple.repl");
|
testFile("simple.repl");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@Test
|
@Test
|
||||||
public void function() {
|
public void function() {
|
||||||
testFile("function.repl");
|
testFile("function.repl");
|
||||||
@@ -86,7 +86,6 @@ public class ReplInterpreterTest {
|
|||||||
public void functionReferencesPrev() {
|
public void functionReferencesPrev() {
|
||||||
testFile("functionReferencesPrev.repl");
|
testFile("functionReferencesPrev.repl");
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user