IQSS / dataverse-client-r

R Client for Dataverse Repositories
https://iqss.github.io/dataverse-client-r
61 stars 24 forks source link

Add `testthat::skip_if_offline()` before most tests #77

Closed wibeasley closed 3 years ago

wibeasley commented 3 years ago

There's a problem on the daily CRAN checks when run on Solaris. I need to

Below is the warning from the CRAN team. Here is a link to the live version of the checks, which updated daily: https://cran.r-project.org/web/checks/check_results_dataverse.html

One of the 24 failures.

  ── Error (tests-dataset_files.R:5:3): download tab from DOI and filename ───────
  Error: SSL certificate problem: certificate has expired
  Backtrace:
      █
   1. └─dataverse::get_dataverse("dataverse-client-r") tests-dataset_files.R:5:2
   2. ├─dataverse:::dataverse_id(...)
   3. └─dataverse:::dataverse_id.character(...)
   4. └─dataverse::get_dataverse(x, ..., check = FALSE)
   5. └─httr::GET(u, httr::add_headers(`X-Dataverse-key` = key), ...)
   6. └─httr:::request_perform(req, hu$handle$handle)
   7. ├─httr:::request_fetch(req$output, req$url, handle)
   8. └─httr:::request_fetch.write_memory(req$output, req$url, handle)
   9. └─curl::curl_fetch_memory(url, handle = handle)
  ── Error (tests-dataset_metadata.R:5:3): download tab from DOI and filename ────

Prof Brian Ripley Tue 1/19/2021 10:22 AM Dear maintainer,

Please see the problems shown on https://cran.r-project.org/web/checks/check_results_dataverse.html.

Please correct before 2021-02-02 to safely retain your package on CRAN.

It seems we need to remind you of the CRAN policy:

'Packages which use Internet resources should fail gracefully with an informative message if the resource is not available or has changed (and not give a check warning nor error).'

This needs correction whether or not the resource recovers.

The CRAN Team


Here are some useful resources I've read

  1. https://books.ropensci.org/http-testing/graceful.html#graceful
  2. https://books.ropensci.org/http-testing/cran-preparedness.html
  3. https://testthat.r-lib.org/reference/skip.html
  4. https://community.rstudio.com/t/internet-resources-should-fail-gracefully/49199
kuriwaki commented 3 years ago

Why would skip_if_offline() solve this Solaris error though?

Possibly relevant re certification: https://github.com/IQSS/dataverse-client-r/issues/83#issuecomment-781471353

wibeasley commented 3 years ago

@kuriwaki, my guess is 'yes', because if it can't reach the server (because of SSL or any other reason), the rest of the test is avoided. We'll find out I guess.

It's kinda cheating, but I see skip_on_os("solaris") is an option if we get desperate and can't debug it effectively.

https://github.com/r-lib/testthat/blob/master/R/skip.R#L117

https://testthat.r-lib.org/reference/skip.html