Skip to content

Commit

Permalink
reporter coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed Jan 28, 2025
1 parent fe67fb1 commit b7f7c6d
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 0 deletions.
3 changes: 3 additions & 0 deletions R/class_crew.R
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ crew_class <- R6::R6Class(
if (is.null(result)) {
return()
}
# Tested in tests/testthat/test-crew_retries.R.
# nocov start
if (result$status == "crash") {
target <- pipeline_get_target(self$pipeline, result$name)
self$scheduler$reporter$report_retry(
Expand All @@ -239,6 +241,7 @@ crew_class <- R6::R6Class(
self$run_target(target)
return()
}
# nocov end
tar_assert_all_na(
result$error,
msg = paste("target", result$name, "error:", result$error)
Expand Down
17 changes: 17 additions & 0 deletions tests/testthat/test-class_reporter.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
tar_test("reporter abstract class", {
skip_cran()
x <- reporter_class$new()
expect_null(x$report_start())
expect_message(x$report_error("x"), class = "tar_condition_run")
expect_null(x$report_completed())
expect_null(x$report_skipped())
expect_null(x$report_errored())
expect_null(x$report_canceled())
expect_null(x$report_outdated(NULL))
expect_null(x$report_outdated_end(NULL))
expect_null(x$report_workspace(NULL))
expect_null(x$report_retry())
expect_null(x$report_finalize())
expect_null(x$flush_messages())
expect_null(x$validate())
})
11 changes: 11 additions & 0 deletions tests/testthat/test-class_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ tar_test("run summary reporter with a cancellation", {
expect_message(local$run())
})

tar_test("summary reporter retry message", {
pipeline <- pipeline_init(
list(target_init("x", quote(TRUE)))
)
local <- local_init(pipeline, reporter = "summary")
expect_message(local$run())
expect_message(
local$scheduler$reporter$report_retry(progress = local$scheduler$progress)
)
})

tar_test("validate summary reporter", {
expect_silent(reporter_init("summary")$validate())
})
12 changes: 12 additions & 0 deletions tests/testthat/test-class_timestamp.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ tar_test("run timestamp reporter with a cancellation", {
expect_message(local$run())
})

tar_test("timestamp reporter retry message", {
pipeline <- pipeline_init(list(target_init("x", quote(TRUE))))
local <- local_init(pipeline, reporter = "timestamp")
local$run()
expect_message(
local$scheduler$reporter$report_retry(
target = local$pipeline$targets$x,
progress = local$scheduler$progress
)
)
})

tar_test("validate timestamp reporter", {
expect_silent(reporter_init("timestamp")$validate())
})
12 changes: 12 additions & 0 deletions tests/testthat/test-class_verbose.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ tar_test("run verbose reporter with a warning", {
)
})

tar_test("verbose reporter retry message", {
pipeline <- pipeline_init(list(target_init("x", quote(TRUE))))
local <- local_init(pipeline, reporter = "verbose")
local$run()
expect_message(
local$scheduler$reporter$report_retry(
target = local$pipeline$targets$x,
progress = local$scheduler$progress
)
)
})

tar_test("validate verbose reporter", {
expect_silent(reporter_init("verbose")$validate())
})
11 changes: 11 additions & 0 deletions tests/testthat/test-utils_cli.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ tar_test("cli_cancel()", {
expect_message(cli_cancel("x", time_stamp = TRUE))
})

tar_test("cli_cancel()", {
skip_cran()
expect_message(cli_retry("x", time_stamp = TRUE))
expect_message(cli_retry("x", time_stamp = FALSE))
})

tar_test("cli_pipeline_uptodate()", {
skip_cran()
expect_message(cli_pipeline_uptodate(seconds_elapsed = 1))
Expand Down Expand Up @@ -58,6 +64,11 @@ tar_test("cli_blue_play()", {
expect_message(cli_blue_play("x"))
})

tar_test("cli_magenta_play()", {
skip_cran()
expect_message(cli_magenta_play("x"))
})

tar_test("cli_green_record()", {
skip_cran()
expect_message(cli_green_record("x"))
Expand Down

0 comments on commit b7f7c6d

Please sign in to comment.