r-lib / rlang

Low-level API for programming with R
https://rlang.r-lib.org
Other
502 stars 140 forks source link

Should `check_installed()` skip tests instead of error? #1658

Open olivroy opened 11 months ago

olivroy commented 11 months ago

If check_installed() is called in tests, we would get an error (non-interactive sessions)

But could there be an option to skip the test instead?

Thanks

Edit: I mean when one of the packages is not installed!

Example in https://github.com/cynkra/dm/pull/2040#issuecomment-1765366534

krlmlr commented 11 months ago

How is that different from the behavior we have today?

krlmlr commented 11 months ago

Wrong repo 🤦

For context: in dm, we have a wrapper around check_installed() that first calls is_installed() and (only in tests) calls skip() with an appropriate error message. This means that we almost never need to call skip_if_not_installed() in tests. Because we also test with every weak dependency missing, in a matrix, this also checks for us if our user-facing code has appropriate checks.

https://github.com/cynkra/dm/blob/main/R/check_suggested.R