| 1 |
|
| 2 |
test_that("run() can be called with arguments", { |
| 3 |
|
| 4 |
project <- renv_tests_scope() |
| 5 |
dir.create("renv", recursive = TRUE, showWarnings = FALSE) |
| 6 |
writeLines("# stub", con = "renv/activate.R") |
| 7 |
|
| 8 |
output <- tempfile("renv-output-") |
| 9 |
script <- renv_test_code({ |
| 10 |
tmpfile <- tempfile(pattern = "renv-script-", tmpdir = dirname(output)) |
| 11 |
writeLines(commandArgs(trailingOnly = TRUE), con = tmpfile) |
| 12 |
file.rename(tmpfile, output) |
| 13 |
}, list(output = output)) |
| 14 |
|
| 15 |
args <- c("--apple", "--banana", "--cherry") |
| 16 |
|
| 17 |
run( |
| 18 |
script = script, |
| 19 |
args = args, |
| 20 |
project = getwd() |
| 21 |
) |
| 22 |
|
| 23 |
wait(file.exists, output) |
| 24 |
Sys.sleep(0.1) |
| 25 |
|
| 26 |
contents <- readLines(output) |
| 27 |
expect_equal(contents, args) |
| 28 |
|
| 29 |
}) |