Skip to content

Commit

Permalink
Merge branch 'main' into pkg_test_env
Browse files Browse the repository at this point in the history
* main:
  Replace crayon by cli (#399)
  ci: Use actions/upload-artifacts@v4 (#398)
  Change message load_timeout (#394)
  • Loading branch information
schloerke committed Feb 10, 2025
2 parents 7c70eb6 + 596ecf6 commit 918664e
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Imports:
callr,
checkmate (>= 2.0.0),
chromote (>= 0.1.2),
crayon,
cli,
fs,
globals (>= 0.14.0),
httr,
Expand Down
14 changes: 7 additions & 7 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export(use_shinytest2)
export(use_shinytest2_test)
importFrom(R6,R6Class)
importFrom(callr,process)
importFrom(crayon,blue)
importFrom(crayon,cyan)
importFrom(crayon,green)
importFrom(crayon,magenta)
importFrom(crayon,make_style)
importFrom(crayon,red)
importFrom(crayon,silver)
importFrom(cli,col_blue)
importFrom(cli,col_cyan)
importFrom(cli,col_green)
importFrom(cli,col_magenta)
importFrom(cli,col_red)
importFrom(cli,col_silver)
importFrom(cli,make_ansi_style)
importFrom(rlang,"%||%")
importFrom(rlang,":=")
importFrom(rlang,list2)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

* Add support for `$click()`ing `{bslib}`'s `input_task_button()` (#829).

* Improved the error message when an app takes too long to start up (@LouisLeNezet, #394).

* `{shinytest2}` now imports `{cli}` and no longer imports `{crayon}` (@olivroy, #399).

# shinytest2 0.3.2

## Bug / Improvements
Expand Down
2 changes: 1 addition & 1 deletion R/app-driver-initialize.R
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ app_initialize <- function(self, private, ..., view = missing_arg()) {
c(
conditionMessage(e),
"\n",
i = crayon::silver("You can inspect the failed AppDriver object via `rlang::last_error()$app`"),
i = cli::col_silver("You can inspect the failed AppDriver object via `rlang::last_error()$app`"),
i = paste0("AppDriver logs:\n", logs),
"\n"
),
Expand Down
11 changes: 9 additions & 2 deletions R/app-driver-start.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,15 @@ app_start_shiny <- function(
Sys.sleep(0.2)

if (i == max_i) {
app_abort(self, private, paste0(
"Cannot find shiny port number. Error lines found:\n",
app_abort(self, private, sprintf(
paste(
"The Shiny app failed to start up within %s second%s.",
"To increase the loading timeout, consult the documentation in `?AppDriver`",
"for the `load_timeout` argument of `AppDriver$new()`.",
"The app printed the following lines to stderr during start up:\n%s"
),
load_timeout / 1000,
if (load_timeout == 1000) "" else "s",
paste(err_lines, collapse = "\n")
))
}
Expand Down
2 changes: 1 addition & 1 deletion R/compare-screenshot-threshold.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ compare_screenshot_threshold <- function(
" > `", threshold, "` (threshold)."),
"*" = paste0("`old`:", old),
"*" = paste0("`new`:", new),
"i" = crayon::silver("(To remove this message, increase `threshold`, or set `quiet = TRUE`)")
"i" = cli::col_silver("(To remove this message, increase `threshold`, or set `quiet = TRUE`)")
))
}

Expand Down
8 changes: 4 additions & 4 deletions R/shinytest2-logs.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ print.shinytest2_log <- function(x, ...) {
}

#' @export
#' @importFrom crayon blue magenta cyan green red silver make_style
#' @importFrom cli col_blue col_magenta col_cyan col_green col_red col_silver make_ansi_style
format.shinytest2_log <- function(x, ...) {

get_color <- function(location, level) {
switch(as.character(location),
shiny = switch(level, stderr = magenta, force),
chromote = switch(level, throw = red, error = red, cyan),
shinytest2 = switch(level, green)
shiny = switch(level, stderr = col_magenta, force),
chromote = switch(level, throw = col_red, error = col_red, col_cyan),
shinytest2 = switch(level, col_green)
)
}

Expand Down
2 changes: 1 addition & 1 deletion actions/test-app/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ runs:
- name: Upload snapshots
if: inputs.upload-snapshots != 'false'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-r${{ steps.test-app.outputs.r-version }}-testthat-snapshots
# path: ${{ inputs.app-dir }}/tests*/testthat/_snaps
Expand Down

0 comments on commit 918664e

Please sign in to comment.