Skip to content

refactor(tests): update integration test setup#990

Draft
Bai-Li-NOAA wants to merge 25 commits intodevfrom
dev-refactor-prepare-test-data
Draft

refactor(tests): update integration test setup#990
Bai-Li-NOAA wants to merge 25 commits intodevfrom
dev-refactor-prepare-test-data

Conversation

@Bai-Li-NOAA
Copy link
Copy Markdown
Collaborator

@Bai-Li-NOAA Bai-Li-NOAA commented Sep 22, 2025

What is the feature?

How have you implemented the solution?

  • Create helper functions (load_*()) to load or create data for a FIMS model run, or run a FIMS model with wrappers to save the fit output. These functions check if the corresponding .RDS file exists; if not, they generate the data or run the model and save the output to an .RDS file. If the file exists, they read and return the object from the .RDS file. This ensures that test data is generated only once and is available for subsequent test runs, speeding up the process.
  • Add error handling (e.g., tryCatch()) in data loading functions to provide clearer messages when file operations fail.
  • Update README to document new helper functions for loading data and running FIMS with wrappers.
  • Rename test-integration-caa-mle.R to test-integration-caa-mle-without-wrappers.R so it can be filtered when running tests (devtools::test(filter = "xxx")), speeding up single-test execution.
  • Update snapshot tests outputs from .md files to .csv files.
  • Replace nan with -999 in JSON files. Thanks to @msupernaw for the fix to issue [feature:] let nan values play through the JSON output without crashing to help with debugging #940.

Does the PR impact any other area of the project, maybe another repo?

Task:
[ ] add an integration test where we manually set the fixed-effect _F_s to constant (address issue #852)

Bai-Li-NOAA and others added 24 commits August 21, 2025 14:40
* set verbosity to `quiet` in `tests/testthat.R` to suppress test output
  when running `devtools::test()` locally.
* set verbosity to `quiet` in `tests/testthat/helper-aaa-quiet-test-output.R`
  to suppress output when running `testthat::test_package()` locally.
  This mirrors the "Show testthat output" (`test_check()`) step in the
  `call-r-cmd-check` GitHub Action workflow.
* set `silent = TRUE` in `TMB::MakeADFun()` calls to
  suppress TMB output during tests.
* use `suppressMessages()` to silence output from fims_frame tests and
  testthat template tests.
* don't use `Rcerr` to print a message to the console when the ParameterVector
  index is out of range, since `throw` already handles the error output.
Bumps [actions/first-interaction](https://github.com/actions/first-interaction) from 1 to 2.
- [Release notes](https://github.com/actions/first-interaction/releases)
- [Commits](actions/first-interaction@v1...v2)

---
updated-dependencies:
- dependency-name: actions/first-interaction
  dependency-version: '2'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
* document(check_fims.R): Add examples of strings passed to ... in
  FIMS:::setup_and_run_gtest()
* refactor(fimsfit.R):
  * Remove is.FIMSFits() function
  * Remove "total" from number_of_parameters; only print it
    as the sum of fixed_effects + random_effects
* document(fimsfit.R): Add comment referencing sdmTMB issue #455 to
  evaluate whether report should always use last.par.best
* document(initialize_modules.R): Clarify that dims field is necessary
  to track dimensions for multivariate input (e.g., MVNORM) and may be
  needed for other distributions
* update(data1.R): Remove check for CSV readability in R
* update(helper-integration-tests-setup-function.R): Replace 1:x with
  seq_along() in for loop for safer indexing

Co-authored-by: Andrea-Havron-NOAA <Andrea-Havron-NOAA@users.noreply.github.com>
Co-authored-by: k-doering-NOAA <k-doering-NOAA@users.noreply.github.com>
Co-authored-by: kellijohnson-NOAA <kellijohnson-NOAA@users.noreply.github.com>
Co-authored-by: msupernaw <msupernaw@users.noreply.github.com>
Co-authored-by: nathanvaughan-NOAA <nathanvaughan-NOAA@users.noreply.github.com>
Co-authored-by: peterkuriyama-NOAA <peterkuriyama-NOAA@users.noreply.github.com>
* add README.md under the /tests directory as a quick reference for
  testing. It includes instructions on adding a new test, run tests, and
  debug tests.
* add a C++ test template to inst/templates.
* add a new R function `use_gtest_template()` to create a C++ test file
  using the template and register the test in
  `tests/gtest/CMakeLists.txt`.
* add R unit tests for `use_gtest_template()`.
* add a C++ test `tests/gtest/test_FIMSJson_JsonParser_WriteToFile.cpp`
  to verify error handling instructions outlined in the C++ test template.
* update LogisticSelectivity C++ test to use the new template.
* fix spelling errors and update WORDLIST.
* Place `Rcpp::loadModule(module = "fims", what = TRUE)` inside the
  `.onLoad` function has been observed to fix R session crashes when running
  `devtools::load_all()` followed by `devtools::test()` in the package
  development workflow.
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
* chore(devcontainer): add lldb for debugging support
* chore(readme): add FIMS local dev setup cheat sheet
* chore(spell-check): check additional files and update WORDLIST
Close #910

Co-authored-by: Abhinav Kumar <abhinavkumar130503@gmail.com>
Much of the content was moved to CONTRIBUTING.md but some was also moved
to the README. The documentation vignette was removed because it mainly
contained links to resources that we are trying to consolidate into more
intuitive locations. `check_fims()` was deprecated and the list of items
was moved to CONTRIBUTING.md. Adds information from collaborative
workflow to the README in the tests folder.

Close #947
* add create_default_configurations() to set up
  configurations based on data
* update create_default_*() to use output
  from create() for parameter specification and it
  returns a tibble
* update initialize_*() to accept a tibble of
  parameters as input
* update vignettes and tests
* change "age" and "length" types to "age_comp" and
  "length_comp" in data1
* add R tests for `create_default_configurations()`.
* add error-handling tests for `create_default_parameters()`
  to cover cases where no parameters are available for optimization.
  Address issue#552.
* add snapshot tests for the outputs of both `create_default_configurations()`
  and `create_default_parameters()`. Snapshots are saved as CSV files.
Update Doxygen destination repository and folder to fims website instead
of a separate repository.
@github-actions
Copy link
Copy Markdown
Contributor

Instructions for code reviewer

Hello reviewer, thanks for taking the time to review this PR!

  • Please use this checklist during your review, checking off items that you have verified are complete, but feel free to skip over items that are not relevant!
  • See the GitHub documentation for how to comment on a PR to indicate where you have questions or changes are needed before approving the PR.
  • Please use conventions in the guidelines for conventional commit messages for both commit messages and comments.
  • PR reviews are a great way to learn so feel free to share your tips and tricks. However, when suggesting changes to the PR that are optional please include nit: (for nitpicking) as the comment type. For example, nit: I prefer using a data.frame() instead of a matrix because ...
  • Engage with the developer when they respond to comments and check off additional boxes as they become complete so the PR can be merged in when all the tasks are fulfilled. Make it clear when the PR is approved by selecting the approved status, and potentially by commenting on the PR with something like This PR is now ready to be merged, no additional changes are needed.

Checklist

  • The PR is requested to be merged into the appropriate branch (typically dev).
  • The code is well-designed.
  • The functionality is good for the users of the code.
  • Code coverage remains high, indicating the new code is tested.
  • The code is commented and the comments are clear, useful, and mostly explain why instead of what.
  • Code is appropriately documented (doxygen and roxygen).

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 22, 2025

Codecov Report

❌ Patch coverage is 94.67085% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.30%. Comparing base (2c7101a) to head (786a48f).
⚠️ Report is 194 commits behind head on dev.

Files with missing lines Patch % Lines
R/create_default_parameters.R 93.51% 22 Missing ⚠️
R/initialize_modules.R 96.26% 4 Missing ⚠️
inst/include/models/functors/catch_at_age.hpp 0.00% 3 Missing ⚠️
inst/include/utilities/fims_json.hpp 85.71% 2 Missing ⚠️
R/distribution_formulas.R 92.85% 1 Missing ⚠️
R/zzz.R 0.00% 1 Missing ⚠️
...nterface/rcpp/rcpp_objects/rcpp_interface_base.hpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #990      +/-   ##
==========================================
- Coverage   80.26%   75.30%   -4.96%     
==========================================
  Files          51       83      +32     
  Lines        1941     8035    +6094     
  Branches      461      311     -150     
==========================================
+ Hits         1558     6051    +4493     
- Misses        262     1978    +1716     
+ Partials      121        6     -115     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Bai-Li-NOAA Bai-Li-NOAA force-pushed the dev-refactor-prepare-test-data branch from 3c98c29 to fd35115 Compare September 22, 2025 16:45
- Create helper functions (`load_*()`) to load or create
  data for a FIMS model run, or run a FIMS model with
  wrappers to save the fit output. These functions
  check if the corresponding `.RDS` file exists; if not,
  they generate the data or run the model and save
  the output to an `.RDS` file. If the file exists,
  they read and return the object from the `.RDS` file.
  This ensures that test data is generated only once
  and is available for subsequent test runs,
  speeding up the process.
- Add error handling (e.g., `tryCatch()`) in data loading
  functions to provide clearer messages when file
  operations fail.
- Update README to document new helper functions
  for loading data and running FIMS with wrappers.
- Rename `test-integration-caa-mle.R` to
  `test-integration-caa-mle-without-wrappers.R` so it
  can be filtered when running tests
  (`devtools::test(filter = "xxx")`), speeding up
  single-test execution.
- Update snapshot tests outputs from `.md` files
  to `.csv` files.
- Replace nan with -999 in JSON files. Thanks to
  @msupernaw for the fix to issue #940.
@kellijohnson-NOAA
Copy link
Copy Markdown
Contributor

@Bai-Li-NOAA I just wanted to note that I think we can hold off on this until after the CIE review. I do not want you to have to rebase this over and over again. So, let's just leave it as is and if you can pick it back up in May that would be great. What do you think?

@Bai-Li-NOAA
Copy link
Copy Markdown
Collaborator Author

@kellijohnson-NOAA Yes, this will be a big rebase task. I thought we had discussed possibly pausing development before or during the CIE review. I could use that pause to work on the rebase, with the goal of having it be the first to merge after the CIE review. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants