Absorb filtering functionality into test_description_m - #89
Conversation
This commit introduces the test_harness_t and test_fixture_t derived types and uses them to refactor and simplify the test-suite driver program: test/main.F90.
This commit reduces the amount of code that end users must write by moving the reporting of the final tally of test passes, test count, and skipped tests to the test_harness_t's "report" type-bound procedure.
This commit the code that checks whether the test suite is running in GitHub CI and checks whether the user requested to run the command_line_t tests. The code is moved from the test-suite driver to the actual test, which further simplifies the test-suite main program.
This commit adds a binary operator that produces a test_diagnosis_t result when applied to a logical operand.
Caveat: The newly refactored test/main.f90 program causes an ICE with gfortran 13.4.
…e into test-harness-feature
move pointer declarations & definitions outside a block construct
also delete redundant example
Also switch file to lower-case .f90 extension because the preprocessor is no longer needed.
This commit prepares for moving the test-filtering logic to one central location in test_description_s rather than having versions of the logic distributed across all tests. Because the deprecated vector_test_description_t is convoluted due to preprocessor directives, extracting the filter from that file would be challenging, which motivates the removal. This is a breaking change for any codes that use vector_test_description_t.
| ,test_description_t("invocation removal after undefining the ASSERTIONS macro", check_macro_removal) & | ||
| ]) | ||
| associate(substring_in_subject => index(subject(), test_description_substring) /= 0) | ||
| associate(substring_in_test_diagnosis => descriptions%contains_text(test_description_substring)) | ||
| associate(matching_descriptions => pack(descriptions, substring_in_subject .or. substring_in_test_diagnosis)) | ||
| test_results = matching_descriptions%run() | ||
| end associate | ||
| end associate | ||
| end associate | ||
| ] | ||
| associate(matching_descriptions => filter(test_descriptions, subject())) | ||
| test_results = matching_descriptions%run() | ||
| end associate |
There was a problem hiding this comment.
@bonachea thanks for taking a look. It's challenging to think through a way to go further. The current matching_descriptions%run() exploits the elemental attribute of the run function, which I really like because it operates on every element of the matching_descriptions array without requiring a loop. But there's no way for an elemental function to produce an array result of a different shape than the argument that it receives so the filtering can't happen without giving up the conciseness of an elemental invocation, which means we'd be trading one set of boilerplate lines for some other set of boilerplate, e.g, a loop plus an explicit allocation, whereas currently, there's no loop and any required allocation happens automatically. What would be nice would be for a future standard to allow invocation of a procedure on an expression as we discussed recently. Then three statements could collapse to one statement of the form
test_results = filter(test_descriptions, subject())%run()
but I realize that even this is pretty clunky. I have one more ideas that I'll pursue and push. I think it will better accomplish what you're proposing.
There was a problem hiding this comment.
Hmm I hadn't thought about the elemental issue.
Now that you bring that up, another idea I considered is that test_description_t%run() for a filtered test could return a special "placeholder" test_result_t object, that merely indicates the test was skipped. That would solve the equal shape issue, and perhaps you'd just need to adjust the result-printing code to properly handle the "placeholders" for skipped tests?
No description provided.