Skip to content

Commit

Permalink
Amend builder fixture in tests with Obj cache cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
reuterbal committed May 10, 2024
1 parent 690ea50 commit b4decea
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 15 deletions.
7 changes: 3 additions & 4 deletions loki/batch/tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,6 @@ def transform_subroutine(self, routine, **kwargs):
successors = kwargs.get('successors')
assert set(successors) == set(self.expected_successors[item.name])

tmp_path = tmp_path/'test_scheduler_successors'
(tmp_path/'some_mod.F90').write_text(fcode_mod)
(tmp_path/'caller.F90').write_text(fcode)

Expand Down Expand Up @@ -2564,7 +2563,7 @@ def transform_file(self, sourcefile, **kwargs):
(None, ['SOME_DEFINITION'], True, [], {}),
# Global preprocessing with local definition for one file, re-adding a dependency on 3
(
{'test_scheduler_frontend_args/file3_4.F90': {'defines': ['SOME_DEFINITION','LOCAL_DEFINITION']}},
{'file3_4.F90': {'defines': ['SOME_DEFINITION','LOCAL_DEFINITION']}},
['SOME_DEFINITION'],
True,
[],
Expand All @@ -2575,7 +2574,7 @@ def transform_file(self, sourcefile, **kwargs):
),
# Global preprocessing with preprocessing switched off for 2
(
{'test_scheduler_frontend_args/file2.F90': {'preprocess': False}},
{'file2.F90': {'preprocess': False}},
['SOME_DEFINITION'],
True,
['#test_scheduler_frontend_args2'],
Expand All @@ -2586,7 +2585,7 @@ def transform_file(self, sourcefile, **kwargs):
),
# No preprocessing except for 2
(
{'test_scheduler_frontend_args/file2.F90': {'preprocess': True, 'defines': ['SOME_DEFINITION']}},
{'file2.F90': {'preprocess': True, 'defines': ['SOME_DEFINITION']}},
None,
False,
['#test_scheduler_frontend_args1', '#test_scheduler_frontend_args4'],
Expand Down
1 change: 1 addition & 0 deletions loki/lint/tests/test_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
except ImportError:
HAVE_YAML = False

from loki.ir import Intrinsic
from loki.lint.linter import lint_files
from loki.lint.reporter import (
ProblemReport, RuleReport, FileReport,
Expand Down
5 changes: 3 additions & 2 deletions loki/tests/test_derived_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
StringSubscript, Conditional, CallStatement, ProcedureSymbol,
FindVariables
)
from loki.build import jit_compile, jit_compile_lib, clean_test
from loki.build import jit_compile, jit_compile_lib, clean_test, Obj
from loki.frontend import available_frontends, OMNI, OFP


Expand All @@ -32,7 +32,8 @@ def fixture_here():

@pytest.fixture(scope='module', name='builder')
def fixture_builder(here):
return Builder(source_dirs=here, build_dir=here/'build')
yield Builder(source_dirs=here, build_dir=here/'build')
Obj.clear_cache()


@pytest.mark.parametrize('frontend', available_frontends())
Expand Down
5 changes: 3 additions & 2 deletions loki/transformations/tests/test_array_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np

from loki import Module, Subroutine, fgen
from loki.build import jit_compile, jit_compile_lib, clean_test, Builder
from loki.build import jit_compile, jit_compile_lib, clean_test, Builder, Obj
from loki.expression import symbols as sym, FindVariables
from loki.frontend import available_frontends
from loki.ir import FindNodes, CallStatement
Expand All @@ -30,7 +30,8 @@ def fixture_here():

@pytest.fixture(scope='function', name='builder')
def fixture_builder(tmp_path):
return Builder(source_dirs=tmp_path, build_dir=tmp_path)
yield Builder(source_dirs=tmp_path, build_dir=tmp_path)
Obj.clear_cache()


@pytest.mark.parametrize('frontend', available_frontends())
Expand Down
5 changes: 3 additions & 2 deletions loki/transformations/tests/test_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Module, Subroutine, FindVariables, BasicType, DerivedType,
FindInlineCalls
)
from loki.build import jit_compile, jit_compile_lib, Builder
from loki.build import jit_compile, jit_compile_lib, Builder, Obj
from loki.expression import symbols as sym
from loki.frontend import available_frontends, OMNI, OFP
from loki.ir import nodes as ir, FindNodes
Expand All @@ -34,7 +34,8 @@ def fixture_here():

@pytest.fixture(scope='module', name='builder')
def fixture_builder(here):
return Builder(source_dirs=here, build_dir=here/'build')
yield Builder(source_dirs=here, build_dir=here/'build')
Obj.clear_cache()


@pytest.mark.parametrize('frontend', available_frontends())
Expand Down
5 changes: 3 additions & 2 deletions loki/transformations/tests/test_transform_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Module, Subroutine, Section, as_tuple, FindNodes, Loop,
Assignment, CallStatement, Intrinsic
)
from loki.build import jit_compile, jit_compile_lib, Builder
from loki.build import jit_compile, jit_compile_lib, Builder, Obj
from loki.expression import symbols as sym
from loki.frontend import available_frontends

Expand All @@ -25,7 +25,8 @@

@pytest.fixture(scope='function', name='builder')
def fixture_builder(tmp_path):
return Builder(source_dirs=tmp_path, build_dir=tmp_path/'build')
yield Builder(source_dirs=tmp_path, build_dir=tmp_path/'build')
Obj.clear_cache()


@pytest.mark.parametrize('frontend', available_frontends())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def fixture_here():
@pytest.fixture(scope='module', name='builder')
def fixture_builder(here):
include_dirs = get_max_includes() if is_maxeler_available() else []
return Builder(source_dirs=here, include_dirs=include_dirs, build_dir=here/'build')
yield Builder(source_dirs=here, include_dirs=include_dirs, build_dir=here/'build')
Obj.clear_cache()


def max_transpile(routine, path, builder, frontend, objects=None, wrap=None):
Expand Down
5 changes: 3 additions & 2 deletions loki/transformations/transpile/tests/test_transpile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np

from loki import Subroutine, Module, cgen
from loki.build import jit_compile, jit_compile_lib, clean_test, Builder
from loki.build import jit_compile, jit_compile_lib, clean_test, Builder, Obj
import loki.expression.symbols as sym
from loki.frontend import available_frontends, OFP
import loki.ir as ir
Expand All @@ -21,7 +21,8 @@

@pytest.fixture(scope='function', name='builder')
def fixture_builder(tmp_path):
return Builder(source_dirs=tmp_path, build_dir=tmp_path)
yield Builder(source_dirs=tmp_path, build_dir=tmp_path)
Obj.clear_cache()


@pytest.mark.parametrize('case_sensitive', (False, True))
Expand Down

0 comments on commit b4decea

Please sign in to comment.