Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_path() returns incorrect value in context of test_coverage_active_file() #1978

Open
t-kalinowski opened this issue Aug 12, 2024 · 2 comments
Labels
bug an unexpected problem or unintended behavior tests 📘

Comments

@t-kalinowski
Copy link
Member

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.

@jeffkimbrel
Copy link

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"))

@jeffkimbrel
Copy link

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

@hadley hadley added bug an unexpected problem or unintended behavior tests 📘 labels Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior tests 📘
Projects
None yet
Development

No branches or pull requests

3 participants