Skip to content

Guard cli.spinner option to avoid crash#74

Merged
vandenman merged 1 commit intojasp-stats:masterfrom
FBartos:fix-agentTest
Mar 2, 2026
Merged

Guard cli.spinner option to avoid crash#74
vandenman merged 1 commit intojasp-stats:masterfrom
FBartos:fix-agentTest

Conversation

@FBartos
Copy link
Contributor

@FBartos FBartos commented Mar 2, 2026

Handle invalid cli.spinner option values in runTestsQuietly. btw::local_reproducible_output (via btw_tool_run_r) can set options(cli.spinner = FALSE), which causes cli::get_spinner() to fail ("$ operator is invalid for atomic vectors") when testthat reporters access spinner frames. This change saves the old value, coerces non-NULL non-character non-list values to "line", and restores the original option on exit to prevent the crash during tests.

Handle invalid cli.spinner option values in runTestsQuietly. btw::local_reproducible_output (via btw_tool_run_r) can set options(cli.spinner = FALSE), which causes cli::get_spinner() to fail ("$ operator is invalid for atomic vectors") when testthat reporters access spinner frames. This change saves the old value, coerces non-NULL non-character non-list values to "line", and restores the original option on exit to prevent the crash during tests.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a defensive guard in runTestsQuietly() to prevent a crash when cli.spinner has been set to an invalid value (e.g., FALSE) by btw::local_reproducible_output(). The cli::get_spinner() function used internally by testthat reporters requires the option to be NULL, a character string, or a list — any other type causes a "$ operator is invalid for atomic vectors" crash.

Changes:

  • The invalid cli.spinner option value is detected and coerced to "line" before tests run.
  • The original option value is always restored via on.exit() after the test function completes.

#' @keywords internal
runTestsQuietly <- function(testFun) {
# Fix cli.spinner: btw::local_reproducible_output() (called by btw_tool_run_r)

Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explanatory comment is accidentally split by a blank line between lines 166 and 168, making it read as two separate comments. The sentence "btw::local_reproducible_output() (called by btw_tool_run_r)" is cut off at line 166, with the rest of the sentence starting on line 168. The blank line should be removed so the comment is a single continuous block.

Suggested change

Copilot uses AI. Check for mistakes.
@vandenman vandenman merged commit c6d0764 into jasp-stats:master Mar 2, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants