Skip to content

Handle interrupts in tests #2148

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

Merged
merged 4 commits into from
Aug 5, 2025
Merged

Handle interrupts in tests #2148

merged 4 commits into from
Aug 5, 2025

Conversation

hadley
Copy link
Member

@hadley hadley commented Jul 31, 2025

I don't see any way to test this programmatically, so I've been testing by adding Sys.sleep(10) to a random test.

Fixes #1464

I don't see any way to test this programmatically, so I've just been adding `Sys.sleep(10)` to a random test.

Fixes #1464
@hadley hadley requested a review from lionel- July 31, 2025 20:36
stop_reporter = TRUE,
praise = TRUE,

initialize = function(stop_reporter = TRUE, praise = TRUE) {
super$initialize()
self$failures <- Stack$new()
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a refactoring I included in this PR because it was confusing me — failures did not just track failing expectations, but all expectations that we need to inform the user about.

messages <- vapply(failures, issue_summary, rule = TRUE, character(1))
if (length(messages) > 0) {
if (self$issues$size() == 0) {
if (self$praise && self$n_success > 0) {
Copy link
Member Author

Choose a reason for hiding this comment

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

The key change is to only report success if there was one actual success — normally if there are zero successes you'll get a skip, but that doesn't help with interrupts. (I also tried emitting a skip, but I think that adds additional unneeded noise).

@hadley hadley merged commit 1154cbf into main Aug 5, 2025
10 of 11 checks passed
@hadley hadley deleted the test-interrupt branch August 5, 2025 16:35
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.

Mention current test on interrupt
2 participants