CRAN check fails if website is unavailable on Fedora platforms

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

CRAN check fails if website is unavailable on Fedora platforms

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
<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.

 

Best,
skoestlmeier


        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

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

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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel