17

Is there any way I could raise my own NOTE exception from within the unit tests in the checking tests ... step of R CMD check?
In general I would like to have a NOTE in 00check.log if database was not available during unit tests.
Dirty solutions welcome.

Update: Actually I see much more use cases for such feature, adding bounty.

jangorecki
  • 16,384
  • 4
  • 79
  • 160
  • 2
    I am not sure you can--you'd need access to the `Log` object in the environment of the `tools` package. – Dirk Eddelbuettel Mar 01 '16 at 15:40
  • 1
    If you're using testthat, you can use `print` inside of a testing file. It's not a NOTE, but at least its some output you could check for that isn't going to make the check fail. – Josh Mar 03 '16 at 23:00
  • You might consider including your own questions before submission with `devtools::release()`. From the help file: "You can also add arbitrary extra questions by defining an (un-exported) function called release_questions() that returns a character vector of additional questions to ask" – Gustavo B Paterno Jul 26 '16 at 18:21

1 Answers1

1

Generally tests are run in a separate process. The Log object that Dirk referred to is a local variable in the original process, so there's no way to access it.

Errors in the child process are detected by a non-zero return value. Other anomalies in the test script aren't seen unless you've saved a copy of the desired output; then the comparison of new output with old would see them.

user2554330
  • 37,248
  • 4
  • 43
  • 90