Skip to content

Commit

Permalink
Make skip column 2 chars wide (#1845)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgirlich authored Sep 25, 2023
1 parent 89107e8 commit b138bf7
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 60 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 12 additions & 3 deletions R/reporter-progress.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
}

}
}

Expand Down
114 changes: 57 additions & 57 deletions tests/testthat/_snaps/reporter-progress.md
Original file line number Diff line number Diff line change
@@ -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()`: !
Expand Down Expand Up @@ -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 ]
Expand All @@ -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
Expand Down Expand Up @@ -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 ]
Expand All @@ -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 ]
Expand All @@ -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
Expand Down Expand Up @@ -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) -----------------------------------------------------------
Expand Down

0 comments on commit b138bf7

Please sign in to comment.