Skip to content

Commit b7f7c6d

Browse files
committed
reporter coverage
1 parent fe67fb1 commit b7f7c6d

File tree

6 files changed

+66
-0
lines changed

6 files changed

+66
-0
lines changed

R/class_crew.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ crew_class <- R6::R6Class(
230230
if (is.null(result)) {
231231
return()
232232
}
233+
# Tested in tests/testthat/test-crew_retries.R.
234+
# nocov start
233235
if (result$status == "crash") {
234236
target <- pipeline_get_target(self$pipeline, result$name)
235237
self$scheduler$reporter$report_retry(
@@ -239,6 +241,7 @@ crew_class <- R6::R6Class(
239241
self$run_target(target)
240242
return()
241243
}
244+
# nocov end
242245
tar_assert_all_na(
243246
result$error,
244247
msg = paste("target", result$name, "error:", result$error)

tests/testthat/test-class_reporter.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
tar_test("reporter abstract class", {
2+
skip_cran()
3+
x <- reporter_class$new()
4+
expect_null(x$report_start())
5+
expect_message(x$report_error("x"), class = "tar_condition_run")
6+
expect_null(x$report_completed())
7+
expect_null(x$report_skipped())
8+
expect_null(x$report_errored())
9+
expect_null(x$report_canceled())
10+
expect_null(x$report_outdated(NULL))
11+
expect_null(x$report_outdated_end(NULL))
12+
expect_null(x$report_workspace(NULL))
13+
expect_null(x$report_retry())
14+
expect_null(x$report_finalize())
15+
expect_null(x$flush_messages())
16+
expect_null(x$validate())
17+
})

tests/testthat/test-class_summary.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ tar_test("run summary reporter with a cancellation", {
2020
expect_message(local$run())
2121
})
2222

23+
tar_test("summary reporter retry message", {
24+
pipeline <- pipeline_init(
25+
list(target_init("x", quote(TRUE)))
26+
)
27+
local <- local_init(pipeline, reporter = "summary")
28+
expect_message(local$run())
29+
expect_message(
30+
local$scheduler$reporter$report_retry(progress = local$scheduler$progress)
31+
)
32+
})
33+
2334
tar_test("validate summary reporter", {
2435
expect_silent(reporter_init("summary")$validate())
2536
})

tests/testthat/test-class_timestamp.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ tar_test("run timestamp reporter with a cancellation", {
3333
expect_message(local$run())
3434
})
3535

36+
tar_test("timestamp reporter retry message", {
37+
pipeline <- pipeline_init(list(target_init("x", quote(TRUE))))
38+
local <- local_init(pipeline, reporter = "timestamp")
39+
local$run()
40+
expect_message(
41+
local$scheduler$reporter$report_retry(
42+
target = local$pipeline$targets$x,
43+
progress = local$scheduler$progress
44+
)
45+
)
46+
})
47+
3648
tar_test("validate timestamp reporter", {
3749
expect_silent(reporter_init("timestamp")$validate())
3850
})

tests/testthat/test-class_verbose.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ tar_test("run verbose reporter with a warning", {
2525
)
2626
})
2727

28+
tar_test("verbose reporter retry message", {
29+
pipeline <- pipeline_init(list(target_init("x", quote(TRUE))))
30+
local <- local_init(pipeline, reporter = "verbose")
31+
local$run()
32+
expect_message(
33+
local$scheduler$reporter$report_retry(
34+
target = local$pipeline$targets$x,
35+
progress = local$scheduler$progress
36+
)
37+
)
38+
})
39+
2840
tar_test("validate verbose reporter", {
2941
expect_silent(reporter_init("verbose")$validate())
3042
})

tests/testthat/test-utils_cli.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ tar_test("cli_cancel()", {
2323
expect_message(cli_cancel("x", time_stamp = TRUE))
2424
})
2525

26+
tar_test("cli_cancel()", {
27+
skip_cran()
28+
expect_message(cli_retry("x", time_stamp = TRUE))
29+
expect_message(cli_retry("x", time_stamp = FALSE))
30+
})
31+
2632
tar_test("cli_pipeline_uptodate()", {
2733
skip_cran()
2834
expect_message(cli_pipeline_uptodate(seconds_elapsed = 1))
@@ -58,6 +64,11 @@ tar_test("cli_blue_play()", {
5864
expect_message(cli_blue_play("x"))
5965
})
6066

67+
tar_test("cli_magenta_play()", {
68+
skip_cran()
69+
expect_message(cli_magenta_play("x"))
70+
})
71+
6172
tar_test("cli_green_record()", {
6273
skip_cran()
6374
expect_message(cli_green_record("x"))

0 commit comments

Comments
 (0)