Skip to content

Latest commit

 

History

History
127 lines (93 loc) · 3.07 KB

README.md

File metadata and controls

127 lines (93 loc) · 3.07 KB

sisyphus

Lifecycle: experimental

The goal of sisyphus is to rerun to allow to rerun tests every time you change a file in your R package.

Installation

You can install the development version of sisyphus like so:

pak::pak("thinkr-open/sisyphus")

Example

Run testthat::test_local every time you change a file in the R/ & tests directories:

sisyphus::sisyphus_run()

The default params to this function are:

  • check_fun: The function launched every time a file change, by default testthat::test_local()

  • delay: The check for modification is done every 1 second

  • func_files_to_watch: A fuction that return the files to watch: by default sisyphus::sisyphus_get_r_and_tests, that outputs the content of R/ & tests/

  • func_files_to_ignore: A fuction that return the files to ignore :by default sisyphus::sisyphus_get_testthat_snaps, that outputs the content of tests/testthat/_snaps, as snaps are modified every time a test is run, creating an infinite loop if ever you watch them.

You can change these settings by passing arguments to the function:

sisyphus::sisyphus_run(
  check_fun = \(){
    print(covr::package_coverage())
  },
  delay = 0.5
  ,
  fun_files_to_watch = \(){
    list.files(
      here::here(),
      recursive = TRUE,
      full.names = TRUE
    )
  }
)

To stop the check, run sisyphus::sisyphus_stop().

To change the config of the checks while the loop is running, you can use:

  • sisyphus_change_delay()
  • sisyphus_change_check_fun()
  • sisyphus_change_fun_files_to_watch()
  • sisyphus_change_fun_files_to_ignore()

Common Pitfalls

  • If not in RStudio, the printing to the console is not correct, and it looks like you don’t have a terminal again. But you do have one, press Enter to get it back.

  • If you don’t have a test infrastructure, you will get the following error:

Error in `test_dir()`:
! No test files found

Run usethis::use_testthat() to create a test infrastructure.

  • Using devtools::check will not fully print the output to the console but you’ll get the error list.

  • sisyphus::sisyphus_stop() throws an error when the asynchronous loop it uses is already destroyed.

> sisyphus::sisyphus_stop()
Error: Expecting a single value: [extent=0].

Check function suggestions

Here is a list of some functions that can be used to check:

sisyphus::sisyphus_run(
  check_fun = \() {
    withr::with_envvar(
      c("NOT_CRAN" = TRUE),{
        cli::cli_alert_info("Running covr::report()...")
        covr::report()
        cli::cat_rule("")
      }
    )
  }
)

Code of Conduct

Please note that the sisyphus project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.