Skip to content
Snippets Groups Projects
Commit 5778f656 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

run node tests in the right context

parent e80b4f6d
Branches
No related tags found
No related merge requests found
......@@ -30,15 +30,18 @@ import org.junit.BeforeClass;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.vm.PolyglotEngine;
import com.oracle.truffle.r.engine.TruffleRLanguage;
import com.oracle.truffle.r.runtime.context.RContext;
import com.oracle.truffle.r.test.generate.FastRSession;
public class TestBase {
private static PolyglotEngine testVM;
static RContext testVMContext;
@BeforeClass
public static void setupClass() {
public static void setupClass() throws IOException {
testVM = FastRSession.create().createTestContext(null);
testVMContext = testVM.eval(FastRSession.GET_CONTEXT).as(RContext.class);
}
// clear out warnings (which are stored in shared base env)
......
......@@ -22,12 +22,27 @@
*/
package com.oracle.truffle.r.nodes.test;
import com.oracle.truffle.api.*;
import com.oracle.truffle.api.frame.*;
import com.oracle.truffle.api.nodes.*;
import com.oracle.truffle.r.runtime.*;
import com.oracle.truffle.r.runtime.data.*;
import com.oracle.truffle.r.runtime.data.model.*;
import java.io.Closeable;
import java.io.IOException;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.RootCallTarget;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.TruffleLanguage;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.r.runtime.RArguments;
import com.oracle.truffle.r.runtime.RRuntime;
import com.oracle.truffle.r.runtime.RType;
import com.oracle.truffle.r.runtime.ReturnException;
import com.oracle.truffle.r.runtime.context.RContext;
import com.oracle.truffle.r.runtime.data.RComplex;
import com.oracle.truffle.r.runtime.data.RDataFactory;
import com.oracle.truffle.r.runtime.data.RNull;
import com.oracle.truffle.r.runtime.data.model.RAbstractDoubleVector;
import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector;
import com.oracle.truffle.r.runtime.data.model.RAbstractVector;
public class TestUtilities {
......@@ -168,7 +183,12 @@ public class TestUtilities {
}
public Object call(Object... args) {
return target.call(RArguments.createUnitialized((Object) args));
try (Closeable c = RContext.withinContext(TestBase.testVMContext)) {
return target.call(RArguments.createUnitialized((Object) args));
} catch (IOException e) {
CompilerDirectives.transferToInterpreter();
throw new RuntimeException(e);
}
}
}
......
......@@ -140,7 +140,7 @@ public final class FastRSession implements RSession {
return singleton;
}
private static final Source GET_CONTEXT = Source.fromText("invisible(.fastr.context.get())", "<get_context>").withMimeType(TruffleRLanguage.MIME);
public static final Source GET_CONTEXT = Source.fromText("invisible(.fastr.context.get())", "<get_context>").withMimeType(TruffleRLanguage.MIME);
public PolyglotEngine createTestContext(ContextInfo contextInfoArg) {
create();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment