Open analyticalmonk opened 8 years ago
Current status: Eliminated ERRORs; reduced multiple WARNINGs to a single one; single NOTE.
About the existing WARNING:
Message being returned:
checking dependencies in R code ... WARNING
Unexported object imported by a ':::' call: ‘testthat:::test_code’
See the note in ?`:::` about the use of this operator.
Background:
The WARNING message has to do with the methodology employed for obtaining the runtime for testthat blocks. Steps employed for doing it (along with examples from code) are:
testthat(
with testthatQuantity(
where the latter is the name of a custom function we will use for measuring the runtime of testthat code blocks. Everything else about the code remains the same. (https://github.com/analyticalmonk/Rperform/blob/master/R/repo_metrics.R#L134)testthatQuantity()
. It takes two parameters, test_name and code. Same as testthat()
. (https://github.com/analyticalmonk/Rperform/blob/master/R/repo_metrics.R#L183-218)testthatQuantity()
, define a function run()
which uses the invisible function testthat:::test_code()
from testthat to run the testthat block. It's different from test_that()
since it allows us to choose the environment in which we want to run the test code. (https://github.com/analyticalmonk/Rperform/blob/master/R/repo_metrics.R#L186-188).testthatQuantity()
, use microbenchmark()
or sys.time()
to obtain the runtime of run()
which in turn provides the runtime of the testthat code block. (https://github.com/analyticalmonk/Rperform/blob/master/R/repo_metrics.R#L193-212)@tdhock The only reason for using test_code()
that I can make out is to evaluate the test in the original environment from which the top-most function (such as time_commit()
in the above case) was called. This is in contrast to the general approach taken the testthat to evaluate tests without affecting the global state. Since you had written the testthatQuantity()
function, can you explain why this approach was required?
A couple more "NOTE"s from running R CMD check --as-cran
:
* checking R code for possible problems ... NOTE
.plot_mem: no visible global function definition for ‘png’
.plot_mem: no visible global function definition for ‘dev.off’
.plot_testMetrics: no visible global function definition for ‘png’
.plot_testMetrics: no visible global function definition for ‘dev.off’
.plot_time: no visible global function definition for ‘png’
.plot_time: no visible global function definition for ‘dev.off’
list_commits: no visible global function definition for ‘as’
plot_metrics: no visible global function definition for
‘capture.output’
Undefined global functions or variables:
as capture.output dev.off png
Consider adding
importFrom("grDevices", "dev.off", "png")
importFrom("methods", "as")
importFrom("utils", "capture.output")
to your NAMESPACE file (and ensure that your DESCRIPTION Imports field
contains 'methods').
* checking Rd files ... NOTE
prepare_Rd: Rperform-package.Rd:31-32: Dropping empty section \examples
The fixes should be evident, but let me know if you have questions. Here's the command I ran:
_R_CHECK_CRAN_INCOMING_=FALSE _R_CHECK_FORCE_SUGGESTS_=FALSE \
R CMD check Rperform_0.0.0.9000.tar.gz --as-cran
My motivation for testthatQuantity
was to copy what was implemented in the testthat
package, but make some modifications that allow measuring the time of each test_that
block.
To avoid that WARNING about :::
you can instead use get
.
For example, instead of
testthat:::test_code()
you can use
test_code <- get("test_code", envir=asNamespace("testthat"))
test_code()
Currently, R CMD check fails. Update and complete documentation, and make other required changes.