Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can a test script inform R CMD check that it should emit a custom message?
    text
    copied!<p>I'm writing a R package (<a href="https://r-forge.r-project.org/projects/delftfews/" rel="nofollow noreferrer"><code>delftfews</code></a>) here at office. we are using <a href="https://r-forge.r-project.org/projects/sciviews" rel="nofollow noreferrer"><code>svUnit</code></a> for unit testing. </p> <p>our process for describing new functionality: we define new unit tests, initially marked as <code>DEACTIVATED</code>; one block of tests at a time we activate them and implement the function described by the tests. almost all the time we have a small amount of DEACTIVATED tests, relative to functions that might be dropped or will be implemented.</p> <p>my problem/question is: can I alter the <a href="http://rwiki.sciviews.org/doku.php?id=developers:runit#another_approach_using_svunit" rel="nofollow noreferrer">doSvUnit.R</a> so that <code>R CMD check pkg</code> emits a NOTE (i.e. a custom message "NOTE" instead of "OK") in case there are DEACTIVATED tests? </p> <p>as of now, we see only that the active tests don't give error:</p> <pre><code>. . * checking for unstated dependencies in tests ... OK * checking tests ... Running ‘doSvUnit.R’ OK * checking PDF version of manual ... OK </code></pre> <p>which is all right if all tests succeed, but less all right if there are skipped tests and definitely wrong if there are failing tests. In this case, I'd actually like to see a NOTE or a WARNING like the following:</p> <pre><code>. . * checking for unstated dependencies in tests ... OK * checking tests ... Running ‘doSvUnit.R’ NOTE 6 test(s) were skipped. WARNING 1 test(s) are failing. * checking PDF version of manual ... OK </code></pre> <p>As of now, we have to open the <code>doSvUnit.Rout</code> to check the real test results.</p> <hr> <p>I contacted two of the maintainers at r-forge and CRAN and they pointed me to the <a href="https://svn.r-project.org/R/trunk/" rel="nofollow noreferrer">sources of R</a>, in particular the <a href="https://svn.r-project.org/R/trunk/src/library/tools/R/testing.R" rel="nofollow noreferrer"><code>testing.R</code></a> script.</p> <p>if I understand it correctly, to answer this question we need patching the <code>tools</code> package: </p> <ul> <li>scripts in the tests directory are called using a <code>system</code> call,</li> <li>output (stdout and stderr) go to one single file,</li> <li>there are two possible outcomes: <strong>ok</strong> or <strong>not ok</strong>,</li> </ul> <p>so I opened a <a href="https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14702" rel="nofollow noreferrer">change request</a> on R, proposing something like bit-coding the return status, bit-0 for ERROR (as it is now), bit-1 for WARNING, bit-2 for NOTE. </p> <p>with my modification, it would be easy producing this output:</p> <pre><code>. . * checking for unstated dependencies in tests ... OK * checking tests ... Running ‘doSvUnit.R’ NOTE - please check doSvUnit.Rout. WARNING - please check doSvUnit.Rout. * checking PDF version of manual ... OK </code></pre> <hr> <p>Brian Ripley replied "There are however several packages with properly written unit tests that do signal as required. Please do take this discussion elsewhere: R-bugs is not the place to ask questions." and closed the change request.</p> <hr> <p>anybody has hints?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload