You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe you are considering (or actively) deprecating the info argument to many expect functions. I understand the value of using NSE for label, but it has a length limitation I'm butting my head against.
Working example: a function that takes an input file, does something to it (silently), and returns a data.frame. Because the processing is non-trivial, I want to do it only once per file, so I capture the return value after testing for silence (ergo expect_silence2). I need to run it twice on each file (diff arguments).
Taking a cue from your tests chapter, I believe a way to do this is something like:
Ideally, I'd run it as for (fn in allfiles) expect_mytests(fn), but for the sake of this issue:
expect_mytests(strrep("b", 9))
expect_mytests(strrep("b", 53))
# Error: nr("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", out0) is not strictly less than 10. Difference: 43
expect_mytests(strrep("b", 54))
# Error: nr(...) is not strictly less than 10. Difference: 89
First: we've lost the NSE info on the last call (not dependent on options("width")). Filenames can be (and in my use, "are often") over 53 characters, and this complete loss is unexpected. I can strategically truncate the string, though this is prone to "works best for me" syndrome (e.g., first 50? last 50? first/last 25?).
Second: the only way I can imagine providing that file-specificity with the failure messages is to add it as an unused argument to my nr function. This works, but it seems a bit kludgy. Is this the only way to include the filename (in this example) within the failure message?
(Third: is this really the best/only way to get the info stuff into the failure message?)
As I'm writing this ... if I switch the order of the arguments within nr, this goes away:
expect_mytests<-function(fn) {
out0<- expect_silent2(my_complex_function(fn, add1=FALSE))
out1<- expect_silent2(my_complex_function(fn, add1=TRUE))
nr<-function(a, ...) nrow(a) # arguably better-looking, anyway
eval(bquote(expect_lt(nr(out0, .(fn)), 10)))
eval(bquote(expect_lt(nr(out1, .(fn)), 10)))
}
expect_mytests(strrep("b", 99))
# Error: nr(out0, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb") is not strictly less than 10. Difference: 89
Is this a limitation of eval or bquote, or is this something testthat is imposing? (I could not find "54" ...)
I believe you are considering (or actively) deprecating the
info
argument to manyexpect
functions. I understand the value of using NSE forlabel
, but it has a length limitation I'm butting my head against.Working example: a function that takes an input file, does something to it (silently), and returns a
data.frame
. Because the processing is non-trivial, I want to do it only once per file, so I capture the return value after testing for silence (ergoexpect_silence2
). I need to run it twice on each file (diff arguments).Taking a cue from your tests chapter, I believe a way to do this is something like:
Ideally, I'd run it as
for (fn in allfiles) expect_mytests(fn)
, but for the sake of this issue:First: we've lost the NSE info on the last call (not dependent on
options("width")
). Filenames can be (and in my use, "are often") over 53 characters, and this complete loss is unexpected. I can strategically truncate the string, though this is prone to "works best for me" syndrome (e.g., first 50? last 50? first/last 25?).Second: the only way I can imagine providing that file-specificity with the failure messages is to add it as an unused argument to my
nr
function. This works, but it seems a bit kludgy. Is this the only way to include the filename (in this example) within the failure message?(Third: is this really the best/only way to get the
info
stuff into the failure message?)As I'm writing this ... if I switch the order of the arguments within
nr
, this goes away:Is this a limitation of
eval
orbquote
, or is this somethingtestthat
is imposing? (I could not find "54" ...)Related issue refs:
info
(andlabel
?) for certain expectations #392 consider un-deprecatinginfo
(andlabel
?) for certain expectationsThe text was updated successfully, but these errors were encountered: