File: test.R

package info (click to toggle)
littler 0.3.22-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 848 kB
  • sloc: ansic: 586; sh: 132; makefile: 5
file content (22 lines) | stat: -rw-r--r-- 872 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Internal, not exported, function used by unit tests
test <- function(src = "cat(2 + 2)") {
    system2(r(), paste("-e", shQuote(src)), stdout = TRUE)
}


##' Return the path of the install \code{r} binary.
##'
##' The test for Windows is of course superfluous as we have no binary for Windows.
##' Maybe one day...
##' @title Return Path to \code{r} Binary
##' @param usecat Optional toggle to request output to stdout (useful in Makefiles)
##' @return The path is returned as character variable. If the \code{usecat} option is
##' set the character variable is displayed via \code{\link{cat}} instead.
##' @author Dirk Eddelbuettel
r <- function(usecat=FALSE) {
    p <- file.path(system.file(package="littler"),
                   "bin",
                   paste0("r", ifelse(.Platform$OS.type=="windows", ".exe", "")))
    if (usecat) return(cat(p)) # nocov
    p
}