r-lib / vdiffr

Visual regression testing and graphical diffing with testthat
https://vdiffr.r-lib.org
Other
180 stars 31 forks source link

`VDIFFR_RUN_TESTS` environment setting #141

Open jtlandis opened 4 months ago

jtlandis commented 4 months ago

I have an R package that is consistently failing GHA for Linux r: devel. I was trying to follow ggplot2's github actions workflow yaml to skip tests based on the version of r, but for some reason it doesn't seem that any of the tests are skipped. I also did a quick grep in the code and I didn't find any instance of when "VDIFFR_RUN_TESTS" in the code anymore. It seems like it was once apart of the code base, but not anymore

Am I missing something?

jtlandis commented 4 months ago

I can confirm that setting the following in the testthat.R file has helped skip vdiffr tests on CI.

if ((nzchar(Sys.getenv("CI")) ||
     !nzchar(Sys.getenv("NOT_CRAN"))) &&
    identical(Sys.getenv("VDIFFR_RUN_TESTS"), 'false')) {
  #if we are running tests remotely AND
  # we are opting out of using vdiffr
  # assigning a dummy function

  expect_doppelganger <- function(...) {
    testthat::skip("`VDIFFR_RUN_TESTS` set to false on this remote check")
  }
} else {
  expect_doppelganger <- vdiffr::expect_doppelganger
}
gavinsimpson commented 1 month ago

@jtlandis This sounds like it would solve my issue #143 (I didn't realise your issue was related before I submitted mine). Where are you setting the VDIFFR_RUN_TESTS env var?

gavinsimpson commented 1 month ago

Uggh @jtlandis, sorry, I must be having one of those days as I completely missed where you set this in your workflow YAML. I swear I did check before asking 🤦🏻

jtlandis commented 1 month ago

My issue was related to my ggside package. You can find how I have configured this environment variable here

gavinsimpson commented 1 month ago

Thanks @jtlandis; I found where you were doing this, hence my second comment. Your solution was very useful - I have implemented this in several workflows now.