From e44776245295b2a75ec8721cc7b2e02cc8227423 Mon Sep 17 00:00:00 2001 From: Mick Jordan <mick.jordan@oracle.com> Date: Thu, 21 Aug 2014 21:33:20 -0700 Subject: [PATCH] add test for vanilla package loading and enable in gate --- .hgignore | 1 + .../rpackages/justr/vanilla/DESCRIPTION | 9 ++++ .../rpackages/justr/vanilla/NAMESPACE | 1 + .../rpackages/justr/vanilla/R/vanilla.R | 2 + .../justr/vanilla/man/vanilla-package.Rd | 31 ++++++++++++ .../rpackages/justr/vanilla/man/vanilla.Rd | 35 ++++++++++++++ .../truffle/r/test/ExpectedTestOutput.test | 10 ++++ .../r/test/rpackages/RPackagesWhiteList.test | 1 + .../r/test/rpackages/TestRPackages.java | 48 +++++++++++++++++++ mx.fastr/mx_fastr.py | 17 +++++-- 10 files changed, 151 insertions(+), 4 deletions(-) create mode 100644 com.oracle.truffle.r.test/rpackages/justr/vanilla/DESCRIPTION create mode 100644 com.oracle.truffle.r.test/rpackages/justr/vanilla/NAMESPACE create mode 100644 com.oracle.truffle.r.test/rpackages/justr/vanilla/R/vanilla.R create mode 100644 com.oracle.truffle.r.test/rpackages/justr/vanilla/man/vanilla-package.Rd create mode 100644 com.oracle.truffle.r.test/rpackages/justr/vanilla/man/vanilla.Rd create mode 100644 com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/RPackagesWhiteList.test create mode 100644 com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java diff --git a/.hgignore b/.hgignore index c845b48c74..22ff51c183 100644 --- a/.hgignore +++ b/.hgignore @@ -8,6 +8,7 @@ ^mx.fastr/eclipse-config-libs.zip ^mx.fastr/eclipse-config.zip ^mx.fastr/netbeans-config.zip +^com.oracle.truffle.r.test/rpackages/testrlibs_user ^build/ ^build-nograal/ ^dist/ diff --git a/com.oracle.truffle.r.test/rpackages/justr/vanilla/DESCRIPTION b/com.oracle.truffle.r.test/rpackages/justr/vanilla/DESCRIPTION new file mode 100644 index 0000000000..e06d3895df --- /dev/null +++ b/com.oracle.truffle.r.test/rpackages/justr/vanilla/DESCRIPTION @@ -0,0 +1,9 @@ +Package: vanilla +Type: Package +Title: Tests the package loading implementation +Version: 1.0 +Date: 2014-08-21 +Author: FastR Tester +Maintainer: FastR Tester <fastr@yahoogroups.com> +Description: Tests the package loading implementation +License: GPL-2 diff --git a/com.oracle.truffle.r.test/rpackages/justr/vanilla/NAMESPACE b/com.oracle.truffle.r.test/rpackages/justr/vanilla/NAMESPACE new file mode 100644 index 0000000000..16685286e4 --- /dev/null +++ b/com.oracle.truffle.r.test/rpackages/justr/vanilla/NAMESPACE @@ -0,0 +1 @@ +export(vanilla) diff --git a/com.oracle.truffle.r.test/rpackages/justr/vanilla/R/vanilla.R b/com.oracle.truffle.r.test/rpackages/justr/vanilla/R/vanilla.R new file mode 100644 index 0000000000..19c05192f9 --- /dev/null +++ b/com.oracle.truffle.r.test/rpackages/justr/vanilla/R/vanilla.R @@ -0,0 +1,2 @@ +vanilla <- +function() print("A vanilla R package") diff --git a/com.oracle.truffle.r.test/rpackages/justr/vanilla/man/vanilla-package.Rd b/com.oracle.truffle.r.test/rpackages/justr/vanilla/man/vanilla-package.Rd new file mode 100644 index 0000000000..6eb0934728 --- /dev/null +++ b/com.oracle.truffle.r.test/rpackages/justr/vanilla/man/vanilla-package.Rd @@ -0,0 +1,31 @@ +\name{vanilla-package} +\alias{vanilla-package} +\alias{vanilla} +\docType{package} +\title{Tests the package loading implementation} +\description{Tests the package loading implementation} +\details{ +\tabular{ll}{ +Package: \tab vanilla\cr +Type: \tab Package\cr +Version: \tab 1.0\cr +Date: \tab 2014-08-21\cr +License: \tab GPL-2\cr +} + +} +\author{ +The FastR Team + +Maintainer: fastr@yahoogroups.com +} +\references{ +} + +\keyword{ package } +\seealso{ + +} +\examples{ + +} diff --git a/com.oracle.truffle.r.test/rpackages/justr/vanilla/man/vanilla.Rd b/com.oracle.truffle.r.test/rpackages/justr/vanilla/man/vanilla.Rd new file mode 100644 index 0000000000..21eb5aea52 --- /dev/null +++ b/com.oracle.truffle.r.test/rpackages/justr/vanilla/man/vanilla.Rd @@ -0,0 +1,35 @@ +\name{vanilla} +\alias{vanilla} +%- Also NEED an '\alias' for EACH other topic documented here. +\title{ +vanilla +} +\description{ +prints A vaniila R package +} +\usage{ +vanilla() +} + +\details{ + +} +\value{ +invisble NULL +} +\references{ + +} +\author{ +FastR Team +} +\note{ + +} + +\seealso{ +% +} +\examples{ +vanilla() +} diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test index 8d0017b14f..0cd4f57a88 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test @@ -1,3 +1,13 @@ +##com.oracle.truffle.r.test.rffi.TestUserRNG.testUserRNG +#{ dyn.load("com.oracle.truffle.r.test.native/urand/lib/liburand.dylib"); RNGkind("user"); print(RNGkind()); set.seed(4567); runif(10) } +[1] "user-supplied" "Inversion" + [1] 0.45336386 0.38848030 0.94576608 0.11726267 0.21542351 0.08672997 + [7] 0.35201276 0.16919220 0.93579263 0.26084486 + +##com.oracle.truffle.r.test.rpackages.TestRPackages.testLoadVanilla +#{ library("vanilla", lib.loc = "com.oracle.truffle.r.test/rpackages/testrlibs_user"); vanilla() } +[1] "A vanilla R package" + ##com.oracle.truffle.r.test.simple.TestSimpleArithmetic.testArithmeticUpdate #{ x <- 3 ; f <- function(z) { if (z) { x <- 1 } ; x <- 1L + x ; x } ; f(FALSE) } [1] 4 diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/RPackagesWhiteList.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/RPackagesWhiteList.test new file mode 100644 index 0000000000..f81e11fa71 --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/RPackagesWhiteList.test @@ -0,0 +1 @@ +{ library("vanilla", lib.loc = "com.oracle.truffle.r.test/rpackages/testrlibs_user"); vanilla() }|Warning message:\non.exit ignored\nWarning message:\non.exit ignored\nWarning message:\non.exit ignored\nWarning message:\non.exit ignored\nWarning message:\non.exit ignored\nWarning message:\non.exit ignored\nWarning message:\non.exit ignored\nWarning message:\non.exit ignored\nWarning message:\non.exit ignored\nWarning message:\non.exit ignored\nWarning message:\non.exit ignored\nWarning message:\non.exit ignored\nWarning message:\non.exit ignored\nWarning message:\non.exit ignored\nWarning message:\non.exit ignored\nWarning message:\non.exit ignored\nWarning message:\non.exit ignored\n[1] "A vanilla R package"|[1] "A vanilla R package" diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java new file mode 100644 index 0000000000..73cdfc22fd --- /dev/null +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java @@ -0,0 +1,48 @@ +package com.oracle.truffle.r.test.rpackages; + +import java.nio.file.*; +import java.util.*; + +import org.junit.*; + +import com.oracle.truffle.r.runtime.*; +import com.oracle.truffle.r.test.*; + +/** + * Tests related to the loading, etc. of R packages. + */ +public class TestRPackages extends TestBase { + private static class ThisWhiteList extends WhiteList { + + protected ThisWhiteList() { + super("RPackagesWhiteList.test"); + } + + } + + @Test + public void testLoadVanilla() { + Path cwd = Paths.get(System.getProperty("user.dir")); + Path rpackages = Paths.get(REnvVars.rHome(), "com.oracle.truffle.r.test", "rpackages"); + Path rpackagesLibs = rpackages.resolve("testrlibs_user"); + Path relLibsPath = cwd.relativize(rpackagesLibs); + if (!relLibsPath.toFile().exists()) { + relLibsPath.toFile().mkdir(); + } + Path rpackagesDists = rpackages.resolve("distributions"); + Path vanilla = rpackagesDists.resolve("vanilla_1.0.tar.gz"); + // install the package (using GnuR for now) + ProcessBuilder pb = new ProcessBuilder("R", "CMD", "install", vanilla.toString()); + Map<String, String> env = pb.environment(); + env.put("R_LIBS_USER", rpackagesLibs.toString()); + try { + Process install = pb.start(); + int rc = install.waitFor(); + assertTrue(rc == 0); + assertTemplateEval(new ThisWhiteList(), TestBase.template("{ library(\"vanilla\", lib.loc = \"%0\"); vanilla() }", new String[]{relLibsPath.toString()})); + } catch (Exception ex) { + assertFalse(); + } + } + +} diff --git a/mx.fastr/mx_fastr.py b/mx.fastr/mx_fastr.py index a25a4bf063..e0855a0071 100644 --- a/mx.fastr/mx_fastr.py +++ b/mx.fastr/mx_fastr.py @@ -114,8 +114,8 @@ def _fastr_gate_body(args, tasks): if rc1 != 0: mx.abort('unit tests expected output check failed') tasks.append(t.stop()) - t = mx.GateTask('UnitTests: simple') - rc2 = junit(['--tests', _simple_unit_tests()]) + t = mx.GateTask('UnitTests: gate') + rc2 = junit(['--tests', _gate_unit_tests()]) if rc2 != 0: mx.abort('unit tests failed') tasks.append(t.stop()) @@ -246,11 +246,20 @@ def junit_default(args): def _simple_unit_tests(): return 'com.oracle.truffle.r.test.simple' -def _testgen_unit_tests(): +def _testrgen_unit_tests(): return 'com.oracle.truffle.r.test.testrgen' +def _rffi_unit_tests(): + return 'com.oracle.truffle.r.test.rffi' + +def _rpackages_unit_tests(): + return 'com.oracle.truffle.r.test.rpackages' + +def _gate_unit_tests(): + return _simple_unit_tests() + ',' + _rffi_unit_tests() + ',' + _rpackages_unit_tests() + def _all_unit_tests(): - return _simple_unit_tests() + ',' + _testgen_unit_tests() + return _gate_unit_tests() + ',' + _testrgen_unit_tests() def testgen(args): '''generate the expected output for unit tests, and All/Failing test classes''' -- GitLab