`test_path()` returns incorrect value in context of `test_coverage_active_file()`
Encountered in pkg-dev workshop at posit::conf(2024)
Also, @jennybc in slack reports:
in related news, I found that you can't do test_coverage_active_file() if you haven't already installed the package properly once. I'm not sure that's a bug? But I suspect it is.
I see (what I suspect to be) a similar problem, but the package is installed. I have some test fixtures in tests/testthat/fixtures and running test_path inside of a test works for test_active_file(), but not for test_coverage_active_file(). It appears test_path is looking directly in fixtures/ rather than tests/testthat/fixtures/, but I'm not sure.
Regular old test() and test_coverage() work fine... just not test_coverage_active_file().
> test_active_file()
[ FAIL 0 | WARN 0 | SKIP 0 | PASS 2 ]
> test_coverage_active_file()
Error in gzfile(file, "rb") : cannot open the connection
In addition: Warning message:
In gzfile(file, "rb") :
cannot open compressed file 'fixtures/XXX.rds', probable reason 'No such file or directory'
First line of test file...
XXX <- readRDS(test_path("fixtures", "XXX.rds"))
It looks like these functions are actually in devtools, not testthat... but does it come down to these two lines where test_active_file() is using path_dir(test_files)[[1]] where test_coverage_active_file() is using path_dir(test_files)?
https://github.com/r-lib/devtools/blob/6ec478bbb26645c6fda6d1c518b27e7f478fc91e/R/test.R#L63
https://github.com/r-lib/devtools/blob/6ec478bbb26645c6fda6d1c518b27e7f478fc91e/R/test.R#L131