Skip to content

Commit b6d9685

Browse files
committed
Use notOutput= instead of capture.output() tests
Where capture.output() was previously used to test the absence of messages, use notOutput= instead so that the test will be skipped. While the test succeeded anyway due to the captured output containing neither the original untranslated message (being matched) nor its translation (that could be printed if a regression happened), skipping the test is more fair.
1 parent 9c58f3e commit b6d9685

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

inst/tests/tests.Rraw

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,17 +2031,19 @@ options(datatable.optimize = 2L)
20312031
test(658.1, DT[ , mean(x), by=grp1, verbose=TRUE], output="GForce optimized j to.*gmean")
20322032
test(658.2, DT[ , list(mean(x)), by=grp1, verbose=TRUE], output="GForce optimized j to.*gmean")
20332033
test(658.3, DT[ , list(mean(x), mean(y)), by=grp1, verbose=TRUE], output="GForce optimized j to.*gmean")
2034-
tt = capture.output(DT[,list(mean(x),mean(y)),by=list(grp1,grp2),verbose=TRUE])
2035-
test(659, !length(grep("Wrote less rows", tt))) # first group is one row with this seed. Ensure we treat this as aggregate case rather than allocate too many rows.
2034+
# first group is one row with this seed. Ensure we treat this as aggregate case rather than allocate too many rows.
2035+
test(659, DT[,list(mean(x),mean(y)),by=list(grp1,grp2),verbose=TRUE], notOutput = "Wrote less rows")
20362036

20372037
# Test .N for logical i subset
20382038
DT = data.table(a=1:10, b=rnorm(10))
20392039
test(660, DT[a==8L, .N], 1L)
20402040

20412041
# Test that growing is sensible in worst case
20422042
DT = data.table(a=rep(1:10,1:10),b=rnorm(55))
2043-
tt = capture.output(DT[,sum(b)*b,by=a,verbose=TRUE])
2044-
test(661, length(grep("growing from",tt))<3) # was 6 when we simply grew enough for latest result
2043+
test(661, DT[,sum(b)*b,by=a,verbose=TRUE],
2044+
notOutput = paste(rep("growing from", 3), collapse = ".*"))
2045+
# Need to test that "growing from" is printed less than three times.
2046+
# The number was previously 6 when we simply grew enough for latest result
20452047

20462048
# Test that adding a new logical column is supported, #2094
20472049
DT=data.table(a=1:3)
@@ -10246,33 +10248,33 @@ options("datatable.use.index"=TRUE, "datatable.auto.index"=TRUE)
1024610248
test(1666.01, d[k==1L, verbose=TRUE], d[3L], output="Creating new index 'k'")
1024710249
d = data.table(k=3:1)
1024810250
options("datatable.use.index"=TRUE, "datatable.auto.index"=FALSE)
10249-
test(1666.02, grep("Creating new index", capture.output(d[k==1L, verbose=TRUE])), integer(0)) # do not create index
10251+
test(1666.02, d[k==1L, verbose=TRUE], notOutput="Creating new index") # do not create index
1025010252
d = data.table(k=3:1)
1025110253
options("datatable.use.index"=FALSE, "datatable.auto.index"=FALSE)
10252-
test(1666.03, grep("Creating new index", capture.output(d[k==1L, verbose=TRUE])), integer(0))
10254+
test(1666.03, d[k==1L, verbose=TRUE], notOutput="Creating new index")
1025310255
d = data.table(k=3:1)
1025410256
options("datatable.use.index"=FALSE, "datatable.auto.index"=TRUE)
10255-
test(1666.04, grep("Creating new index", capture.output(d[k==1L, verbose=TRUE])), integer(0))
10257+
test(1666.04, d[k==1L, verbose=TRUE], notOutput="Creating new index")
1025610258
d = data.table(k=3:1) # subset - index
1025710259
setindex(d, k)
1025810260
options("datatable.use.index"=TRUE, "datatable.auto.index"=TRUE)
1025910261
test(1666.05, d[k==1L, verbose=TRUE], d[3L], output="Optimized subsetting with index 'k'")
1026010262
options("datatable.use.index"=TRUE, "datatable.auto.index"=FALSE)
1026110263
test(1666.06, d[k==1L, verbose=TRUE], d[3L], output="Optimized subsetting with index 'k'")
1026210264
options("datatable.use.index"=FALSE, "datatable.auto.index"=FALSE)
10263-
test(1666.07, grep("Using existing index", capture.output(d[k==1L, verbose=TRUE])), integer(0)) # not using existing index
10265+
test(1666.07, d[k==1L, verbose=TRUE], notOutput="Using existing index") # not using existing index
1026410266
options("datatable.use.index"=FALSE, "datatable.auto.index"=TRUE)
10265-
test(1666.08, grep("Using existing index", capture.output(d[k==1L, verbose=TRUE])), integer(0))
10267+
test(1666.08, d[k==1L, verbose=TRUE], notOutput="Using existing index")
1026610268
d1 = data.table(k=3:1) # join - no index
1026710269
d2 = data.table(k=2:4)
1026810270
options("datatable.use.index"=TRUE, "datatable.auto.index"=TRUE)
1026910271
test(1666.09, d1[d2, on="k", verbose=TRUE], d1[d2, on="k"], output="ad hoc")
1027010272
options("datatable.use.index"=TRUE, "datatable.auto.index"=FALSE)
1027110273
test(1666.10, d1[d2, on="k", verbose=TRUE], d1[d2, on="k"], output="ad hoc")
1027210274
options("datatable.use.index"=FALSE, "datatable.auto.index"=FALSE)
10273-
test(1666.11, grep("Looking for existing (secondary) index", capture.output(d1[d2, on="k", verbose=TRUE])), integer(0)) # not looking for index
10275+
test(1666.11, d1[d2, on="k", verbose=TRUE], notOutput="Looking for existing (secondary) index") # not looking for index
1027410276
options("datatable.use.index"=FALSE, "datatable.auto.index"=TRUE)
10275-
test(1666.12, grep("Looking for existing (secondary) index", capture.output(d1[d2, on="k", verbose=TRUE])), integer(0))
10277+
test(1666.12, d1[d2, on="k", verbose=TRUE], notOutput="Looking for existing (secondary) index")
1027610278
d1 = data.table(k=3:1,v1=10:12) # join - index
1027710279
d2 = data.table(k=2:4,v2=20:22)
1027810280
setindex(d1, k)
@@ -16319,7 +16321,7 @@ test(2094.02, X$TAG, rep(names(x), each = 2))
1631916321

1632016322
# use arbitrary column without message when fun.aggregate=length, #2980
1632116323
DT = data.table(a=c(3L, 3L, 2L, 9L, 5L, 10L, 3L, 2L, 9L, 8L), b=rep(1:5, 2))
16322-
test(2095, any(grepl('override', capture.output(dcast(DT, a~b, fun.aggregate=length)), fixed=TRUE)), FALSE)
16324+
test(2095, dcast(DT, a~b, fun.aggregate=length), notOutput='override')
1632316325

1632416326
# gmean intermediate can overflow integers without warning, #986
1632516327
test(2096, data.table(a=c(1L,1L), v=c(2e9L, 2e9L))[, mean(v), a], data.table(a=1L, V1=2e9))

0 commit comments

Comments
 (0)