Skip to content

Commit e1eaccf

Browse files
committed
Fix tests for compiled code on R-devel. Closes rstudio#1404
1 parent 0ff5ef5 commit e1eaccf

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

R/conditions.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ getCallNames <- function(calls) {
7676
}
7777

7878
getLocs <- function(calls) {
79-
sapply(calls, function(call) {
79+
vapply(calls, function(call) {
8080
srcref <- attr(call, "srcref", exact = TRUE)
8181
if (!is.null(srcref)) {
8282
srcfile <- attr(srcref, "srcfile", exact = TRUE)
@@ -86,7 +86,7 @@ getLocs <- function(calls) {
8686
}
8787
}
8888
return("")
89-
})
89+
}, character(1))
9090
}
9191

9292
#' @details \code{captureStackTraces} runs the given \code{expr} and if any

tests/testthat/test-stacks.R

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ causeError <- function(full) {
1313
B()
1414
})
1515

16-
res <- try(captureStackTraces(isolate(renderTable({C()}, server = FALSE)())),
16+
res <- try({
17+
captureStackTraces({
18+
isolate({
19+
renderTable({
20+
C()
21+
}, server = FALSE)()
22+
})
23+
})
24+
},
1725
silent = TRUE)
1826
cond <- attr(res, "condition", exact = TRUE)
1927

@@ -50,7 +58,7 @@ test_that("integration tests", {
5058
"isolate", "withCallingHandlers", "captureStackTraces", "doTryCatch",
5159
"tryCatchOne", "tryCatchList", "tryCatch", "try"))
5260
expect_equal(nzchar(df$loc), c(TRUE, TRUE, TRUE, FALSE, TRUE,
53-
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
61+
FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE,
5462
FALSE, FALSE))
5563

5664
df <- causeError(full = TRUE)
@@ -72,8 +80,8 @@ test_that("integration tests", {
7280
"tryCatch", "try"))
7381
expect_equal(nzchar(df$loc), c(FALSE, FALSE, FALSE, TRUE,
7482
TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
75-
FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE,
76-
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
83+
FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE,
84+
FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE,
7785
FALSE, FALSE, FALSE, FALSE))
7886
})
7987

0 commit comments

Comments
 (0)