Skip to content
Snippets Groups Projects
Commit a287b7ef authored by Mick Jordan's avatar Mick Jordan
Browse files

sync mx_fastr.rtestgen up with FASTR_TESTGEN_GNUR option; allow latter to specify a specific R home

parent ad683ca4
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,7 @@ public class RVersionNumber {
public static final String MAJOR_MINOR = MAJOR + "." + MINOR;
public static final String MINOR_PATCH = MINOR + "." + PATCH;
public static final String FULL = MAJOR + "." + MINOR + "." + PATCH;
public static final String R_HYPHEN_FULL = "R-" + FULL;
public static final String RELEASE_YEAR = "2016";
public static final String RELEASE_MONTH = "03";
......
......@@ -38,13 +38,14 @@ import com.oracle.truffle.r.test.TestBase;
* currently some differences in behavior (TBD). Which R is used is controlled by the environment
* variable {@code FASTR_TESTGEN_GNUR}. If unset, we take the default, which is currently the system
* installed version (more precisely whatever "R" resolves to on the PATH). If
* {@code FASTR_TESTGEN_GNUR} is set to {@code internal}, we use the internally built GnuR. Any
* other value behaves as if it was unset. {@code PATH}.
* {@code FASTR_TESTGEN_GNUR} is set to {@code internal} or the empty string, we use the internally
* built GnuR. Any other value is treated as a path to a directory assumed to contain an R HOME, i.e
* the executable used is {@code $FASTR_TESTGEN_GNUR/bin/R}.
*/
public class GnuROneShotRSession implements RSession {
private static final String[] GNUR_COMMANDLINE = new String[]{"R", "--vanilla", "--slave", "--silent"};
private static final String SYSTEM_GNUR_ENV = "FASTR_TESTGEN_GNUR";
private static final String FASTR_TESTGEN_GNUR = "FASTR_TESTGEN_GNUR";
private static final String NATIVE_PROJECT = "com.oracle.truffle.r.native";
//@formatter:off
......@@ -61,10 +62,15 @@ public class GnuROneShotRSession implements RSession {
protected static byte[] QUIT = "q()\n".getBytes();
protected Process createGnuR() throws IOException {
String testGenGnuR = System.getenv(SYSTEM_GNUR_ENV);
if (testGenGnuR != null && testGenGnuR.equals("internal")) {
Path gnuRPath = FileSystems.getDefault().getPath(REnvVars.rHome(), NATIVE_PROJECT, "gnur", "R-" + RVersionNumber.FULL, "bin", "R");
GNUR_COMMANDLINE[0] = gnuRPath.toString();
String testGenGnuR = System.getenv(FASTR_TESTGEN_GNUR);
if (testGenGnuR != null) {
if (testGenGnuR.length() == 0 || testGenGnuR.equals("internal")) {
Path gnuRPath = FileSystems.getDefault().getPath(REnvVars.rHome(), NATIVE_PROJECT, "gnur", RVersionNumber.R_HYPHEN_FULL, "bin", "R");
GNUR_COMMANDLINE[0] = gnuRPath.toString();
} else {
GNUR_COMMANDLINE[0] = FileSystems.getDefault().getPath(testGenGnuR, "bin", "R").toString();
}
}
ProcessBuilder pb = new ProcessBuilder(GNUR_COMMANDLINE);
// fix time zone to "CET" (to create consistent expected output)
......@@ -114,4 +120,9 @@ public class GnuROneShotRSession implements RSession {
public String name() {
return "GnuR one-shot";
}
public static void main(String[] args) {
String testGenGnuR = System.getenv(FASTR_TESTGEN_GNUR);
System.out.printf("%s='%s'%n", FASTR_TESTGEN_GNUR, testGenGnuR);
}
}
......@@ -436,14 +436,31 @@ def testgen(args):
# check we are in the home directory
if os.getcwd() != _fastr_suite.dir:
mx.abort('must run rtestgen from FastR home directory')
# check the version of GnuR against FastR
try:
fastr_version = subprocess.check_output([mx.get_jdk().java, '-cp', mx.classpath('com.oracle.truffle.r.runtime'), 'com.oracle.truffle.r.runtime.RVersionNumber'])
gnur_version = subprocess.check_output(['R', '--version'])
if not gnur_version.startswith(fastr_version):
mx.abort('R version is incompatible with FastR, please update to ' + fastr_version)
except subprocess.CalledProcessError:
mx.abort('RVersionNumber.main failed')
def need_version_check():
vardef = os.environ.has_key('FASTR_TESTGEN_GNUR')
varval = os.environ['FASTR_TESTGEN_GNUR'] if vardef else None
version_check = not vardef or varval != 'internal'
if version_check:
if vardef and varval != 'internal':
rpath = join(varval, 'bin', 'R')
else:
rpath = 'R'
else:
rpath = None
return version_check, rpath
version_check, rpath = need_version_check()
if version_check:
# check the version of GnuR against FastR
try:
fastr_version = subprocess.check_output([mx.get_jdk().java, '-cp', mx.classpath('com.oracle.truffle.r.runtime'), 'com.oracle.truffle.r.runtime.RVersionNumber'])
gnur_version = subprocess.check_output([rpath, '--version'])
if not gnur_version.startswith(fastr_version):
mx.abort('R version is incompatible with FastR, please update to ' + fastr_version)
except subprocess.CalledProcessError:
mx.abort('RVersionNumber.main failed')
# clean the test project to invoke the test analyzer AP
testOnly = ['--projects', 'com.oracle.truffle.r.test']
mx.clean(['--no-dist', ] + testOnly)
......
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