Skip to content

Commit

Permalink
Frontend: Purge the use of OFP from the test base
Browse files Browse the repository at this point in the history
  • Loading branch information
mlange05 committed Oct 17, 2024
1 parent 0bdbe01 commit dc6ce03
Show file tree
Hide file tree
Showing 19 changed files with 59 additions and 93 deletions.
7 changes: 2 additions & 5 deletions loki/backend/tests/test_fgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from loki import Module, Subroutine, Sourcefile
from loki.backend import fgen
from loki.expression import symbols as sym
from loki.frontend import available_frontends, OMNI, OFP
from loki.frontend import available_frontends, OMNI
from loki.ir import Intrinsic, DataDeclaration
from loki.types import ProcedureType, BasicType

Expand Down Expand Up @@ -107,10 +107,7 @@ def test_fgen_data_stmt(frontend):
""".strip()

routine = Subroutine.from_source(fcode, frontend=frontend)
if frontend == OFP:
assert isinstance(routine.spec.body[-1], Intrinsic)
else:
assert isinstance(routine.spec.body[-1], DataDeclaration)
assert isinstance(routine.spec.body[-1], DataDeclaration)
spec_code = fgen(routine.spec)
assert spec_code.lower().count('data ') == 2
assert spec_code.count('/') == 4
Expand Down
4 changes: 2 additions & 2 deletions loki/backend/tests/test_pygen.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from loki import Subroutine
from loki.backend import pygen
from loki.build import jit_compile, clean_test
from loki.frontend import available_frontends, OFP, OMNI
from loki.frontend import available_frontends, OMNI
from loki.transformations.transpile import FortranPythonTransformation


Expand Down Expand Up @@ -452,7 +452,7 @@ def test_pygen_logical_statements(tmp_path, frontend):
f2p.py_path.unlink()


@pytest.mark.parametrize('frontend', available_frontends(xfail=[(OFP, 'OFP cannot handle stmt functions')]))
@pytest.mark.parametrize('frontend', available_frontends())
def test_pygen_downcasing(tmp_path, frontend):
"""
A simple test routine to test the conversion to lower case.
Expand Down
6 changes: 3 additions & 3 deletions loki/batch/tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@
)
from loki.expression import Scalar, Array, Literal, ProcedureSymbol
from loki.frontend import (
available_frontends, OMNI, OFP, FP, REGEX, HAVE_FP, HAVE_OFP, HAVE_OMNI
available_frontends, OMNI, FP, REGEX, HAVE_FP, HAVE_OMNI
)
from loki.ir import nodes as ir, FindNodes, FindInlineCalls
from loki.transformations import (
DependencyTransformation, ModuleWrapTransformation
)


pytestmark = pytest.mark.skipif(not HAVE_FP and not HAVE_OFP, reason='Fparser and OFP not available')
pytestmark = pytest.mark.skipif(not HAVE_FP, reason='Fparser not available')


@pytest.fixture(scope='module', name='here')
Expand Down Expand Up @@ -116,7 +116,7 @@ def fixture_frontend():
independent from the specific frontend used. Cannot use OMNI for this
as not all tests have dependencies fully resolved.
"""
return FP if HAVE_FP else OFP
return FP


@pytest.fixture(name='driverA_dependencies')
Expand Down
16 changes: 5 additions & 11 deletions loki/expression/tests/test_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from loki.build import jit_compile, clean_test
from loki.expression import symbols as sym, parse_expr, AttachScopesMapper
from loki.frontend import (
available_frontends, OFP, OMNI, FP, HAVE_FP, parse_fparser_expression
available_frontends, OMNI, FP, HAVE_FP, parse_fparser_expression
)
from loki.ir import (
nodes as ir, FindNodes, FindVariables, FindExpressions,
Expand Down Expand Up @@ -208,9 +208,7 @@ def test_boz_literals(tmp_path, frontend):
assert stmts[5].rhs.parameters[0].value == 'z"babe"'


@pytest.mark.parametrize('frontend', available_frontends(
skip={OFP: "Not implemented because too stupid in OFP parse tree"})
)
@pytest.mark.parametrize('frontend', available_frontends())
def test_complex_literals(tmp_path, frontend):
"""
Test complex literal values.
Expand Down Expand Up @@ -310,9 +308,7 @@ def test_logical_array(tmp_path, frontend):
clean_test(filepath)


@pytest.mark.parametrize('frontend', available_frontends(
xfail=[(OFP, 'Not implemented')]
))
@pytest.mark.parametrize('frontend', available_frontends())
def test_array_constructor(tmp_path, frontend):
"""
Test various array constructor formats
Expand Down Expand Up @@ -796,9 +792,7 @@ def test_masked_statements(tmp_path, frontend):
clean_test(filepath)


@pytest.mark.parametrize('frontend', available_frontends(xfail=[
(OFP, 'Current implementation does not handle nested where constructs')
]))
@pytest.mark.parametrize('frontend', available_frontends())
def test_masked_statements_nested(tmp_path, frontend):
"""
Nested masked statements (WHERE(...) ... [ELSEWHERE ...] ENDWHERE)
Expand Down Expand Up @@ -1607,7 +1601,7 @@ def test_typebound_resolution_type_info(frontend, tmp_path):
))
def test_stmt_func_heuristic(frontend, tmp_path):
"""
Our Fparser/OFP translation has a heuristic to detect statement function declarations,
Our Fparser translation has a heuristic to detect statement function declarations,
but that falsely misinterpreted some assignments as statement functions due to
missing shape information (reported in #326)
"""
Expand Down
17 changes: 6 additions & 11 deletions loki/frontend/tests/test_frontends.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)
from loki.build import jit_compile, clean_test
from loki.expression import symbols as sym
from loki.frontend import available_frontends, OMNI, OFP, FP, REGEX
from loki.frontend import available_frontends, OMNI, FP, REGEX
from loki.ir import nodes as ir, FindNodes


Expand Down Expand Up @@ -364,9 +364,7 @@ def test_enum(tmp_path, frontend):
clean_test(filepath)


@pytest.mark.parametrize('frontend', available_frontends(
xfail=[(OFP, 'OFP fails to parse parameterized types')]
))
@pytest.mark.parametrize('frontend', available_frontends())
@pytest.mark.usefixtures('reset_frontend_mode')
def test_frontend_strict_mode(frontend, tmp_path):
"""
Expand Down Expand Up @@ -1622,7 +1620,7 @@ def test_regex_function_inline_return_type():
assert 'dot_product_ecv' in routine.variables


@pytest.mark.parametrize('frontend', available_frontends(xfail=[(OFP, 'No support for prefix implemented')]))
@pytest.mark.parametrize('frontend', available_frontends())
def test_regex_prefix(frontend, tmp_path):
fcode = """
module some_mod
Expand Down Expand Up @@ -1842,12 +1840,9 @@ def test_inline_comments(frontend):
assert assigns[3].comment.text == '! wall !'

comments = FindNodes(ir.Comment).visit(routine.body)
assert len(comments) == 1 if frontend == OFP else 4
if frontend == OFP:
assert comments[0].text == '! Who said that?'
else:
assert comments[1].text == '! Who said that?'
assert comments[0].text == comments[2].text == comments[3].text == ''
assert len(comments) == 4
assert comments[1].text == '! Who said that?'
assert comments[0].text == comments[2].text == comments[3].text == ''


@pytest.mark.parametrize('from_file', (True, False))
Expand Down
3 changes: 1 addition & 2 deletions loki/ir/tests/test_control_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from loki import Subroutine
from loki.backend import fgen
from loki.build import jit_compile, clean_test
from loki.frontend import available_frontends, OMNI, OFP
from loki.frontend import available_frontends, OMNI
from loki.ir import nodes as ir, FindNodes


Expand Down Expand Up @@ -610,7 +610,6 @@ def test_single_line_forall_masked_stmt(tmp_path, frontend):

@pytest.mark.parametrize('frontend', available_frontends(xfail=[
(OMNI, 'Renames index variable to omnitmp000'),
(OFP, 'Parser fails to parse'),
]))
def test_multi_line_forall_construct(tmp_path, frontend):
fcode = """
Expand Down
6 changes: 2 additions & 4 deletions loki/tests/test_derived_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
FindVariables
)
from loki.build import jit_compile, jit_compile_lib, clean_test, Obj
from loki.frontend import available_frontends, OMNI, OFP
from loki.frontend import available_frontends, OMNI


@pytest.fixture(name='builder')
Expand Down Expand Up @@ -1204,9 +1204,7 @@ def test_derived_type_rescope_symbols_shadowed(tmp_path, shadowed_typedef_symbol
clean_test(filepath)


@pytest.mark.parametrize('frontend', available_frontends(xfail=[
(OFP, 'OFP cannot parse the Fortran')
]))
@pytest.mark.parametrize('frontend', available_frontends())
def test_derived_types_character_array_subscript(frontend, tmp_path):
fcode = """
module derived_type_char_arr_mod
Expand Down
6 changes: 2 additions & 4 deletions loki/tests/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Scalar, DeferredTypeSymbol, FindVariables, SubstituteExpressions, Literal
)
from loki.build import jit_compile, clean_test
from loki.frontend import available_frontends, OFP, OMNI
from loki.frontend import available_frontends, OMNI
from loki.sourcefile import Sourcefile


