Skip to content

Commit dad4348

Browse files
bschilderclaude
andcommitted
Fix run_benchmark_once: message(<condition>) escapes tryCatch under testthat
The tryCatch handlers in run_benchmark_once() called `message(e)` where `e` is the caught condition. R's `message()` re-signals any condition passed to it. Under testthat's calling handlers, signaling an error condition is treated as a test error β€” which escapes the tryCatch even though tryCatch *did* catch it. This caused test-run_benchmark to fail on GitHub Actions whenever the g:Profiler API returned malformed JSON (e.g. for fruit fly β†’ human). The all_genes() and convert_orthologs() calls were supposed to record NA and continue, but the test errored at line 9 instead. Fix: pass `conditionMessage(e)` (a plain string) to `message()` so it prints the message text without re-signaling the condition. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f977afd commit dad4348

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

β€ŽDESCRIPTIONβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: orthogene
22
Type: Package
33
Title: Gene mapping made easy
4-
Version: 1.17.3
4+
Version: 1.17.4
55
Authors@R:
66
c(
77
person(given = "Brian",

β€ŽNEWS.mdβ€Ž

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# orthogene 1.17.4
2+
3+
## Bug fixes
4+
5+
* `run_benchmark_once()`: replace `message(e)` with
6+
`message(conditionMessage(e))` inside the `tryCatch` error handlers.
7+
Passing a condition object to `message()` re-signals it, and under
8+
testthat's calling handlers an error condition signaled this way escapes
9+
the `tryCatch` and is reported as a test failure β€” even though
10+
`tryCatch` did catch it. This caused `test-run_benchmark` to fail on
11+
GitHub Actions whenever the g:Profiler API returned malformed JSON, even
12+
though `run_benchmark_once()` was supposed to record `NA` and move on.
13+
114
# orthogene 1.17.3
215

316
## Bug fixes

β€ŽR/run_benchmark_once.Rβ€Ž

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ run_benchmark_once <- function(species,
3030
)
3131
},
3232
error = function(e) {
33-
message(e)
33+
## Pass conditionMessage() rather than the condition itself β€”
34+
## message(<condition>) re-signals the condition, which testthat's
35+
## calling handlers then treat as a test error, escaping tryCatch.
36+
message("all_genes() failed: ", conditionMessage(e))
3437
NA
3538
}
36-
)
39+
)
3740
if (is.data.frame(gene_map1)){
3841
time1 <- gene_map1$time[1]
3942
} else {
@@ -78,7 +81,9 @@ run_benchmark_once <- function(species,
7881
)
7982
},
8083
error = function(e) {
81-
message(e)
84+
## See comment above: message(<condition>) re-signals the
85+
## condition and escapes tryCatch under testthat.
86+
message("convert_orthologs() failed: ", conditionMessage(e))
8287
NA
8388
}
8489
)

0 commit comments

Comments
Β (0)