Re: [Rd] CRAN check fails if website is unavailable on Fedora platforms

2020-01-14 Thread Iñaki Ucar
On Tue, 14 Jan 2020 at 15:06, Siegfried Köstlmeier
 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
>   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


[Rd] CRAN check fails if website is unavailable on Fedora platforms

2020-01-14 Thread Siegfried Köstlmeier
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
  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.

 

Best,
skoestlmeier


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel