Skip to content

Instantly share code, notes, and snippets.

@czeildi
Last active October 27, 2017 16:17
Show Gist options
  • Save czeildi/76cdf40afaf2aa8616e68668ab7eb1f6 to your computer and use it in GitHub Desktop.
Save czeildi/76cdf40afaf2aa8616e68668ab7eb1f6 to your computer and use it in GitHub Desktop.
CI suitable test running for R project which is not a package
# do not forget to set the executable bit on .git/hooks/pre-push
Rscript test-runner.R
suppressWarnings(source("libraries.R"))
invisible(sapply(list.files("src", full.names = TRUE), source))
has_all_tests_passed_as_expected <- testthat::test_dir("test", reporter = testthat::SilentReporter) %>%
map_lgl(~ "expectation_success" %in% class(.[["results"]][[1]])) %>%
all()
if (!has_all_tests_passed_as_expected) stop("some of the tests failed")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment