tests/testthat/test-setpwd.R

library(rconf)
library(testthat)
context("setpwd")

rscript <- system.file("extdata", "somescript.R", package="rconf")
Rscript <- system("which Rscript", intern=TRUE)

test_that("test setpwd in an rscript", {
  expect_equal(system2(Rscript, rscript, stdout=TRUE)[2], getwd())
  expect_equal(system2(Rscript, rscript, stdout=TRUE)[4], dirname(rscript))
  expect_equal(system2(Rscript, rscript, stdout=TRUE)[6], getwd())
  expect_equal(system2(Rscript, rscript, stdout=TRUE)[8], dirname(rscript))
})
obarisk/rconf documentation built on May 3, 2019, 9:01 p.m.