-
Notifications
You must be signed in to change notification settings - Fork 115
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
devtools::test(...) passes but tests fail in covr::package_coverage(...) #487
Comments
covr runs its tests with The first thing to do is see if you have the same failures using In terms of constructing paths in your tests the best practice is to rely on |
Thanks for the quick reply! I'm currently also looking into the |
By now I am at a point where |
If you are talking about hechth/recetox-xMSannotator@9b770b5 I still get test failures with e.g.
I can't really help you further until I can run the tests cleanly on my machine. |
Yes, the most recent commit in which I changed the tests is here: hechth/recetox-xMSannotator@71b5854. On my machine it now all passes, also the codecov works since I altered the test condition a bit. In the refactoring I did some changes which apparently cause few rows in the output dataframes to be different, but it seems to be minor. The rather interesting behaviour is that the differences are different, depending on whether I run |
@jimhester I'm again at a point where Thank you so much for the time and support, I really appreciate it and it helps me a lot in making our code better and cleaner :) |
There are a number of different potential issues, hadley/r-pkgs#483 documents some of them. Again I tried running your package (hechth/recetox-xMSannotator@3820ca3) tests and check locally and ran into failures with both. You might try pulling the GitHub repo into a new directory and verifying the tests work on your machine afterwards. I could probably diagnose the issue pretty quickly if I can run the tests myself. |
@jimhester you need to fetch the test data (it is quite something, so we moved it to a different repo (should be publicly readable, just copy the content of the testdata/recetox-xMSannotator folder to the testdata folder in the repo. On my machine (as well as a dev server), the tests using Thank you so much for the help, I'll look into the issues you provided. |
I guess I have a similar issue with my package {bigsnpr}.
Could this be an issue with some outdated cache used by {covr}? |
I have ran into this issue with one of my packages, cpr. I think it might have something to do with reading .rds files within a test, or rather, from where the .rds files are read. Tests in version 03b0898 will pass locally and on several other OS and R versions, see the logs for the github actions R-CMD-check and test-coverage. In this version, there are two .rds files in the tests/testthat directory which are read during the evaluation of the tests. The coverage and one of the runners fail due to testing. On the next commit, d1024f7, the tests tests/testthat/test-cpr.R and test/testthat/test-cnr.R were commented out and the R-CMD check and code coverage do not error. Finally, on commit ce5021f I moved one of the .rds files from test/testthat/ to inst/example_objects and changed the what the testing script reads in the .rds file to use From these steps it seems like the file location might be part of the cause for the different behavior between checks, tests, and covr. |
Thanks for reporting your solution @dewittpe. In the test file that fails in the coverage, I do read RDS files, but they are all located in |
@privefl -- I have run into the same again. test-coverage and R-CMD-check failed when I needed to read in a larger .rds file. I'm rethinking my testing objectives and writing out several smaller specific tests instead of the original idea of checking for equality with a large object. I'm at a bit of a loss here too. Some OS/R-version combinations work, some don't, and between the two github actions it appears that there is some inconsistency in behavior reading in the .rds files. |
@dewittpe the tests in the project I mentioned above also involved comparisons of rather large files stored as .rds on disk, so there seems to be something in common. |
I have the same issue, but not using any .rds test files. It fails for normal code, which might help pinpointing the problem. This is the repository: Right now, all of library(declared)
library(testthat)
devtools::load_all()
test_that("tagged values work", {
expect_true(hasTag_(makeTag_("-a"), "-a"))
expect_true(hasTag_(makeTag_("-ab"), "-ab"))
})
# Test passed 🎉 This passes well at the command line, but as soon as I put this test in covr::package_coverage()
# Error: Failure in `/private/var/folders/43/n9gyx1_n6llbb4ds7tflndc40000gn/T/Rtmp6LwsHQ/R_LIBS81d6c63576f/declared/declared-tests/testthat.Rout.fail`
# f/declared/declared-tests/testthat/test-internals.R�test-internals.R:284:5): tagged values work ────────────────────────
# hasTag_(makeTag_("-a"), "-a") is not TRUE
#
# `actual`: FALSE
# `expected`: TRUE
# ── Failure (test-internals.R:285:5): tagged values work ────────────────────────
# hasTag_(makeTag_("-ab"), "-ab") is not TRUE
#
# `actual`: FALSE
# `expected`: TRUE
#
# [ FAIL 2 | WARN 0 | SKIP 0 | PASS 393 ]
# Error: Test failures
# Execution halted |
For the small ask package I see a similar issue, without .rds files in test files.
Stepping through Running in the main package directory, this gives
but this passes (
I got stuck here, as simply replacing
Hope this helps to isolate issues |
@D-Se This issue seems to have become a dumping ground for disparate issues, so I am going to close it. |
Yeah - I think the main reason by now for the difference is (as was already mentioned) that |
Sorry to dig up this old issue, but I'm facing the same problem but with a snapshot test. Here's the relevant code:
works with
but when I look at the snapshots, or try |
Running my tests of recetox-xMSannotator using
devtools::test()
works completely fine, but callingcovr::package_coverage()
fails in finding local test data.Could it be that some working directories are changed during the coverage measurement?
The text was updated successfully, but these errors were encountered: