[R-pkg-devel] Is using global assignment in package tests allowed?

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Thu Jan 27 16:20:57 CET 2022


I don't know the answer to your question, but "beyond my ken" doesn't sound like a very convincing reason. Mucking with any environment that isn't yours is asking for trouble... the behavior you depend on today may come into conflict with the code you are coordinating with when you least expect it.

Is your code in a public version control repo?

On January 27, 2022 6:55:49 AM PST, James Pustejovsky <jepusto using gmail.com> wrote:
>Hello,
>
>I'm writing unit tests using testthat for a package that we want to submit
>to CRAN. Because of some aspect of how testthat works (which is beyond my
>ken), I have only been able to get my tests to work by using global
>assignment (<<-) to create some objects on which the tests are then run.
>However, per CRAN policy: "Packages should not modify the global
>environment (user’s workspace)."
>
>Does anyone know whether this policy applies to all code within the
>package, including unit tests? Or does it apply just to the code and
>functions in /R?
>Or to all code that is executed as part of checking the package (i.e., code
>that is never run can use <<-)?
>
>James
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-package-devel using r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-package-devel

-- 
Sent from my phone. Please excuse my brevity.



More information about the R-package-devel mailing list