Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teardown files for test_dir #158

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion R/test-files.r
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ test_env <- function() {
#'
#' Test files start with \code{test} and are executed in alphabetical order
#' (but they shouldn't have dependencies). Helper files start with
#' \code{helper} and loaded before any tests are run.
#' \code{helper} and loaded before any tests are run. Teardown files
#' start with \code{teardown} and are loaded and run after the tests.
#'
#' @param path path to tests
#' @param reporter reporter to use
Expand All @@ -32,6 +33,7 @@ test_dir <- function(path, filter = NULL, reporter = "summary",
reporter <- MultiReporter$new(reporters = list(current_reporter, lister))

source_dir(path, "^helper.*\\.[rR]$", env = env)
on.exit(source_dir(path, "^teardown.*\\.[rR]$", env = env), add = TRUE)

files <- dir(path, "^test.*\\.[rR]$")
if (!is.null(filter)) {
Expand Down
3 changes: 2 additions & 1 deletion man/test_dir.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ a data frame of the summary of test results
\description{
Test files start with \code{test} and are executed in alphabetical order
(but they shouldn't have dependencies). Helper files start with
\code{helper} and loaded before any tests are run.
\code{helper} and loaded before any tests are run. Teardown files
start with \code{teardown} and are loaded and run after the tests.
}