Skip to content

Commit

Permalink
Replace crayon by cli + address some TODOs to add some color
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Dec 12, 2024
1 parent 9a35b01 commit 368fef0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Imports:
later (>= 1.0.0),
promises (>= 1.3.2),
tools,
crayon,
cli,
rlang (>= 0.4.10),
fastmap (>= 1.1.1),
withr,
Expand Down Expand Up @@ -210,7 +210,6 @@ Collate:
RoxygenNote: 7.3.2
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RdMacros: lifecycle
Config/testthat/edition: 3
Config/Needs/check:
shinytest2
6 changes: 3 additions & 3 deletions R/conditions.R
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,11 @@ printOneStackTrace <- function(stackTrace, stripResult, full, offset) {
": ",
mapply(paste0(st$call, st$loc), st$category, FUN = function(name, category) {
if (category == "pkg")
crayon::silver(name)
cli::col_silver(name)
else if (category == "user")
crayon::blue$bold(name)
cli::style_bold(cli::col_blue(name))
else
crayon::white(name)
cli::col_white(name)
}),
"\n"
)
Expand Down
8 changes: 3 additions & 5 deletions R/test.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ print.shiny_runtests <- function(x, ..., reporter = "summary") {


if (any(x$pass)) {
# TODO in future... use clisymbols::symbol$tick and crayon green
cat("* Success\n")
cli::cat_bullet("Success", bullet = "tick", bullet_col = "green")
mapply(
x$file,
x$pass,
Expand All @@ -171,9 +170,8 @@ print.shiny_runtests <- function(x, ..., reporter = "summary") {
}
)
}
if (any(!x$pass)) {
# TODO in future... use clisymbols::symbol$cross and crayon red
cat("* Failure\n")
if (!all(x$pass)) {
cli::cat_bullet("Failure", bullet = "cross", bullet_col = "red")
mapply(
x$file,
x$pass,
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-test-runTests.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ test_that("runTests runs as expected without rewiring", {
appDir <- test_path(file.path("..", "test-helpers", "app1-standard"))
df <- testthat::expect_output(
print(runTests(appDir = appDir, assert = FALSE)),
"Shiny App Test Results\\n\\* Success\\n - app1-standard/tests/runner1\\.R\\n - app1-standard/tests/runner2\\.R"
"Shiny App Test Results\\n\\v Success\\n - app1-standard/tests/runner1\\.R\\n - app1-standard/tests/runner2\\.R"
)

expect_equal(df, data.frame(
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-test-server-app.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test_that("runTests works with a dir app that calls modules and uses testServer"
app <- test_path("..", "test-modules", "12_counter")
run <- testthat::expect_output(
print(runTests(app)),
"Shiny App Test Results\\n\\* Success\\n - 12_counter/tests/testthat\\.R"
"Shiny App Test Results\\n\\v Success\\n - 12_counter/tests/testthat\\.R"
)
expect_true(all(run$pass))
})
Expand All @@ -50,7 +50,7 @@ test_that("runTests works with a dir app that calls modules that return reactive
app <- test_path("..", "test-modules", "107_scatterplot")
run <- testthat::expect_output(
print(runTests(app)),
"Shiny App Test Results\\n\\* Success\\n - 107_scatterplot/tests/testthat\\.R"
"Shiny App Test Results\\n\\v Success\\n - 107_scatterplot/tests/testthat\\.R"
)
expect_true(all(run$pass))
})
Expand Down

0 comments on commit 368fef0

Please sign in to comment.