Skip to content

Commit 5e6c540

Browse files
committed
Don't count foreign warnings when skipping some
We already only count warnings in foreign mode, don't match their text contents. With ignore.warning set, we lack a way to figure out when the translated warning should be skipped, so don't count them at all.
1 parent 5c9ec23 commit 5e6c540

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

R/test.data.table.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,15 +452,15 @@ test = function(num,x,y=TRUE,error=NULL,warning=NULL,message=NULL,output=NULL,no
452452
stopifnot(is.character(ignore.warning), !anyNA(ignore.warning), nchar(ignore.warning)>=1L)
453453
for (msg in ignore.warning) observed = grep(msg, observed, value=TRUE, invert=TRUE) # allow multiple for translated messages rather than relying on '|' to always work
454454
}
455-
if (length(expected) != length(observed)) {
455+
if (length(expected) != length(observed) && (!foreign || is.null(ignore.warning))) {
456456
# nocov start
457457
catf("Test %s produced %d %ss but expected %d\n%s\n%s\n", numStr, length(observed), type, length(expected), paste("Expected:", expected), paste("Observed:", observed, collapse = "\n"))
458458
fail = TRUE
459459
# nocov end
460-
} else {
460+
} else if (!foreign) {
461461
# the expected type occurred and, if more than 1 of that type, in the expected order
462462
for (i in seq_along(expected)) {
463-
if (!foreign && !string_match(expected[i], observed[i])) {
463+
if (!string_match(expected[i], observed[i])) {
464464
# nocov start
465465
catf("Test %s didn't produce the correct %s:\nExpected: %s\nObserved: %s\n", numStr, type, expected[i], observed[i])
466466
fail = TRUE

0 commit comments

Comments
 (0)