Add testthat coverage for trait meta-analysis pipeline functions#3858
Open
omkarrr2533 wants to merge 1 commit intoPecanProject:developfrom
Open
Add testthat coverage for trait meta-analysis pipeline functions#3858omkarrr2533 wants to merge 1 commit intoPecanProject:developfrom
omkarrr2533 wants to merge 1 commit intoPecanProject:developfrom
Conversation
23d6ab7 to
d9ca08e
Compare
be57177 to
1f495fb
Compare
6b2de10 to
2eab0f0
Compare
Add comprehensive test coverage for the core meta-analysis pipeline functions as preparation for modularity improvements planned in the GSoC 'Refactoring the PEcAn trait meta-analysis workflow' project. New test files: - helper-test-data.R: Shared fixtures - test-check_consistent.R: Unit tests for check_consistent() - test-run.meta.analysis.pft.R: Tests for workflow wrapper - test-meta_analysis_standalone.R: Tests for core analysis function - test-get.parameter.samples.R: Documents invisible(NULL) return problem These tests lock in current behavior before any refactoring begins. No functional changes to existing code.
2eab0f0 to
6783775
Compare
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this does
Adds test coverage for the core functions in the meta-analysis pipeline —
check_consistent(),run.meta.analysis.pft(),meta_analysis_standalone(),p.point.in.prior(), and documents a structural issue inget.parameter.samples().These tests lock in existing behavior so that future refactoring (particularly the GSoC modularity work) has a safety net against regressions.
Why
The meta-analysis pipeline currently has minimal test coverage. Before changing anything in these functions, we need tests that confirm what they actually do today. A few things I found worth noting while writing these:
get.parameter.samples()ends withsave(...)and noreturn()statement, so it returnsinvisible(NULL). Callers can't access results without loading the saved file. The test file documents this with a skip explaining the problem — this is the core architectural issue the GSoC project aims to fix.run.meta.analysis.pft()checks for input files before touching the database, which means we can test all its precondition logic without needing a DB connection.check_consistent()is a pure function with no side effects, so it's straightforward to test thoroughly.What's covered
22 tests run, 1 strategic skip.
Design decisions
helper-test-data.R. Thedbcon = NULLcalls are safe becauserun.meta.analysis.pft()validates input files before attempting any database operations.test-meta_analysis_standalone.Rchecks forrjagsinstallation and actual JAGS availability before running.helper-test-data.R.create_test_trait_data(),create_test_priors(),create_test_pft(), andsetup_trait_files()build minimal but realistic data structures that match what the pipeline actually produces. These are reusable for future tests.:::for internal functions.check_consistent,p.point.in.prior, andrun.meta.analysis.pftaren't exported, so tests access them viaPEcAn.MA:::.Checklist
devtools::test()skip_on_cran()andskip_if_not_installed()where appropriateR CMD checkpasses without new warnings