This repository was archived by the owner on Sep 24, 2026. It is now read-only.
Add a testthat suite and CI - #4
Merged
Merged
Conversation
First module to run tests in CI outside the CBM set. Adds: - `.github/workflows/testthat-module.yaml` — a thin caller for the shared reusable workflow. It pins `@feat/testthat-module-workflow` for now, because that workflow is still in review (PredictiveEcology/actions#44); switch to `@main` once it merges. - `tests/testthat/setup.R` — sets options and resolves the module path. testthat runs from `tests/testthat`, so `modulePath` is three levels up, not one. - `tests/testthat/test-metadata.R` — asserts the module's public contract: input and output object names AND classes, and parameter names. Removes the dead `newModule()` scaffolding: `tests/testthat/test-template.R` and `tests/unitTests.R`. Neither was ever run. They are not merely noise -- once a module is converted to a package for testing, `R CMD check` runs `unitTests.R` and it fails with "No test files found", because it hardcodes a relative `tests/testthat` path that does not resolve in the installed test directory. The metadata test is deliberately the first one. A module's metadata is its public contract, and the raster -> terra migration now reaching the release branches changes object classes across the family. This is the assertion that catches a rename or a retype before a downstream project does. `tests/Test_EscapeFit.R` is left alone but is stale: it sets `formula` and `data` parameters, and this module has neither -- its parameters are `.runInitialTime`, `.runInterval`, `.saveInitialTime`, `.saveInterval` and `.useCache`, and its inputs are `fireSense_escapeCovariates` and `fireSense_escapeFormula`. It is a manual script, not run by anything. Flagging rather than deleting. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0125hLaqRWaPcutdboenVK2g
PredictiveEcology/actions#44 merged and its branch was deleted, so the @feat/testthat-module-workflow ref no longer resolves. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0133867aFrmKtbhpNXasToP9
This was referenced Sep 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pilot for the module test workflow. This is the first module outside the CBM set to run tests in CI.
Depends on PredictiveEcology/actions#44 (the
testthat-modulereusable workflow). The caller here pins@feat/testthat-module-workflowso this can be validated before that merges — switch to@mainonce it does.What it adds
tests/testthat/test-metadata.R— asserts the module's public contract: input and output object names and classes, plus parameter names.tests/testthat/setup.R— options and module path resolution. testthat runs fromtests/testthat, somodulePathis three levels up; getting it wrong fails silently (the module simply isn't found)..github/workflows/testthat-module.yaml— thin caller.Why metadata first
A module's metadata is its public contract — a project binds to these object names and classes. The
raster→terramigration now reaching the release branches changes object classes across the family, so this is the assertion that catches a rename or retype here rather than in a downstream project. It is also cheap and mechanical enough to generate for every module.Verified locally against this module:
convertToPackage()builds the package rendition in a throwaway directory (the module itself is untouched), and all 5 assertions pass.Removals
tests/testthat/test-template.Randtests/unitTests.R— the deadnewModule()scaffolding, still carryingC:/Users/yonluo/...paths. Neither was ever run.These are not merely noise. Once a module is converted to a package for testing,
R CMD checkrunsunitTests.R, and it fails withNo test files foundbecause it hardcodes a relativetests/testthatpath that does not resolve in the installed test directory. The dead scaffolding actively breaks the build.Flagged, not changed
tests/Test_EscapeFit.Ris stale. It setsformulaanddataparameters; this module has neither. Its parameters are.runInitialTime,.runInterval,.saveInitialTime,.saveInterval,.useCache, and its inputs arefireSense_escapeCovariatesandfireSense_escapeFormula. It is a manual script, not run by anything. Left in place — deleting it is the maintainer's call.Also noticed:
reqdPkgs = list()is empty, yetspatialExtentcallsraster::extent(). Not touched here.🤖 Generated with Claude Code
https://claude.ai/code/session_0125hLaqRWaPcutdboenVK2g