Skip to content
Merged
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: checked
Title: Systematically Run R CMD Checks
Version: 0.5.2
Version: 0.5.2.9000
Authors@R:
c(
person(
Expand Down
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# checked (development)

* Make is possible to construct reporter environments with additional values
to better control their behavior.

* Add `checks_only` parameter to `reporter_basic_tty` which if set to TRUE
will make the reporter broadcast only check tasks instead of both
install and check.

# checked 0.5.2

* Add timers striping to `strip_details_from_issue()` to avoid false-positives.
Expand Down
24 changes: 16 additions & 8 deletions R/reporter.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,39 @@
#' A line-feed reporter presenting output one line at a time, providing
#' a reporter with minimal assumptions about terminal capabilities.
#'
#' @param checks_only whether basic tty reporter should report only check tasks.
#' @param ... additional values which should be assigned to the reported
#' environment.
#'
#' @family reporters
#' @name reporters
NULL

reporter <- function(type) {
reporter <- function(type, ...) {
type <- paste0("reporter_", type)
structure(new.env(parent = baseenv()), class = c(type, "reporter"))
reporter_options <- list(...)
structure(
list2env(reporter_options, parent = baseenv(), hash = TRUE),
class = c(type, "reporter")
)
}

#' @rdname reporters
#' @export
reporter_ansi_tty <- function() {
reporter("ansi_tty")
reporter_ansi_tty <- function(...) {
reporter("ansi_tty", ...)
}

#' @rdname reporters
#' @export
reporter_ansi_tty2 <- function() {
reporter("ansi_tty2")
reporter_ansi_tty2 <- function(...) {
reporter("ansi_tty2", ...)
}

#' @rdname reporters
#' @export
reporter_basic_tty <- function() {
reporter("basic_tty")
reporter_basic_tty <- function(checks_only = FALSE, ...) {
reporter("basic_tty", checks_only = checks_only, ...)
}

#' @rdname reporters
Expand Down
23 changes: 19 additions & 4 deletions R/reporter_basic_tty.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ report_start_setup.reporter_basic_tty <- function(
) {
# start with all tasks initialized as pending
v <- igraph::V(checker$graph)
v_actionable <- v[is_actionable_task(v$task)]
v_reportable <- if (reporter$checks_only) {
v[is_check(v$task)]
} else {
v[is_actionable_task(v$task)]
}

# named factor vector, names as task aliases and value of last reported status
reporter$status <- rep(STATUS$pending, times = length(v_actionable))
names(reporter$status) <- v_actionable$name
reporter$status <- rep(STATUS$pending, times = length(v_reportable))
names(reporter$status) <- v_reportable$name

reporter$time_start <- Sys.time()

Expand Down Expand Up @@ -44,8 +48,17 @@ report_status.reporter_basic_tty <- function(reporter, checker, envir) {
"pending" = "queued",
"in progress" = cli::cli_fmt(cli::cli_text("started")),
"done" = {
pkgs_done <- reporter$status == STATUS$done # nolint
# +1 to acount for the task that is currently processed
fmt_count <-
cli::col_grey(" [{sum(pkgs_done)+1}/{length(pkgs_done)}]")

if (is.null(p)) {
cli::cli_fmt(cli::cli_text("finished (restored)"))
cli::cli_fmt(
cli::cli_text(
"finished", cli::format_inline(fmt_count), " (restored)"
)
)
} else if (p$get_r_exit_status() != 0) {
# checks processes don't have logs associated with it
message <- if (!is.null(p$log)) {
Expand All @@ -70,6 +83,7 @@ report_status.reporter_basic_tty <- function(reporter, checker, envir) {
fmt_warning <- "{.warn {ewn[[2]]} WARNING{?/S}}"
fmt_note <- "{.note {ewn[[3]]} NOTE{?/S}}"
fmt_duration <- " {.time_taken ({format_time(dur)})}"

cli::cli_fmt(cli::cli_text(
"finished",
if (sum(ewn) > 0) " with ",
Expand All @@ -78,6 +92,7 @@ report_status.reporter_basic_tty <- function(reporter, checker, envir) {
if (ewn[[2]] > 0) cli::format_inline(fmt_warning),
if (ewn[[3]] > 0) cli::format_inline(fmt_note)
)),
cli::format_inline(fmt_count),
if (!is.null(dur)) cli::format_inline(fmt_duration)
))
}
Expand Down
12 changes: 9 additions & 3 deletions man/reporters.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions tests/testthat/_snaps/reporters.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
Message
<checked> Checks
[][install] rev.both.dependency started
[][install] rev.both.dependency finished ()
[][install] rev.both.dependency finished [1/7] ()
[][install] pkg.ok.error started
[][install] pkg.ok.error finished ()
[][install] pkg.ok.error finished [2/7] ()
[][install] pkg.ok.error started
[][check] rev.both.ok started
[][install] pkg.ok.error finished ()
[][check] rev.both.ok finished with 1 NOTE ()
[][install] pkg.ok.error finished [3/7] ()
[][check] rev.both.ok finished with 1 NOTE [4/7] ()
[][check] rev.both.error started
[][check] rev.both.error finished with 1 NOTE ()
[][check] rev.both.error finished with 1 NOTE [5/7] ()
[][check] rev.both.ok started
[][check] rev.both.ok finished with 1 NOTE ()
[][check] rev.both.ok finished with 1 NOTE [6/7] ()
[][check] rev.both.error started
[][check] rev.both.error finished with 1 ERROR, 1 WARNING ()
[][check] rev.both.error finished with 1 ERROR, 1 WARNING [7/7] ()
Finished in

Loading