Expand Down Expand Up @@ -933,9 +933,7 @@ def test_module_rename_imports_no_definitions(frontend, tmp_path):
assert use_name is None or f'{s} => {use_name}' in fcode


@pytest.mark.parametrize('frontend', available_frontends(
xfail=[(OFP, 'hasModuleNature on use-stmt but without conveying actual nature')]
))
@pytest.mark.parametrize('frontend', available_frontends())
def test_module_use_module_nature(frontend, tmp_path):
"""
Test module natures attributes in ``USE`` statements
Expand Down
6 changes: 3 additions & 3 deletions loki/tests/test_sourcefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
StatementFunction, Comment, CommentBlock, RawSource, Scalar
)
from loki.build import jit_compile, clean_test
from loki.frontend import available_frontends, OFP, OMNI, FP, REGEX
from loki.frontend import available_frontends, OMNI, FP, REGEX


@pytest.fixture(scope='module', name='here')
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_sourcefile_pp_macros(here, frontend):


@pytest.mark.parametrize('frontend', available_frontends(xfail=[
(OFP, 'Cannot handle directives'), (OMNI, 'Files are preprocessed')
(OMNI, 'Files are preprocessed')
]))
def test_sourcefile_pp_directives(here, frontend):
filepath = here/'sources/sourcefile_pp_directives.F90'
Expand Down Expand Up @@ -193,7 +193,7 @@ def test_sourcefile_cpp_preprocessing(here, frontend):
assert 'b = 6' in fgen(routine)


@pytest.mark.parametrize('frontend', available_frontends(xfail=[(OFP, 'No support for statement functions')]))
@pytest.mark.parametrize('frontend', available_frontends())
def test_sourcefile_cpp_stmt_func(here, frontend, tmp_path):
"""
Test the correct identification of statement functions
Expand Down
8 changes: 4 additions & 4 deletions loki/tests/test_subroutine.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ProcedureSymbol, StatementFunction, DeferredTypeSymbol
)
from loki.build import jit_compile, jit_compile_lib, clean_test
from loki.frontend import available_frontends, OFP, OMNI, REGEX
from loki.frontend import available_frontends, OMNI, REGEX
from loki.types import BasicType, DerivedType, ProcedureType
from loki.ir import nodes as ir

Expand Down Expand Up @@ -1465,7 +1465,7 @@ def test_subroutine_rescope_clone(frontend):
)


@pytest.mark.parametrize('frontend', available_frontends(xfail=[(OFP, 'No support for statement functions')]))
@pytest.mark.parametrize('frontend', available_frontends())
def test_subroutine_stmt_func(tmp_path, frontend):
"""
Test the correct identification of statement functions
Expand Down Expand Up @@ -1537,7 +1537,7 @@ def test_mixed_declaration_interface(frontend):
assert "Declarations must have intents" in str(error.value)


@pytest.mark.parametrize('frontend', available_frontends(xfail=[(OFP, 'Prefix support not implemented')]))
@pytest.mark.parametrize('frontend', available_frontends())
def test_subroutine_prefix(frontend):
"""
Test various prefixes that can occur in function/subroutine definitions
Expand Down Expand Up @@ -1852,7 +1852,7 @@ def test_subroutine_lazy_arguments_incomplete2(frontend):
assert all(isinstance(arg, Array) for arg in routine.arguments[4:])


