Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace crayon by cli + address some TODOs to add some color #4170

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
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
Loading