Skip to content
Snippets Groups Projects
Commit 27e74309 authored by stepan's avatar stepan
Browse files

New FastR option `AdditionalOptions`, which allows to set default values for R level options

Used in pkg testing to set 'vdiffr_skip' so that vdiffr tests (visual diff for testthat) are skipped.
parent 2708809e
No related branches found
No related tags found
No related merge requests found
......@@ -74,6 +74,8 @@ public enum FastROptions {
// Miscellaneous
IgnoreGraphicsCalls("Silently ignore unimplemented functions from graphics package", false),
AdditionalOptions("List of R level options default values. Syntax: 'optionName:value;optionName2:value;'. " +
"Value can be 'T' or 'F' in which case it is interpreted as boolean, otherwise as string", "", true),
StartupTiming("Records and prints various timestamps during initialization", false);
private final String help;
......
......@@ -18,8 +18,11 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.graalvm.nativeimage.ObjectHandle;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.r.launcher.RStartParams;
import com.oracle.truffle.r.runtime.RError.Message;
import com.oracle.truffle.r.runtime.context.RContext;
import com.oracle.truffle.r.runtime.context.RContext.ContextKind;
import com.oracle.truffle.r.runtime.data.RDataFactory;
......@@ -180,6 +183,27 @@ public class ROptions {
if (cranMirror != null) {
map.put("repos", cranMirror);
}
String additional = FastROptions.AdditionalOptions.getStringValue();
if (additional == null || additional.isEmpty()) {
return;
}
String[] namesValues = additional.trim().split(";");
for (int i = 0; i < namesValues.length; i++) {
String[] items = namesValues[i].trim().split(":");
if (items.length != 2) {
RError.warning(RError.NO_CALLER, Message.GENERIC, "Invalid value of AdditionalOptions option: " + namesValues[i]);
continue;
}
Object value = items[1].trim();
if (items[1].equals("T")) {
value = RRuntime.LOGICAL_TRUE;
} else if (items[1].equals("F")) {
value = RRuntime.LOGICAL_FALSE;
}
map.put(items[0], value);
}
}
private static boolean optionFromEnvVar(String envVar, REnvVars envVars) {
......
-DR:+IgnoreGraphicsCalls
-DR:-EmitTmpSource
-DR:AdditionalOptions=vdiffr_skip:T
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment