(Closes 2311) Add functionality to derive module and subroutine names of adjoint test from filename for LFRic API #2749
+27
−12
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.
Closes #2311 which has a description of the problem.
Patch notes
I solved the problem by feeding the filename given to -otest down into the codebase. Here is a summary of the changes made across the relevant call tree:
src/psyclone/psyad/main.py
Changed the default value of this variable to be
None
. Added in theargs.test_filename
value to the call signature ofgenerate_adjoint_str
.src/psyclone/psyad/tl2ad.py
Added new
test_filename
argument into call signature. I decided to add the conversion of thetest_filename
into thetest_name
variable here because I figured it would be API specific, so having it in the API selection telegraphs that nicely. Default value is justadjoint_test
like the previous behaviour.For the LFRic API, we take everything from
test_filename
before "_mod." to be thetest_name
.src/psyclone/psyad/domain/lfric/lfric_adjoint_harness.py
Changed function to use
test_name
instead of the hardcoded value of "adjoint_test".Testing
I tested this by making changes to
src/psyclone/tests/psyad/domain/lfric/test_lfric_adjoint_harness.py
. I passed in a new value of the optionaltest_name
that is "adjoint_test_alg" which would replicate what we see in LFRic. This test passed by producing the expected "adjoint_test_alg_mod" as the module name and "adjoint_test_alg" as the subroutine name.I also tested this by changing
src/psyclone/tests/psyad/tl2ad_test.py
to include atest_filename
KGO, which also passed.