[R-pkg-team] Bug#1103994: dh-make-R: 'generic' runner runs testthat tests from wrong directory, failing them

Rebecca N. Palmer rebecca_palmer at zoho.com
Wed Apr 23 18:42:01 BST 2025


Package: dh-r
Version: 20241218
Tags: patch

The 'generic' test runner (but not 'run-unit-test') runs tests/*.R with 
the current directory at the package root.  This fails for tests that 
refer to other files and expect to be run from the tests directory (e.g. 
this is standard for tests that use r-cran-testthat).

The one example I know of is r-cran-survminer (for which I have sent a 
fix separately).

Fix:

--- a/scripts/dh-make-R
+++ b/scripts/dh-make-R
@@ -1545,7 +1545,8 @@ maybe_write("debian/salsa-ci.yml", $sals
  my $test_generic = <<'EOF';
  #!/bin/sh -e

-for testfile in tests/*.[Rr] ; do
+cd tests
+for testfile in *.[Rr] ; do
      echo "BEGIN TEST $testfile"
      LC_ALL=C.UTF-8 R --no-save < $testfile
  done



More information about the R-pkg-team mailing list