[R-pkg-devel] Problem passing noSuggests test
Jon Olav Skoien
jon@@ko|en @end|ng |rom gm@||@com
Fri Aug 1 17:48:25 CEST 2025
Thank you for all answers!
I agree that adopting a testing framework would be a better approach
for future packages. However, as this particular package is not under
active development, I was particularly looking for solutions that
required less modifications of the current code.
And from the answers and the code in the MASS-example, it seems the
most straightforward fix in my particular case is to replace the print
statements with stopifnot(all.equal(...)). The suggested package
should in my case not produce different output than the original
package, it just offers a different way of computing the same result
when the two of them interact correctly. While I will not use the
.rout.save modification examples here, they could be useful for other
scenarios and for others who encounter this thread in the future.
Thanks and best wishes,
Jon
On Fri, 1 Aug 2025 at 16:39, Michael Chirico <michaelchirico4 using gmail.com> wrote:
>
> I would emphasize/paraphrase Ivan's point -- using goldens (.Rout.save) for such tests is quite a headache. We do so for a very limited number of tests in {data.table} (something like 10 tests of over 10,000).
>
> You could instead change the tests of Suggests behavior to be based on expectations, be that a framework like {testthat}/{RUnit}/{assertthat} or just the built-in tooling like stopifnot(), where you just quit/skip the checks when Suggests are unavailable.
>
> Of course if you have a strong affinity for golden tests you can just split things into multiple test files. If it is a huge pain to disentangle which tests rely on Suggests behavior, that is a decent sign to me that maybe that package is not Suggests after all.
>
> Mike C
>
> On Fri, Aug 1, 2025, 7:29 AM Sebastian Meyer <seb.meyer using fau.de> wrote:
>>
>> Am 31.07.25 um 11:09 schrieb Jon Olav Skoien:
>> > Is there a different way of conditionally
>> > using the suggested package? Or do I have to use the IGNORE_RDIFF
>> > method?
>>
>> To use *reference output* for optional tests, you could move these tests
>> to a dedicated script with a corresponding .Rout.save file, put the
>> files in a tests/ subdirectory, and use an .Rin file to include them
>> only if the suggested package is available. I implemented a similar
>> approach in the 'nlme' package to run extra tests with reference output
>> conditionally on an environment variable, see
>> <https://svn.r-project.org/R-packages/trunk/nlme/tests/extras.Rin> for
>> inspiration.
>>
>> --
>> Sebastian Meyer
>>
>> ______________________________________________
>> R-package-devel using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
More information about the R-package-devel
mailing list