tinytest icon indicating copy to clipboard operation
tinytest copied to clipboard

options(warn = 1) by default?

Open HenrikBengtsson opened this issue 3 years ago • 5 comments

WRE now (https://github.com/wch/r-source/commit/3a3073b94eaadb024e4ebf6cdfb041833bad4382) says:

@item
Tests should use @code{options(warn = 1)} as reporting

@example
There were 22 warnings (use warnings() to see them)
@end example

@noindent
is pointless, especially for automated checking systems.

Is this something that tinytest could do by default, e.g. in run_test_file()?

PS. This is just a comment; I'm new to tinytest, so sorry if this has already been discussed or is out of the scope of the design/philosophy.

HenrikBengtsson avatar Feb 25 '21 19:02 HenrikBengtsson

Thanks, I was unaware of this WRE requirement.

It seems like a good default, especially for test_package as this is the command that is intended to be used to trigger tests in R CMD check.

markvanderloo avatar Feb 25 '21 20:02 markvanderloo

There are some other things I should set, e.g. make sure that the sorting locale is C like in R CMD check. cf #69. In the works.

markvanderloo avatar Feb 25 '21 20:02 markvanderloo

Interesting suggestion!

But I am not sure if always turning it on is right? Maybe making this is a toggle is better. I.e. in my for-work package, I warn on use of a deprecated-but-supported interface. That counts as a warning yet I know full well it is there. Making the test fails does not help.

Or maybe we add a per-file 'un-setter' of this default?

eddelbuettel avatar Feb 25 '21 20:02 eddelbuettel

Come to think about it, I could locally reset options(warn) before hitting the deprecated calls. But then I get dinged with a 'side-effects triggered'. Less bad than a fail, I suppose...

eddelbuettel avatar Feb 25 '21 21:02 eddelbuettel

For packages we can probably get away with adding the option setting to tests/tinytest.R, so

options(warn=1)
tinytest::test_package("foo")

I can add this to setup_tinytest() and ppl can do it explicitly if they run tests interactively. waddayathink?

markvanderloo avatar Jun 25 '21 14:06 markvanderloo