[R-pkg-devel] Problem passing noSuggests test
Ivan Krylov
|kry|ov @end|ng |rom d|@root@org
Fri Aug 1 16:01:51 CEST 2025
В Thu, 31 Jul 2025 11:09:39 +0200
Jon Olav Skoien <jon.skoien using gmail.com> пишет:
> From what I understood, a solution is to wrap this part of the code
> inside if (require("suggestedPackage")) {useSuggestedPackage}
Correct! (requireNamespace(...) is also a good option if you don't
intend to use the package directly and are instead testing your
package's internal use of its optional dependency.)
> However, it still fails the noSuggests test, this time because the
> output does not match the test.Rout.save-file. This is also clear, as
> some of the code is not executed, and some output is missing.
There may be no good solution for "reference output" tests when some of
their dependencies are optional. Without bringing in a test framework,
I've only seen kludges, such as the test printing reference output when
the optional dependency is missing:
https://github.com/Rdatatable/data.table/blob/8039a230b0ebbcc8ca9ea86e84d7c378e00b9d51/tests/knitr.R#L2-L3
I wouldn't call it a beautiful solution, but it does work.
--
Best regards,
Ivan
More information about the R-package-devel
mailing list