From a7ecb1a22711cad41cb08321e388044a1f5d08d0 Mon Sep 17 00:00:00 2001 From: Hiroaki Yutani Date: Sun, 6 Sep 2020 16:02:42 +0900 Subject: [PATCH 1/6] Skip visual tests when vdiffr is not available --- tests/testthat/helper-vdiffr.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/testthat/helper-vdiffr.R b/tests/testthat/helper-vdiffr.R index 77f38e3155..50aa9a4858 100644 --- a/tests/testthat/helper-vdiffr.R +++ b/tests/testthat/helper-vdiffr.R @@ -2,4 +2,9 @@ # - VDIFFR_RUN_TESTS is "false" (on Travis CI with older versions and dev version of R) # - CI is not set (on CRAN) -expect_doppelganger <- vdiffr::expect_doppelganger +if (requireNamespace("vdiffr", quietly = TRUE)) { + expect_doppelganger <- vdiffr::expect_doppelganger +} else { + # If vdiffr is not available, assign a dummy function + expect_doppelganger <- function(...) skip("vdiffr is not installed.") +} From 1a6588b6bc635cd3b6ed0fb5a726580beb0e7662 Mon Sep 17 00:00:00 2001 From: Hiroaki Yutani Date: Sun, 6 Sep 2020 16:03:05 +0900 Subject: [PATCH 2/6] Add tweak to skip ggsave tests --- tests/testthat/test-ggsave.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/testthat/test-ggsave.R b/tests/testthat/test-ggsave.R index 4a4fbe0667..bfd314698a 100644 --- a/tests/testthat/test-ggsave.R +++ b/tests/testthat/test-ggsave.R @@ -29,6 +29,10 @@ test_that("ggsave restores previous graphics device", { }) test_that("ggsave uses theme background as image background", { + # FIXME: This should check svglite, but, at the time of writing this, there's already a binary + # package of svglite, and it can be installed even the dependency is not available, surprisingly... + skip_if_not_installed("systemfonts") + path <- tempfile() on.exit(unlink(path)) p <- ggplot(mtcars, aes(disp, mpg)) + From dcf5a4ec679f5d341603a520a7caa6c8407ff740 Mon Sep 17 00:00:00 2001 From: Hiroaki Yutani Date: Sun, 6 Sep 2020 16:03:54 +0900 Subject: [PATCH 3/6] Update CMD-ckeck.yml --- .github/workflows/R-CMD-check.yaml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 3236acc8b2..f318c21d48 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -24,17 +24,17 @@ jobs: config: - {os: windows-latest, r: '4.0', vdiffr: true, xref: true} - {os: macOS-latest, r: '4.0', vdiffr: true, xref: true} - - {os: ubuntu-16.04, r: 'devel', vdiffr: false, xref: true, cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '4.0', vdiffr: true, xref: true, cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.6', vdiffr: false, xref: true, cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.5', vdiffr: false, xref: true, cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.4', vdiffr: false, xref: true, cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.3', vdiffr: false, xref: true, cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"} - - {os: ubuntu-16.04, r: '3.2', vdiffr: false, xref: false, cran: "https://demo.rstudiopm.com/all/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: 'devel', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest", http-user-agent: "R/4.0.0 (ubuntu-16.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions"} + - {os: ubuntu-16.04, r: '4.0', vdiffr: true, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '3.6', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '3.5', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '3.4', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '3.3', vdiffr: false, xref: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '3.2', vdiffr: false, xref: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - CRAN: ${{ matrix.config.cran }} + RSPM: ${{ matrix.config.rspm }} # don't treat missing suggested packages as error _R_CHECK_FORCE_SUGGESTS_: false # Some packages might unavailable on the older versions, so let's ignore xref warnings @@ -68,12 +68,11 @@ jobs: - name: Install system dependencies on Linux if: runner.os == 'Linux' - env: - RHUB_PLATFORM: linux-x86_64-ubuntu-gcc run: | - Rscript -e "remotes::install_github('r-hub/sysreqs')" - sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))") - sudo -s eval "$sysreqs" + while read -r cmd + do + eval sudo $cmd + done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "16.04"))') - name: Install system dependencies on macOS if: runner.os == 'macOS' From 00234d913e8d979ea4670c6d19b156ab14bc8ae9 Mon Sep 17 00:00:00 2001 From: Hiroaki Yutani Date: Sun, 6 Sep 2020 16:10:58 +0900 Subject: [PATCH 4/6] Add http-user-agent --- .github/workflows/R-CMD-check.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index f318c21d48..438d6c3ac1 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -49,6 +49,7 @@ jobs: - uses: r-lib/actions/setup-r@master with: r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} - uses: r-lib/actions/setup-pandoc@master From c789bf66402b9a38525753d1b61d4326d60935ad Mon Sep 17 00:00:00 2001 From: Hiroaki Yutani Date: Sun, 6 Sep 2020 16:15:14 +0900 Subject: [PATCH 5/6] Fix a comment --- tests/testthat/test-ggsave.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-ggsave.R b/tests/testthat/test-ggsave.R index bfd314698a..6d60439686 100644 --- a/tests/testthat/test-ggsave.R +++ b/tests/testthat/test-ggsave.R @@ -30,7 +30,7 @@ test_that("ggsave restores previous graphics device", { test_that("ggsave uses theme background as image background", { # FIXME: This should check svglite, but, at the time of writing this, there's already a binary - # package of svglite, and it can be installed even the dependency is not available, surprisingly... + # package of svglite, and it can be installed even if the dependency is not available, surprisingly... skip_if_not_installed("systemfonts") path <- tempfile() From 83356074fbac212bbc34d881f40d27d086583fae Mon Sep 17 00:00:00 2001 From: Hiroaki Yutani Date: Sun, 6 Sep 2020 16:35:04 +0900 Subject: [PATCH 6/6] Require vdiffr except when it's explicitly disabled --- tests/testthat/helper-vdiffr.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/testthat/helper-vdiffr.R b/tests/testthat/helper-vdiffr.R index 50aa9a4858..bf132c875e 100644 --- a/tests/testthat/helper-vdiffr.R +++ b/tests/testthat/helper-vdiffr.R @@ -5,6 +5,11 @@ if (requireNamespace("vdiffr", quietly = TRUE)) { expect_doppelganger <- vdiffr::expect_doppelganger } else { - # If vdiffr is not available, assign a dummy function + # If vdiffr is not available and visual tests are not explicitly disabled, raise error. + if (!identical(Sys.getenv("VDIFFR_RUN_TESTS"), "false")) { + abort("vdiffr is not installed") + } + + # Otherwise, assign a dummy function expect_doppelganger <- function(...) skip("vdiffr is not installed.") }