Skip to content

Commit

Permalink
Fix repeated fused stencil test (#443)
Browse files Browse the repository at this point in the history
* Fixed repeated stencil test for fused stencils.

Now repeated fused stencils are actually allowed and tested correctly.

* Made string _extract_arg_from_directive raw to avoid warning about invalid escape sequence.

* Ruff formatting

---------

Co-authored-by: stelliom <[email protected]>
  • Loading branch information
2 people authored and iomaganaris committed Jun 18, 2024
1 parent 6739c6d commit f7e887a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion tools/src/icon4pytools/liskov/parsing/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def validate(self, directives: Sequence[ts.ParsedDirective]) -> None:


def _extract_arg_from_directive(directive: str, arg: str) -> str:
match = re.search(f"{arg}\s*=\s*([^\s;)]+)", directive)
match = re.search(rf"{arg}\s*=\s*([^\s;)]+)", directive)
if match:
return match.group(1)
else:
Expand Down Expand Up @@ -122,6 +122,8 @@ def _validate_directive_uniqueness(self, directives: Sequence[ts.ParsedDirective
parse.EndCreate,
parse.StartStencil,
parse.EndStencil,
parse.StartFusedStencil,
parse.EndFusedStencil,
parse.EndIf,
parse.EndProfile,
parse.StartProfile,
Expand Down
4 changes: 2 additions & 2 deletions tools/tests/liskov/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ def test_directive_semantics_validation_repeated_directives(make_f90_tmpfile, di
[
(
SINGLE_STENCIL_WITH_COMMENTS,
"!$DSL START STENCIL(name=mo_nh_diffusion_stencil_06)\n!$DSL END STENCIL(name=mo_nh_diffusion_stencil_06)",
"!$DSL START STENCIL(name=apply_nabla2_to_vn_in_lateral_boundary)\n!$DSL END STENCIL(name=apply_nabla2_to_vn_in_lateral_boundary)",
),
(
SINGLE_FUSED,
"!$DSL START FUSED STENCIL(name=mo_nh_diffusion_stencil_06)\n!$DSL END FUSED STENCIL(name=mo_nh_diffusion_stencil_06)",
"!$DSL START FUSED STENCIL(name=calculate_diagnostic_quantities_for_turbulence)\n!$DSL END FUSED STENCIL(name=calculate_diagnostic_quantities_for_turbulence)",
),
],
)
Expand Down

0 comments on commit f7e887a

Please sign in to comment.