Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor tests to remove dependencies on internal models #594

Merged
merged 4 commits into from
Aug 7, 2023

Conversation

mattw-nws
Copy link
Contributor

Shifts unit tests to use BMI test mock models instead of legacy internal models. This lays the groundwork for #562 and additional legacy code removal

Additions

  • test_bmi_cpp is now used for several unit tests in Formulation_Manager_Test.cpp
  • The cmake build system now automatically builds test_bmi_cpp without any additional flags
  • Formulation_Manager_Test now uses some #defines from Bmi_Formulation.hpp and AorcForcing.hpp (the latter was the case already but it wasn't explicitly included)

Removals

  • Formulation_Manager_Test no longer uses tshirt, tshirt_c, simple_lumped or anything that requires et_calc

Changes

  • test_bmi_cpp is now built as a dependency. The build should be the same as the usual way (e.g. the artifacts go to the same place) and shouldn't interfere with manual builds either.

Testing

  1. All automated tests pass, separately tested with the removed components removed from the codebase.

Screenshots

Notes

Todos

  • Possibly allow C++ BMI formulations to be directly compiled in and use Bmi_Formulation instead of Bmi_Module_Formulation, which would remove the required weirdness of building the plugin shared library version of test_bmi_cpp.

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code follows project standards (link if applicable)
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • Reviewers requested with the Reviewers tool ➡️

Testing checklist (automated report can be put here)

Target Environment support

  • Linux

… to get test_bmi_cpp for example realization config purposes.
…ally add any value to have more than one module tested here, and adding it would require different build flags to ngen. Using only the test_bmi_cpp mock, it would be relatively easy in the future to make Bmi_Formulation less "abstract" and support C++ BMI models not in a shared library, removing the need to compile the module in extern explicitly.

Conflicts:
	.github/workflows/test_and_validate.yml
"], "
"\"forcing\": { "
"\"file_pattern\": \".*{{ID}}.*.csv\", "
"\"file_pattern\": \".*{{ID}}.*.csv\", " // DIFF from Ex.1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these comments placed to get git diff to behave sensibly? That's the only possibility I can infer from them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah... those are I suppose vestiges from a676c5d, where I was trying to capture how the examples differed from one another, to determine what the tests were actually testing and hence what needed to be preserved. Still somewhat useful as road markers, since the four giant strings aren't easily comparable. (I recommend cutting example 1 and pasting it after example 4 if you want, that's how I compared them to get those notes.)

@@ -27,6 +27,7 @@ target_include_directories(testbmicppmodel PRIVATE ../bmi-cxx/ )
set_target_properties(testbmicppmodel PROPERTIES VERSION ${PROJECT_VERSION})

set_target_properties(testbmicppmodel PROPERTIES PUBLIC_HEADER include/test_bmi_cpp.hpp)
set_target_properties(testbmicppmodel PROPERTIES CXX_VISIBILITY_PRESET default)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my perspective, this is a stop-gap toward actually export-marking the relevant exported symbols explicitly, to demonstrate the practice that we should be encouraging from real models that we integrate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes... to elaborate, when I added add_subdirectory(test_bmi_cpp...) to CMakeLists.txt, it was compiling with -fvisibility=hidden for reasons that weren't fully clear... it also wasn't fully clear why it wasn't doing that when building test_bmi_cpp with cmake standalone. Arguably, including that flag and having the desired public symbols explicitly marked (as @PhilMiller suggests) are the best practice, though there's little or nothing in this test module that isn't intended to be visible.

@PhilMiller
Copy link
Contributor

Not for this PR, but those embedded configurations would be an ideal use of C++ raw string literals
https://en.cppreference.com/w/cpp/language/string_literal

@mattw-nws mattw-nws self-assigned this Aug 3, 2023
@mattw-nws mattw-nws merged commit 104245f into NOAA-OWP:master Aug 7, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants