r-lib/pkgload

Package dependency on testthat seems to be incorrect

atheriel opened this issue · 1 comments

The testthat package is listed as Suggests, but load_all() calls library(testthat):

> pkgload::load_all()
ℹ Loading <my-package>
Error in ("base" %:::% "library")("testthat", warn.conflicts = FALSE) : 
  there is no package calledtestthat> traceback()
3: stop(packageNotFoundError(package, lib.loc, sys.call()))
2: ("base" %:::% "library")("testthat", warn.conflicts = FALSE)
1: pkgload::load_all()

To reproduce:

  1. Uninstall testthat.
  2. Run pkgload::load_all() on any package.

I think this could be fixed by checking if testthat is present beforehand.

A workaround is to call load_all with attach_testthat = FALSE.

However we could probably add a test to uses_testthat() to handle this case as well.