Closed kyleam closed 1 year ago
@kyleam I think
options(warn = 2)
would work if we changed those tests fromexpect_warning()
toexpect_error()
, right? [...]
Simply s/warning/error/
? No, that wouldn't make the tests pass for at least two reasons: they'd then expect the wrong message (it'd now be the underlying one from fread rather than our custom one), and there are downstream asserts that expect an object to be returned (which wouldn't happen in the case of an error).
In any case, changing the tests so that they pass would just be hiding the core issue: nm_file_impl
expects to able to swallow fread
s warning, and a setting of warn = 2
breaks its behavior. Below is a minimal example of the behavior that I'm referring to.
When nm_file_impl() calls data.table::read(), it catches any warning and looks at the message to decide if multiple tables were in the file, in which case it warns and returns NULL. That logic fails if the user has tweaked the warn option to, for example, silence warnings or to convert warnings to errors.
Override the warn value to 1 so that the handler can reliably process the warnings.
Note that the default warn value is 0, which says to show a message like "There were NN warnings (use warnings() to see them)" if there are over 10 messages. That setting works fine because each handler will still receive the individual warnings, but it also has no effect. So 1 is simpler value that communicates the behavior we're relying on.
This commit was originally going to be a part of a series making deprecations like the ones in gh-561 show up as errors in Drone. I was hoping I could do that with
options(warn = 2)
, and, when you rundevtools::test()
with that, this test fails:Sadly, adjusting Drone is more complicated than just adding
-e options(warn = 2)
to thedevtools::check()
call, because it doesn't make it through to the underlying rcmdcheck. So, here's the fix by itself.Note that, even though its handling doesn't trigger a test failure,
check_run_times
could probably use a similar fix in two spots, but I haven't taken the time to work through that code and decide whether it matters in practice.