Closed llrs closed 6 years ago
the script is using test_dir
which by default has stop_on_failure = FALSE
. it may be the covr
call
fo the time being the i would suggest moving to expect_error
in the testthat
call until you fix your code and then once it runs switch to an affirmative test.
@llrs this works now on the skip branch, you can test it out on a package you have. cc @dpastoor, @jimhester.
@yonicd thanks for the new branch. I tried and it comments a single line (the one producing the data to be tested) but not the failing test (or the expect_that
line). Also the final report is not generated see below for details:
The error I get on the console:
> covrpage()
processing file: _covrpage.Rmd
|.... | 6%
inline R code fragments
|........ | 12%
label: unnamed-chunk-1 (with options)
List of 1
$ include: logi FALSE
|........... | 18%
ordinary text without R code
|............... | 24%
label: unnamed-chunk-2 (with options)
List of 1
$ include: logi FALSE
|................... | 29%
ordinary text without R code
|....................... | 35%
label: unnamed-chunk-3 (with options)
List of 1
$ include: logi FALSE
|........................... | 41%
ordinary text without R code
|............................... | 47%
label: unnamed-chunk-4 (with options)
List of 1
$ include: logi FALSE
|.................................. | 53%
ordinary text without R code
|...................................... | 59%
label: unnamed-chunk-5 (with options)
List of 1
$ echo: logi FALSE
Quitting from lines 52-77 (_covrpage.Rmd)
Error: Failure in `/tmp/RtmpNDFpvL/R_LIBS5d7c37dbca90/GSEAdv/GSEAdv-tests/testthat.Rout.fail`
On that file, after starting R and loading the package the output ends with:
>
> test_check("GSEAdv")
[31mββ[39m [31m1. Error: keepGPP works (@test_keeps.R#9) [39m [31mββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ[39m
object 'out' not found
1: expect_equal(ncol(out), 5L) at testthat/test_keeps.R:9
2: quasi_label(enquo(object), label)
3: eval_bare(get_expr(quo), get_env(quo))
4: ncol(out)
ββ testthat results βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
OK: 183 SKIPPED: 1 FAILED: 1
1. Error: keepGPP works (@test_keeps.R#9)
Error: testthat unit tests failed
Execution halted
The relevant lines on that file are here:
test_that("keepGPP works", {
# out <- keepGPP(Info)
expect_equal(ncol(out), 5L)
})
The commented line was introduced by covrpage, but then the expect is failing, as it can't find the out object
The intent was to have the expectation fail, you are missing there a global variable βoutβ it is crashing for a different reason I think. Try replacing 5L with 6L.
I don't understand the comment. Why I'm missing there a global variable 'out'? Initially it wasn't commented in the test_that call, and after running the covrpage it got commented. (Doing rm(out); covrpage()
resulted in the same output)
I on purpose changed the expectation in order to fail the test, if I change it back to 6L
it will pass and it won't test if the branch works when a test is failing.
You misunderstood me. I meant to keep it a vaild expectation test, i did not know it was 6 before you changed it. My suggestion is to keep the out object in the environment but have it try to check against something wrong on purpose. Removing out make little sense practically in a normal test file. Usually you would have out be created but with wrong dimensions and catching that error.
That is what I did initially, and still the covrpage function failed to generate the report (despite using the skip branch)
Ok. Can you paste the Rout.fail lines so I can see why it is failing.
It is what I originally posted on the last block of code on my first comment after you pinged me.
>
> test_check("GSEAdv")
οΏ½[31mββοΏ½[39m οΏ½[31m1. Error: keepGPP works (@test_keeps.R#9) οΏ½[39m οΏ½[31mββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββοΏ½[39m
object 'out' not found
1: expect_equal(ncol(out), 5L) at testthat/test_keeps.R:9
2: quasi_label(enquo(object), label)
3: eval_bare(get_expr(quo), get_env(quo))
4: ncol(out)
ββ testthat results βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
OK: 183 SKIPPED: 1 FAILED: 1
1. Error: keepGPP works (@test_keeps.R#9)
Error: testthat unit tests failed
Execution halted
That is saying out is missing. Can you rerun wo commenting out that line in the test?
test_that("keepGPP works", { out <- keepGPP(Info) expect_equal(ncol(out), 5L) })
Yes, it says that it is missing because it gets commented when I run covrpage.
When I cleaned the session and redid the covrpage again, I got some other test commented and then a failing test in another archive. These branch comments my test at its will, and some of them are test that pass.
Ah, ok. So the way this works is to
run testthat locate failed tests comment out the lines run covr uncomment the lines
The tests are mapped out using covrpage::map_testthat()
Try seeing that the lines are being mapped correctly to that test. It seemed to work ok on my end.
ok. try again (repull). I noticed that i wrote map_test
for files that have full namespacing for all function calls ie testthat::test_that
and most of the time users will have just test_that
which creates a bit of a different logic in the parser. This is what caused the seemingly random commenting of your file.
now the mapping should work for both types of inputs.
thanks for being the tester for this.
I installed from the latest version of the branch, but I got the same error: Error: Failure in
in the file I found that the failing test is failing and nothing else (as previously happened, but now without random commenting):
ββ testthat results ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
OK: 185 SKIPPED: 1 FAILED: 1
1. Failure: keepGPP works (@test_keeps.R#9)
Error: testthat unit tests failed
Execution halted
errr... what is the GH url of the repo are you testing? testthat should be failing that is the point, but covr should be running ok, ignoring that test.
I am using :
covrpage * 0.0.51 2018-08-26 Github (yonicd/covrpage@b4a47d2)
testthat * 2.0.0 2017-12-13 CRAN (R 3.5.0)
my mistake. i didnt return the mapping directory to the right place. I also added some functionality that the function will cleanup itself all the commenting, even if it crashing during the covr build.
try again (hopefully the last time)
No, I get the same error "yonicd/covrpage@111cb6b", it only adds a new line at the end of a test I have
Are you testing covrpage or your package?
i have tried it on a few repos i checked out that i can manipulate the tests. for example @jonocarroll hosts ggeasy. I changed line 43 in test_labs to throw an error.
I run the new function in the root repo directory. It is acting as expected.
> covrpage::coverage_skip(test_path = 'tests/testthat')
β | OK F W S | Context
β | 3 1 | attr labs
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
test-labs.R:43: failure: regular labs pass new labels through easy_labs
`easy_res` not equal to `hard_res`.
Component βlabelsβ: Component βtitleβ: 1 string mismatch
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β | 9 | remove legend [0.2 s]
β | 9 | remove axes [0.2 s]
ββ Results βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Duration: 0.5 s
OK: 21
Failed: 1
Warnings: 0
Skipped: 0
No-one is perfect!
ggeasy Coverage: 84.21%
R/axis.R: 55.88%
R/labs.R: 95.00%
R/legend.R: 100.00%
Oh, sorry I was trying the covrpage
not the covrpage_skip
function.
When I try the covrpage_skip function on my package, I see some errors could not find function "condPerPathways"
(those are S4 methods not functions), then it outputs:
ββ Terminating early ββββββββββββββββββββββββββββββββββββββββββββββββββ
Too many failures
but on the linked file I have has the same error:
ββ testthat results βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
OK: 149 SKIPPED: 9 FAILED: 1
1. Failure: keepGPP works (@test_keeps.R#9)
Error: testthat unit tests failed
Execution halted
no worries, i added coverage_skip
in the last few commits. It can be used as a more direct way to test covr
with failing tests. It could be that testthat
aborts when it reaches a threshold of failing tests.
a small caveat to coverage_skip
is that it needs to run from the root directory of the package that it is testing (unlike covrpage
that can be run with relational paths)
do the tests work in a regular context without force failing them?
Hey,
The function seems to fail if you simply do covrpage::coverage_skip(test_path = "tests/")
but works when I run covrpage::coverage_skip(test_path = "tests/testthat/")
.
I changed to default path of coverage_skip
to tests/testthat to make it a more natural run by default. https://github.com/yonicd/covrpage/commit/05a5814d57071192eec2143fed019769e9ead0b7
@yonicd Yes, When I change back to the right value the devtools::test
(using Rstudio) works as well as the covrpage::covrpage
while covrpage::coverage_skip()
fails.
Many thanks for your long and continued effort to solve this issue!
what test path are you setting in the coverage_skip call and what directory are you running it from?
I am using covrpage::coverage_skip(test_path = "tests/testthat/")
on the root of the package.
I get
ββ Terminating early βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Too many failures
GSEAdv Coverage: 77.33%
R/completness.R: 0.00%
R/expand.R: 0.00%
R/summary.R: 0.00%
R/pathwaysPerGene.R: 14.29%
R/calc-nPathways.R: 33.33%
R/simulateGSC.R: 36.30%
R/check-GSC.R: 59.52%
R/keep.R: 72.00%
R/simulate2GSC.R: 78.38%
R/fromSizeGenes_sizePathways.R: 78.57%
R/as_GeneSetCollection.R: 83.33%
R/sizesPer.R: 86.11%
R/AllGenerics.R: 90.24%
R/genesPerGene.R: 90.32%
R/cond.R: 90.91%
R/fromSizePathways.R: 92.50%
R/add.R: 92.59%
R/pathway.R: 94.64%
R/remove.R: 95.65%
R/nested.R: 97.14%
R/duplicated.R: 100.00%
R/estimate_sizes.R: 100.00%
R/fromSizeGenes.R: 100.00%
R/gene.R: 100.00%
R/genesPerPathway.R: 100.00%
R/modify.R: 100.00%
R/n_functions.R: 100.00%
R/sizes.R: 100.00%
R/utilities.R: 100.00%
R/zzz.R: 100.00%
When the test is set to pass, and it fails when a test fails.
is your package on a github repo that i can clone and test?
Yes, it is llrs/GSEAdv. Although the specific test file is a new one I created and I haven't pushed yet (I can't in my current network), and as it is on github it doesn't pass the R CMD check
. I will be able to push changes by Friday.
Let me know if I have to do something.
ok. i'll check back in on Friday to test the commit. I have had a few other people test out the current build of coverage_skip and it seems to work for them.
@yonicd I updated the package in llrs/GSEAdv, the file I change to check the function covrpage is the test on tests/testthat/test_keeps.R
. Let me know if you need the sessionInfo of my setup or something.
By the way, I would like to propose this package to check Bioconductor's packages in their severs. But they only accept packages available on CRAN. Do you plan to submit it on CRAN?
i will check why it is failing on that repo.
I am planning on submitting to CRAN when I get a chance.
thanks!
> biocLite("GSEAdv")
BioC_mirror: https://bioconductor.org
Using Bioconductor 3.7 (BiocInstaller 1.30.0), R 3.5.1 (2018-07-02).
Installing package(s) βGSEAdvβ
Old packages: 'digest', 'tinytex', 'batchtools', 'broom', 'callr', 'dbplyr',
'devtools', 'energy', 'fansi', 'foreign', 'fs', 'ggplotify', 'ggtern', 'haven',
'huxtable', 'later', 'leaflet', 'officer', 'openssl', 'pander', 'pkgconfig',
'plotly', 'processx', 'RcppArmadillo', 'reticulate', 'rlang', 'roxygen2', 'scales',
'sinew', 'streamR', 'subprocess', 'survival', 'sys', 'texPreview', 'usethis',
'XML', 'xtable'
Update all/some/none? [a/s/n]:
n
Warning message:
package βGSEAdvβ is not available (for R version 3.5.1)
Yes, the GSEAdv package is not yet on Bioconductor, that's why that code block was commented. Install it from github using remotes or devtools if you want.
seems ok on my end.
fork of your repo: https://github.com/yonicd/GSEAdv
Yes, on that commit there isn't any test failing. The problems are when doing test driven development: when I first make a test and the function or method fails a test, covrpage doesn't build the tests/README.md
There are failing tests in that commit
The covrpage report says that there are some errors, but the CI reports that all the test are passing, and the covr report is generated.
In my local machine all the test are OK, there's only one test skipped, but it pass the R CMD check.
Not sure I follow.
covrpage (which is local): 3 errors + 1 fail ci: no errors + no fails local: no errors + no fails + 1 skip
how are you running local tests? devtools::test
or testthat::test_dir
or testthat::test_check
?
this is getting farther from the original issue. maybe for the sake of length i'll close this one and you can open a fresh one with the updated problem.
I was running the tests with devtools::test
using Rstudio. I'll open a new issue then.
I was trying the package in another package where I still have some failing test (work in progress..). Could it be possible to generate the page even if a test failed?
I think it uses
test_check
(in case of using testthat), which has the argument ofstop_on_failure
set to TRUE by default. Changingstop_on_failure
to FALSE would solve the issue, but maybe there is a reason behind this.