tests/test-cran/test-command.R

library(testit)

assert("Rscript() correctly calls Rscript with system2()", {
  (Rscript(c("-e", "1+1"), stdout = TRUE) %==% "[1] 2")
})

assert("Rscript_call() correctly calls Rscript()", {
  (Rscript_call(function() 1+1) %==% 2)
  loaded = Rscript_call(
    function() loadedNamespaces(), options = "--default-packages=xfun"
  )
  ("xfun" %in% loaded)
})
yihui/xfun documentation built on May 4, 2024, 5:52 p.m.