rappdirs icon indicating copy to clipboard operation
rappdirs copied to clipboard

Switch test expect_snapshot to explicit expect_warning

Open vejnar opened this issue 1 year ago • 5 comments

Problem: In recent R versions (not sure when it changed), the format of warnings has changed making the snapshot _snaps/utils.md incorrect and the test to fail.

This PR switches the test to explicit expect_warning to catch the warning and then expect_equal. This way it should pass with any R version.

Please comment or merge.

vejnar avatar Nov 26 '23 23:11 vejnar

making the snapshot _snaps/utils.md incorrect and the test to fail.

It does not fail for me, on R-4.3.2 or R-devel. OTOH testthat has changed the output slightly, try updating testthat.

gaborcsardi avatar Nov 27 '23 00:11 gaborcsardi

I am using testthat 3.2.0 and R 4.3.2 and it fails.

I am thinking it would be better to have more explicit tests, ie not relying on specific output formatting, as proposed in this PR so tests are passing with any versions, past or present.

vejnar avatar Nov 27 '23 00:11 vejnar

Since we rely on snapshot tests a lot, it is important to understand why it fails for you if it does not on any of our CI platforms. What is your platform?

gaborcsardi avatar Nov 27 '23 01:11 gaborcsardi

I am on Archlinux. I am building packages using the AUR for all R packages.

vejnar avatar Nov 27 '23 01:11 vejnar

If you are running R CMD check, then the snapshot test failures are ignored by default, so it should not be a problem.

But I actually reproduce the failure on Archlinux:

FROM archlinux:latest
WORKDIR /root
RUN pacman -Sy --noconfirm r gcc which git make
RUN git clone https://github.com/r-lib/rappdirs.git
RUN R -q -e 'source("https://pak.r-lib.org/install.R")'
WORKDIR /root/rappdirs
RUN R -q -e 'pak::pkg_install("testthat")'
RUN R -q -e 'testthat::test_local()'

gaborcsardi avatar Nov 27 '23 08:11 gaborcsardi