On Tue, 14 Jan 2020 at 15:06, Siegfried Köstlmeier <siegfried.koestlme...@gmail.com> wrote: > > Hi all, > > I maintain the package „qrandom“ which is based on a web API. In last time > the testthat tests failed because the website was down. > I implemented the following code in v1.2.2 to ensure that tests are only run > if the website is accessible and to avoid the CRAN checks to fail: > > > library(testthat) > > library(qrandom) > > > check_qrng <- function(){ > > tryCatch( > > expr = { > > req <- curl::curl_fetch_memory('https://qrng.anu.edu.au/index.php') > > req$status_code > > }, > > error = function(e){ > > -1 > > } > > ) > > } > > > ## test package separated with filter due to limited Travis-CI build time > > ## HTTP status 200 indicates “OK” > > if(curl::has_internet() & check_qrng() == 200){ > > test_check('qrandom', filter = "qrandom") > > test_check('qrandom', filter = "qrandomunif") > > test_check('qrandom', filter = "qrandomnorm") > > test_check('qrandom', filter = "qUUID") > > test_check('qrandom', filter = "qrandommaxint") > > } > > I was informed that the check results > <https://cran.r-project.org/web/checks/check_results_qrandom.html> had an > error status for both flavor r-devel-linux-x86_64-fedora-clang and > r-devel-linux-x86_64-fedora-gcc, while the other platforms showed the status > “OK”. Currently, the status is “OK” for all updated package versions 1.2.2 > because the website is available again. > > What is it that the above code does not prevent the checks to be run if the > website is not available specifically on Fedora systems? May it be that curl > is platform dependent or are CRAN package checks run different here? I would > be pleased to avoid these check fails in future.
Since you use testthat, you can use skip_on_cran() to skip tests that require an Internet connection. Yet it would be a better idea to mock those tests on CRAN (see packages vcr, webmockr, httptest, and probably others). Iñaki ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel