Reputation: 11409
I am testing an R package called eutradeflows on travis. The package contains test programmed with testthat and I would like to see the output of devtools::test()
in travis.
There was a line in the main travis log saying :
Status: 4 NOTEs
See ‘/home/travis/build/stix-global/eutradeflows/eutradeflows.Rcheck/00check.log’
for details
From this answer, I learned that its possible to display a file in the travis log. In .travis.yml I have asked travis to print that file after the test:
- cat /home/travis/build/stix-global/eutradeflows/eutradeflows.Rcheck/00check.log
But it doesn't contain the result of testthat tests.
How can I display the output of testthat tests in travis?
This is particularly important since I have skip
instructions in the tests and I would like to know which tests have been skipped.
Upvotes: 0
Views: 611
Reputation: 342
I used a slightly heavier weight fix to ensure that build and test only happened once. In the build matrix I put the following in for the script
script: |
R CMD build .
R CMD INSTALL RMINC*.tar.gz
R CMD check --as-cran --no-install RMINC*.tar.gz
cat RMINC.Rcheck/00check.log
Rscript -e "\
testr <- devtools::test(); \
testr <- as.data.frame(testr); \
if(any(testr\$error) || any(testr\$warning > 0)) \
stop('Found failing tests') \
"
pass=$?
if [[ $pass -ne 0 || $(grep -i "WARNING\|ERROR" RMINC.Rcheck/00check.log) != "" ]]; then
(exit 1)
else
(exit 0)
fi
This runs R CMD check and properly displays build output, failing on warnings or errors in either check or test phases.
Upvotes: 0
Reputation: 11409
To display the result of testthat tests,
add this to .travis.yml
:
r_binary_packages:
- devtools
- roxygen2
after_success:
- Rscript -e 'devtools::install();devtools::test()'
Upvotes: 1