-
Notifications
You must be signed in to change notification settings - Fork 15
Description
As part of the SEWG hackathon today, @billsacks and I added CMake code to build an example pfunit test into CISM. PFUnit adds Fortran-based unit testing to projects and is used by many components in CESM. For this project, we used the test code in ESCOMP/cesm_share as an example, and we used some infrastructure from CIME to support this, so, to run the tests, we used the instructions from ESCOMP/cesm_share .
Unit tests are simple tests that test very small and specific pieces of code with given inputs to make sure we are getting expected outputs. These are lightweight tests that can be run automatically by github actions for pull requests or as part of development activities. To get "good" coverage of large models like CISM, it would require many (MANY) unit tests, but these could still be useful to ensure that important parts of code are not broken by updates.
The code for the pfunit building infrastructure and an example test is on my branch here.
So, there are a couple of "next steps" for this project:
- Integrate the CMakeLists code for pfunit with the CMakeLists code in CISM. This is also done in cesm_share, so that could be an example, however, we may need to do something different for source files because of CISM's non-hierarchal CMake build.
- Discuss and choose code for future unit tests. Gunter and I talked about it today and he suggested basal friction calculations in libglissade/glissade_basal_traction.F90 or possibly surface mass balance functions related to smb_input. Kate was thinking about glide_types or some unit tests related to model data structure filling as that area of code is likely to be refactored soon. Also, new code added for history output should probably include unit tests.
- Possibly code refactoring to make subroutines better structured for unit testing (reduced useage of module variables and more passage of needed values as arguments)
- Write a bunch of tests!
- Add to development workflow, and document it.