Move test_chemistry_struct_synched between test suites
#327
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.
This PR moves move
test_chemistry_struct_synchedbetween test suites (from pygrackle-suite to the corelib-suite).At a high-level, this makes sense because this test deals with source code files.
Costs
This introduces some more lines of code. I could probably cut down on some of it (I reused some generic code I had written for a personal project, so it's a little more generic than necessary).
Benefits
This change has 3 advantages:
running the
test_chemistry_struct_synchedtest in the pygrackle-suite, it severely limited the organization of the public grackle headers. When the test was invoked from the pygrackle-suite, the header read in by the castxml tool (to probe thechemistry_datatype) could not have a transitive dependence on the grackle_float.h generated header (because the pygrackle tests can't make any assumptions about the existence/location of a build-directory).gr_required_units#209)it opens the door to reuse the machinery to write additional tests for other structs. For example:
While it is theoretically possible to test these scenarios through pytest, it would involve writing a bunch of extra specialized additional C & Cython code for each case (more than would be necessary for testing stuff through GTest). Furthermore, testing the internal types with Cython would mean that Cython needs access to internal headers (which I don't think we necessarily want).
Less importantly, because the build-system now invokes
castxmlwhenever the test-cases are built, the struct definition and the logic in the test case are always guaranteed to be synchronized with each other (this was not always the case)Other Thoughts
In the future, we could replace the usage of
castxmlwith a C++ library like https://github.com/boostorg/pfr (this doesn't need the rest of boost) or https://github.com/stephenberry/glaze. Both of these libraries would be easy to auto-install through CMake for this test (just like googletest) and could be used to automatically infer the list of members in a struct. The one "catch" is we would need to require C++20/C++23 for this particular test (which wouldn't be a huge deal)