Skip to content

Absorb filtering functionality into test_description_m - #89

Closed
rouson wants to merge 39 commits into
mainfrom
absorb-filtering-in-test_description
Closed

Absorb filtering functionality into test_description_m#89
rouson wants to merge 39 commits into
mainfrom
absorb-filtering-in-test_description

Conversation

@rouson

@rouson rouson commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

No description provided.

rouson and others added 30 commits August 9, 2025 07:16
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.
move pointer declarations & definitions outside a block construct
rouson added 9 commits August 10, 2025 21:46
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.
@bonachea bonachea linked an issue Aug 11, 2025 that may be closed by this pull request
Comment on lines 49 to 53
,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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems like a reasonable solution to issue #67.

It's still not fully automatic/transparent inside test_description_t%run() as requested in issue #67, but at least it's a pretty minimal piece of boilerplate the client is expected to write.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bonachea I'm really glad you persisted in this discussion. I'm closing this PR because PR #91 now contains a much better approach than I wouldn't have discovered without your persistence.

@rouson rouson closed this Aug 12, 2025
@rouson
rouson deleted the absorb-filtering-in-test_description branch August 23, 2025 22:27
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.

Move --contains test filtering logic into Julienne

2 participants