From 3ce3c3ac3634848297d7f7ccb8de9293065e64fc Mon Sep 17 00:00:00 2001
From: Florian Angerer <florian.angerer@oracle.com>
Date: Fri, 23 Feb 2018 15:38:25 +0100
Subject: [PATCH] Read global mx args for package testing from file
 'test.mx.args'.

---
 .../r/install.packages.R                      | 20 ++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/com.oracle.truffle.r.test.packages/r/install.packages.R b/com.oracle.truffle.r.test.packages/r/install.packages.R
index cf3901e4d8..521ac7415d 100644
--- a/com.oracle.truffle.r.test.packages/r/install.packages.R
+++ b/com.oracle.truffle.r.test.packages/r/install.packages.R
@@ -164,6 +164,19 @@ choice.depends <- function(pkg, choice=c("direct","suggests")) {
 	unname(all.deps)
 }
 
+# provides JVM args when running the tests
+fastr.test.jvm.args <- function() {
+    mx.args.file <- "com.oracle.truffle.r.test.packages/test.mx.args"
+    tryCatch({
+        if (file.exists(mx.args.file)) {
+            opts <- paste0('"', paste0("--Ja @", readLines(mx.args.file), collapse=" "), '"')
+            log.message(paste0("MX_R_GLOBAL_ARGS=", opts), level=1)
+            return (opts)
+	    }
+    })
+    return ("'--Ja @-DR:+IgnoreGraphicsCalls'")
+}
+
 # returns a vector of package names that are the direct dependents of pkg
 direct.depends <- function(pkg) {
 	choice.depends(pkg, "direct")
@@ -837,7 +850,12 @@ system.test <- function(pkgname) {
 	# we want to stop tests that hang, but some packages have many tests
 	# each of which spawns a sub-process (over which we have no control)
 	# so we time out the entire set after 20 minutes.
-	rc <- system2(rscript, args, env=c("FASTR_PROCESS_TIMEOUT=20", paste0("R_LIBS_USER=",shQuote(lib.install)),"R_LIBS="))
+    env <- c("FASTR_PROCESS_TIMEOUT=20", 
+             paste0("R_LIBS_USER=", shQuote(lib.install)),
+             "R_LIBS=",
+             paste0("MX_R_GLOBAL_ARGS=", fastr.test.jvm.args())
+            )
+	rc <- system2(rscript, args, env=env)
 	rc
 }
 
-- 
GitLab