cli
cli copied to clipboard
Concrete demo of what I'm seeing
As per slack discussion
This test passes when executed via test_active_file() or test() in the RStudio console, but fails in the RStudio build pane or in a terminal inside RStudio. It passes via any method when run via R in a (non-RStudio) terminal.
Update: the CI test failures seem to just be snapshot related and are not what I'm seeing, which I'll copy/paste below.
Error (test-code.R:19:3): Jenny's problem [ansi]
Error: RStudio not running
Backtrace:
▆
1. └─testthat::expect_snapshot(cli_code_wrapper("if (1) {true_val} else {false_val}")) at test-code.R:19:3
2. └─testthat:::expect_snapshot_helper(...)
3. └─testthat:::snapshot_accept_hint(variant, snapshotter$file)
4. ├─base::paste0(...)
5. └─cli::format_inline("* Run {.run testthat::snapshot_accept('{name}')} to accept the change.")
6. └─cli::cli_fmt(...) at cli/R/cli.R:120:3
7. └─cli:::cli__fmt(rec, collapse, strip_newline) at cli/R/cli.R:91:3
8. ├─base::do.call(app[[msg$type]], msg$args) at cli/R/cli.R:61:5
9. └─cli (local) `<fn>`(text = `<cl_gl_dl>`)
10. └─cli:::clii_inline_text(app, text) at cli/R/cliapp.R:6:3
11. └─app$xtext(text, wrap = FALSE) at cli/R/cliapp.R:171:3
12. └─cli:::clii__xtext(...) at cli/R/cliapp.R:6:3
13. └─style$fmt(text) at cli/R/internals.R:18:3
14. └─cli::code_highlight(lines) at cli/R/themes.R:373:5
15. ├─code_theme %||% code_theme_default() at cli/R/prettycode.R:41:3
16. └─cli:::code_theme_default() at cli/R/prettycode.R:41:3
17. └─cli:::code_theme_default_rstudio() at cli/R/prettycode.R:243:5
18. └─cli:::get_rstudio_theme() at cli/R/prettycode.R:272:3
19. ├─base::suppressWarnings(rstudioapi::getThemeInfo()) at cli/R/aaa-utils.R:166:3
20. │ └─base::withCallingHandlers(...)
21. └─rstudioapi::getThemeInfo()
22. └─rstudioapi::callFun("getThemeInfo")
23. └─rstudioapi::verifyAvailable()
I can't reproduce this, the test passes in the build pane, and also in an RStudio terminal. :(
Can you check your config for potentially related env vars and options?
I've removed .Renviron and .Rprofile and see the same result as before (failure in the RStudio build pane). FWIW this is with RStudio Version 2023.12.1+402 (2023.12.1+402).
Yeah, same here. Same RStudio, R 4.3.2, no profile, no env vars, no test failure.
The stack trace, otoh, looks pretty good, I might be able to work something out there.
What's your theme?
> rstudioapi::getThemeInfo()
$editor
[1] "Chrome"
$global
[1] "Modern"
$dark
[1] FALSE
$foreground
[1] "rgb(0, 0, 0)"
$background
[1] "rgb(255, 255, 255)"
Looks same as you:
rstudioapi::getThemeInfo()
#> $editor
#> [1] "Chrome"
#>
#> $global
#> [1] "Modern"
#>
#> $dark
#> [1] FALSE
#>
#> $foreground
#> [1] "rgb(0, 0, 0)"
#>
#> $background
#> [1] "rgb(255, 255, 255)"
What's your testthat version?
testthat 3.2.1
Freshly re-installed and re-checked, for good measure. Still seeing my same result.
@jennybc Is this still relevant? Can you still reproduce it?
I'm going to close this, because it's sort of foggy for me now. If it's still real, I'll encounter it again and we can discuss then.