tests/testthat/test-tar_path_script_support.R

tar_test("tar_path_script() outside a pipeline", {
  script <- tar_config_get("script")
  expect_equal(
    tar_path_script_support(),
    paste0(tools::file_path_sans_ext(script), "_r")
  )
  tar_config_set(script = "example_script")
  expect_equal(tar_path_script_support(), "example_script_r")
})

# nolint start
tar_test("tar_path_script() inside a pipeline", {
  skip_cran()
  script <- "example_script"
  tar_script(tar_target(
    x,
    tar_path_script_support()),
    script = script,
    ask = FALSE
  )
  tar_make(script = script, callr_function = NULL)
  expect_equal(tar_read(x), "example_script_r")
})
# nolint end

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.