Skip to content

Commit 519c5e5

Browse files
committed
tests: remember tracebacks from warnings
1 parent 8606301 commit 519c5e5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

R/test.data.table.R

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,17 @@ test.data.table = function(script="tests.Rraw", verbose=FALSE, pkg=".", silent=F
212212
warning=function(w) {
213213
# nocov start
214214
if (!silent && showProgress) print(w)
215-
env$warnings = c(env$warnings, list(list(env$prevtest, toString(w))))
215+
env$warnings = c(env$warnings, list(list(
216+
env$prevtest, toString(w),
217+
paste(
218+
vapply_1c(sys.calls(), function(call) {
219+
if (length(call) && is.name(call[[1]])) {
220+
as.character(call[[1]])
221+
} else "..."
222+
}),
223+
collapse=" -> "
224+
)
225+
)))
216226
invokeRestart("muffleWarning")
217227
# nocov end
218228
}
@@ -278,7 +288,7 @@ test.data.table = function(script="tests.Rraw", verbose=FALSE, pkg=".", silent=F
278288
if (length(env$warnings)) {
279289
# nocov start
280290
warnings = rbindlist(env$warnings)
281-
setnames(warnings, c("after test", "warning"))
291+
setnames(warnings, c("after test", "warning", "calls"))
282292
catf(
283293
ngettext(length(warnings),
284294
"Caught %d warning outside the test() calls:\n",

0 commit comments

Comments
 (0)