r-lib / devtools

Tools to make an R developer's life easier
https://devtools.r-lib.org
Other
2.37k stars 755 forks source link

`run_examples()` fails if `tests/testthat/helper.R` contains an un-exported function #2559

Closed olivroy closed 4 months ago

olivroy commented 4 months ago

You can test this out with usethis.

Its file tests/testthat/helper.R contains proj_find() which is an internal function.

devtools::run_examples(pkg = "~/Documents/rrr-forks/usethis/")
#> ℹ Updating usethis documentation
#> ℹ Loading usethis
#> ── Running 91 example files ───────────────────────────────────────── usethis ──
#> ℹ Loading usethis
#> Error in `FUN()`:
#> ! In path: "~/rrr-forks/usethis/tests/testthat/helper.R"
#> Caused by error in `proj_find()`:
#> ! could not find function "proj_find"

In the backtrace, I see

  8.           └─testthat::source_dir(path, "^helper.*\\.[rR]$", env = env, wrap = FALSE)

Note that usethis:::proj_find() makes it work.