@pytest.mark.parametrize('frontend', available_frontends(xfail=[(OFP, 'Prefix support not implemented')]))
@pytest.mark.parametrize('frontend', available_frontends())
def test_subroutine_lazy_prefix(frontend):
"""
Test that prefixes for functions are correctly captured when the object is made
Expand Down
2 changes: 1 addition & 1 deletion loki/tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
FindNodes, ProcedureDeclaration
)
from loki.expression import symbols as sym
from loki.frontend import available_frontends, OFP, OMNI
from loki.frontend import available_frontends, OMNI


@pytest.fixture(scope='module', name='here')
Expand Down
5 changes: 2 additions & 3 deletions loki/transformations/build_system/tests/test_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from loki import Sourcefile
from loki.batch import Scheduler, SchedulerConfig
from loki.frontend import available_frontends, OMNI, OFP
from loki.frontend import available_frontends, OMNI
from loki.ir import (
FindNodes, CallStatement, Import, Interface, Intrinsic, FindInlineCalls
)
Expand Down Expand Up @@ -445,8 +445,7 @@ def test_dependency_transformation_replace_interface(frontend, use_scheduler, mo
assert intfs[0].symbols == ('kernel_test',)


@pytest.mark.parametrize('frontend', available_frontends(
xfail=[(OFP, 'OFP does not correctly handle result variable declaration.')]))
@pytest.mark.parametrize('frontend', available_frontends())
def test_dependency_transformation_inline_call(frontend):
"""
Test injection of suffixed kernel, accessed through inline function call.
Expand Down
6 changes: 2 additions & 4 deletions loki/transformations/extract/tests/test_extract_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest

from loki.frontend import available_frontends, OMNI, OFP
from loki.frontend import available_frontends, OMNI
from loki.ir import CallStatement, Import, FindNodes, FindInlineCalls
from loki.sourcefile import Sourcefile
from loki.subroutine import Subroutine
Expand Down Expand Up @@ -558,9 +558,7 @@ def test_extract_internal_procedures_basic_scalar_function(frontend):
call = list(FindInlineCalls().visit(outer.body))[0]
assert 'x' in call.kw_parameters

@pytest.mark.parametrize(
'frontend', available_frontends(skip=(OFP, "ofp fails for unknown reason, likely frontend issue"))
)
@pytest.mark.parametrize('frontend', available_frontends())
def test_extract_internal_procedures_basic_scalar_function_both(frontend):
"""
Basic test for scalars highlighting that the outer and inner procedure may be functions.
Expand Down
5 changes: 2 additions & 3 deletions loki/transformations/inline/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from loki import Module, Subroutine
from loki.build import jit_compile_lib, Builder, Obj
from loki.frontend import available_frontends, OMNI, OFP
from loki.frontend import available_frontends, OMNI
from loki.ir import (
nodes as ir, FindNodes, FindVariables, FindInlineCalls
)
Expand Down Expand Up @@ -195,8 +195,7 @@ def test_transform_inline_elemental_functions_extended(tmp_path, builder, fronte


@pytest.mark.parametrize('frontend', available_frontends(
skip={OFP: "OFP apparently has problems dealing with those Statement Functions",
OMNI: "OMNI automatically inlines Statement Functions"}
skip={OMNI: "OMNI automatically inlines Statement Functions"}
))
@pytest.mark.parametrize('stmt_decls', (True, False))
def test_inline_statement_functions(frontend, stmt_decls):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
import pytest

from loki import Module, Subroutine
from loki.frontend import available_frontends, OFP
from loki.frontend import available_frontends
from loki.ir import nodes as ir, FindNodes
from loki.batch import Scheduler, SchedulerConfig

from loki.transformations.inline import InlineTransformation


@pytest.mark.parametrize('frontend', available_frontends(
(OFP, 'Prefix/elemental support not implemented'))
)
@pytest.mark.parametrize('frontend', available_frontends())
@pytest.mark.parametrize('pass_as_kwarg', (False, True))
def test_inline_transformation(tmp_path, frontend, pass_as_kwarg):
"""Test combining recursive inlining via :any:`InliningTransformation`."""
Expand Down
5 changes: 2 additions & 3 deletions loki/transformations/single_column/tests/test_scc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from loki import Subroutine, Sourcefile, Dimension, fgen
from loki.batch import ProcedureItem
from loki.expression import Scalar, Array, IntLiteral
from loki.frontend import available_frontends, OMNI, OFP
from loki.frontend import available_frontends, OMNI
from loki.ir import (
FindNodes, Assignment, CallStatement, Conditional, Loop,
Pragma, PragmaRegion, pragmas_attached, is_loki_pragma,
Expand Down Expand Up @@ -633,8 +633,7 @@ def test_scc_variable_demotion(frontend, horizontal):
assert isinstance(kernel.variable_map['c'], Scalar)


@pytest.mark.parametrize('frontend', available_frontends(xfail=[(OFP,
'OFP fails to parse multiconditional with embedded call.')]))
@pytest.mark.parametrize('frontend', available_frontends())
def test_scc_multicond(frontend, horizontal, blocking):
"""
Test if horizontal loops in multiconditionals with CallStatements are
Expand Down
Loading

0 comments on commit dc6ce03

Please sign in to comment.