Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Use warning() for "warnings" instead of cat() #619
First of all, thank you to everyone working on this package! I find it very useful.
I prefer to turn warnings into errors. (related discussion:
However, testthat does not use R's warning mechanism for the warnings it prints. I think it would be better to rely on R's centralized warning mechanism than catting the string "warning".
R CMD check currently gives me:
As you can see, there is no warning in the output here. However, testthat does give warnings (see the output at the bottom for the specific warnings given).
If I inspect the created testthat.Rout file, I could see the warnings. But I do not want to manually set up a grep.
testthat could either use the
If testthat does not want to use R's warnings for some reason, perhaps it could just use a different word (to me, a "warning" is well-defined in R), or perhaps respect conventions such as the "warn" option. For example, the warn option is ignored in the following:
Thanks for the response.
I see, that makes sense. But what about the second idea I mentioned above, of using the built-in warning at the end if any warnings were captured during any of the tests. Something like
Alternatively, whether a test is defined to "pass" or "fail" could depend on the "warn" option. If the "warn" option is 2, then if there is a warning the test "fails".
Yes, and I would prefer to be able to control that behavior by setting the 'warn' option.