tests/interactive/test-tar_script.R

tar_test("Run tar_script() interactively.", {
  expect_false(file.exists("_targets.R"))
  tar_script(x, library_targets = FALSE)
  expect_true(file.exists("_targets.R"))
  expect_equal(readLines("_targets.R"), "x")
  old_tar_ask <- Sys.getenv("TAR_ASK")
  Sys.setenv(TAR_ASK = "true")
  tar_script(y, library_targets = FALSE) # See a menu and choose 2.
  expect_equal(readLines("_targets.R"), "x")
  tar_script(y, library_targets = FALSE) # See a menu and choose 0.
  expect_equal(readLines("_targets.R"), "x")
  tar_script(y, library_targets = FALSE) # See a menu and choose 1.
  expect_equal(readLines("_targets.R"), "y")
  Sys.setenv(TAR_ASK = old_tar_ask)
})

Try the targets package in your browser

Any scripts or data that you put into this service are public.

targets documentation built on Oct. 3, 2024, 1:11 a.m.