From f7e887a752ab34e1efc9bce0d0383a86d961cebb Mon Sep 17 00:00:00 2001 From: stelliom <67868694+stelliom@users.noreply.github.com> Date: Fri, 19 Apr 2024 10:36:12 +0200 Subject: [PATCH] Fix repeated fused stencil test (#443) * 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 --- tools/src/icon4pytools/liskov/parsing/validation.py | 4 +++- tools/tests/liskov/test_validation.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/src/icon4pytools/liskov/parsing/validation.py b/tools/src/icon4pytools/liskov/parsing/validation.py index a6e4e81..905faeb 100644 --- a/tools/src/icon4pytools/liskov/parsing/validation.py +++ b/tools/src/icon4pytools/liskov/parsing/validation.py @@ -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: @@ -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, diff --git a/tools/tests/liskov/test_validation.py b/tools/tests/liskov/test_validation.py index fe79e2a..57165e3 100644 --- a/tools/tests/liskov/test_validation.py +++ b/tools/tests/liskov/test_validation.py @@ -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)", ), ], )