From b138bf7f85a3c7728a536436f12ad182f6e6480b Mon Sep 17 00:00:00 2001 From: Maximilian Girlich Date: Mon, 25 Sep 2023 16:19:09 +0200 Subject: [PATCH] Make skip column 2 chars wide (#1845) --- NEWS.md | 3 + R/reporter-progress.R | 15 ++- tests/testthat/_snaps/reporter-progress.md | 114 ++++++++++----------- 3 files changed, 72 insertions(+), 60 deletions(-) diff --git a/NEWS.md b/NEWS.md index cf50ee1b4..f54cd737f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # testthat (development version) +* The skip column is now two characters wide to have a consistent width in case + 10 or more tests are skipped in a single file (@mgirlich, #1844). + * `skip_if_offline()` now errors if you don't have curl installed (#1854). * All packages, regardless of whether or not they use rlang 1.0.0, now diff --git a/R/reporter-progress.R b/R/reporter-progress.R index 4977247ce..33e01818b 100644 --- a/R/reporter-progress.R +++ b/R/reporter-progress.R @@ -103,7 +103,7 @@ ProgressReporter <- R6::R6Class("ProgressReporter", colourise(cli::symbol$tick, "success"), " | ", colourise("F", "failure"), " ", colourise("W", "warning"), " ", - colourise("S", "skip"), " ", + colourise(" S", "skip"), " ", colourise(" OK", "success"), " | ", "Context" ) @@ -143,9 +143,18 @@ ProgressReporter <- R6::R6Class("ProgressReporter", col_format <- function(n, type) { if (n == 0) { - " " + if (type == "skip") { + " " + } else { + " " + } } else { - colourise(n, type) + if (type == "skip") { + colourise(sprintf("%2d", n), type) + } else { + colourise(n, type) + } + } } diff --git a/tests/testthat/_snaps/reporter-progress.md b/tests/testthat/_snaps/reporter-progress.md index 228ae01b8..ebbad779a 100644 --- a/tests/testthat/_snaps/reporter-progress.md +++ b/tests/testthat/_snaps/reporter-progress.md @@ -1,10 +1,10 @@ # captures error before first test - v | F W S OK | Context + v | F W S OK | Context - / | 0 | reporters/error-setup - - | 1 0 | reporters/error-setup - x | 1 0 | reporters/error-setup + / | 0 | reporters/error-setup + - | 1 0 | reporters/error-setup + x | 1 0 | reporters/error-setup -------------------------------------------------------------------------------- Error ('reporters/error-setup.R:3:6'): (code run outside of `test_that()`) Error in `h()`: ! @@ -35,12 +35,12 @@ # gracefully handles multiple contexts - v | F W S OK | Context + v | F W S OK | Context - / | 0 | reporters/context - / | 0 | my context - - | 1 | my context - v | 1 | my context + / | 0 | reporters/context + / | 0 | my context + - | 1 | my context + v | 1 | my context == Results ===================================================================== [ FAIL 0 | WARN 0 | SKIP 0 | PASS 1 ] @@ -49,21 +49,21 @@ # fails after max_fail tests - v | F W S OK | Context - - / | 0 | reporters/fail-many - - | 1 0 | reporters/fail-many - \ | 2 0 | reporters/fail-many - | | 3 0 | reporters/fail-many - / | 4 0 | reporters/fail-many - - | 5 0 | reporters/fail-many - \ | 6 0 | reporters/fail-many - | | 7 0 | reporters/fail-many - / | 8 0 | reporters/fail-many - - | 9 0 | reporters/fail-many - \ | 10 0 | reporters/fail-many - | | 11 0 | reporters/fail-many - x | 11 0 | reporters/fail-many + v | F W S OK | Context + + / | 0 | reporters/fail-many + - | 1 0 | reporters/fail-many + \ | 2 0 | reporters/fail-many + | | 3 0 | reporters/fail-many + / | 4 0 | reporters/fail-many + - | 5 0 | reporters/fail-many + \ | 6 0 | reporters/fail-many + | | 7 0 | reporters/fail-many + / | 8 0 | reporters/fail-many + - | 9 0 | reporters/fail-many + \ | 10 0 | reporters/fail-many + | | 11 0 | reporters/fail-many + x | 11 0 | reporters/fail-many -------------------------------------------------------------------------------- Failure ('reporters/fail-many.R:3:5'): Example FALSE is not TRUE @@ -209,17 +209,17 @@ # can fully suppress incremental updates - v | F W S OK | Context - - / | 0 | reporters/successes - - | 1 | reporters/successes - \ | 2 | reporters/successes - | | 3 | reporters/successes - / | 4 | reporters/successes - - | 5 | reporters/successes - \ | 6 | reporters/successes - | | 7 | reporters/successes - v | 7 | reporters/successes + v | F W S OK | Context + + / | 0 | reporters/successes + - | 1 | reporters/successes + \ | 2 | reporters/successes + | | 3 | reporters/successes + / | 4 | reporters/successes + - | 5 | reporters/successes + \ | 6 | reporters/successes + | | 7 | reporters/successes + v | 7 | reporters/successes == Results ===================================================================== [ FAIL 0 | WARN 0 | SKIP 0 | PASS 7 ] @@ -228,9 +228,9 @@ --- - v | F W S OK | Context + v | F W S OK | Context - v | 7 | reporters/successes + v | 7 | reporters/successes == Results ===================================================================== [ FAIL 0 | WARN 0 | SKIP 0 | PASS 7 ] @@ -239,21 +239,21 @@ # reports backtraces - v | F W S OK | Context - - / | 0 | reporters/backtraces - - | 1 0 | reporters/backtraces - \ | 2 0 | reporters/backtraces - | | 3 0 | reporters/backtraces - / | 4 0 | reporters/backtraces - - | 5 0 | reporters/backtraces - \ | 6 0 | reporters/backtraces - | | 6 1 0 | reporters/backtraces - / | 6 1 1 | reporters/backtraces - - | 7 1 1 | reporters/backtraces - \ | 8 1 1 | reporters/backtraces - | | 9 1 1 | reporters/backtraces - x | 9 1 1 | reporters/backtraces + v | F W S OK | Context + + / | 0 | reporters/backtraces + - | 1 0 | reporters/backtraces + \ | 2 0 | reporters/backtraces + | | 3 0 | reporters/backtraces + / | 4 0 | reporters/backtraces + - | 5 0 | reporters/backtraces + \ | 6 0 | reporters/backtraces + | | 6 1 0 | reporters/backtraces + / | 6 1 1 | reporters/backtraces + - | 7 1 1 | reporters/backtraces + \ | 8 1 1 | reporters/backtraces + | | 9 1 1 | reporters/backtraces + x | 9 1 1 | reporters/backtraces -------------------------------------------------------------------------------- Error ('reporters/backtraces.R:5:8'): errors thrown at block level are entraced Error in `g()`: foo @@ -505,12 +505,12 @@ # records skips - v | F W S OK | Context + v | F W S OK | Context - / | 0 | reporters/skips - - | 1 0 | reporters/skips - \ | 2 0 | reporters/skips - v | 2 0 | reporters/skips + / | 0 | reporters/skips + - | 1 0 | reporters/skips + \ | 2 0 | reporters/skips + v | 2 0 | reporters/skips == Results ===================================================================== -- Skipped tests (2) -----------------------------------------------------------