ESCOMP / ESCOMP/CTSM

Unit-test string replacement in LREPRSTRUCT test

Open
#3,325 1 comment 0 reactions 0 assignees View on GitHub
b4b size: small testing
Dominant language
Fortran
Stars
352
Forks
361
Avg merge
2d 21h
Merged PRs (30d)
7

Description

_Originally posted by @billsacks in https://github.com/ESCOMP/CTSM/issues/3314#issuecomment-3058129878_

> I got as far as thinking about how I'd do this:
> 1. Pull replace_grain into a top-level function
> 2. Extract the line, `user_nl_clm_text = re.sub(r"GRAIN\w*", replace_grain, user_nl_clm_text)` into a new top-level function in the module. This will be the function that would be unit tested.
> 3. Do a manual test of building the LREPRSTRUCT test to ensure that the user_nl_clm file is still the same as before after steps (1) and (2).
> 4. Create a unit test module for LREPRSTRUCT
> 5. Create at least one unit test for the extracted function, giving it a string as input and testing the resulting string. At a minimum this should have the situation mentioned in my comment above, where one line contains 'GRAINN_TO_FOOD' and a later line contains (among other things) "'GRAINN_TO_FOOD_PERHARV', 'GRAINN_TO_FOOD_ANN'". (The later line could include a more extensive line that matches what's in that line in the current user_nl_clm.)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.