Skip to content

Commit a8bb8c8

Browse files
committed
Correctly transfer 'install.fastr.packages' from FastR to GnuR.
1 parent 9cf2e56 commit a8bb8c8

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

com.oracle.truffle.r.test.packages/pkgtest/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ def _installpkgs_script():
9595
return join(packages_test, 'r', 'install.packages.R')
9696

9797

98+
def commit_fastr_builtins():
99+
'''
100+
There are some FastR builtins which we also want to use in GnuR (i.e. 'install.fastr.packages').
101+
This function deparses these functions and writes them into a file which is then loaded by GnuR.
102+
'''
103+
dest_file = join(_packages_test_project_dir(), 'r', 'fastr.functions.rdx')
104+
cmd_line = [get_fastr_rscript(), "--silent", "-e", '{ fastrRepoPath <- NULL; save(fastrRepoPath, install.fastr.packages, file="%s") }' % dest_file]
105+
logging.debug("Generating fastr.functions.R: " + str(cmd_line))
106+
return pkgtest_run(cmd_line)
107+
108+
98109
def _installpkgs(args, **kwargs):
99110
'''
100111
Runs the R script that does package/installation and testing.
@@ -164,6 +175,9 @@ def pkgtest(args):
164175
env['FASTR_OPTION_PrintErrorStacktracesToFile'] = 'false'
165176
env['FASTR_OPTION_PrintErrorStacktraces'] = 'true'
166177

178+
# transfer required FastR functions to GnuR
179+
commit_fastr_builtins()
180+
167181
# If '--cache-pkgs' is set, then also set the native API version value
168182
_set_pkg_cache_api_version(install_args, get_fastr_include_path())
169183

com.oracle.truffle.r.test.packages/r/install.cache.R

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -712,12 +712,6 @@ transitive.dependencies <- function(pkg, lib, pl = as.data.frame(available.packa
712712

713713
pkg.cache.in.overrides <- function(pkgname) pkgname %in% (if(is.fastr()) overrides$fastr else overrides$gnur)
714714

715-
716-
# TODO: currently just a workaround for GnuR; we should use same code as in FastR
717-
if (!exists("install.fastr.packages")) {
718-
install.fastr.packages <<- install.packages
719-
}
720-
721715
# Fetches the package from the cache or installs it. This is also done for all transitive dependencies.
722716
pkg.cache.internal.install <- function(pkg.cache.env, pkgname, contriburl, lib.install) {
723717
tryCatch({
@@ -778,3 +772,4 @@ pkg.cache.internal.install <- function(pkg.cache.env, pkgname, contriburl, lib.i
778772
return (1L)
779773
})
780774
}
775+

com.oracle.truffle.r.test.packages/r/install.packages.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,15 @@ run <- function() {
12581258
curScriptDir <- getCurrentScriptDir()
12591259
if (!is.null(curScriptDir)) {
12601260
source(file.path(curScriptDir, "install.cache.R"))
1261+
if (!is.fastr()) {
1262+
fastr.functions.path <- file.path(curScriptDir, "fastr.functions.rdx")
1263+
if (file.exists(fastr.functions.path)) {
1264+
loaded.names <- load(fastr.functions.path)
1265+
log.message("Loaded names: ", loaded.names)
1266+
} else {
1267+
log.message("Warning: Running with GnuR but could not find file '", fastr.functions.path, "'")
1268+
}
1269+
}
12611270
} else {
12621271
log.message("Cannot use package cache since script directory cannot be determined")
12631272

0 commit comments

Comments
 (0)