Skip to content

Commit 5266702

Browse files
committed
Rewrite basic Fortran test without YAML
Signed-off-by: John Pennycook <john.pennycook@intel.com>
1 parent 237d475 commit 5266702

File tree

2 files changed

+44
-22
lines changed

2 files changed

+44
-22
lines changed

tests/basic_fortran/basic_fortran.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
# Copyright (C) 2019 Intel Corporation
1+
# Copyright (C) 2019-2024 Intel Corporation
22
# SPDX-License-Identifier: BSD-3-Clause
33

4-
import unittest
54
import logging
6-
from codebasin import config, finder, walkers
5+
import os
6+
import unittest
7+
8+
from codebasin import finder
79
from codebasin.walkers.platform_mapper import PlatformMapper
810

911

10-
class TestExampleFile(unittest.TestCase):
12+
class TestBasicFortran(unittest.TestCase):
1113
"""
1214
Simple test of ability to handle directives in Fortran code.
1315
"""
@@ -16,19 +18,50 @@ def setUp(self):
1618
self.rootdir = "./tests/basic_fortran/"
1719
logging.getLogger("codebasin").disabled = True
1820

19-
self.expected_setmap = {frozenset(['CPU']): 2,
20-
frozenset(['GPU']): 3,
21-
frozenset(['CPU', 'GPU']): 8}
21+
self.expected_setmap = {
22+
frozenset(["CPU"]): 2,
23+
frozenset(["GPU"]): 3,
24+
frozenset(["CPU", "GPU"]): 8,
25+
}
2226

2327
def test_yaml(self):
2428
"""basic_fortran/basic_fortran.yaml"""
25-
codebase, configuration = config.load(
26-
"./tests/basic_fortran/basic_fortran.yaml", self.rootdir)
29+
codebase = {
30+
"files": [
31+
os.path.realpath(os.path.join(self.rootdir, "test.f90")),
32+
],
33+
"platforms": ["CPU", "GPU"],
34+
"exclude_files": set(),
35+
"exclude_patterns": [],
36+
"rootdir": self.rootdir,
37+
}
38+
configuration = {
39+
"CPU": [
40+
{
41+
"file": codebase["files"][0],
42+
"defines": ["CPU"],
43+
"include_paths": [],
44+
"include_files": [],
45+
},
46+
],
47+
"GPU": [
48+
{
49+
"file": codebase["files"][0],
50+
"defines": ["GPU"],
51+
"include_paths": [],
52+
"include_files": [],
53+
},
54+
],
55+
}
2756
state = finder.find(self.rootdir, codebase, configuration)
2857
mapper = PlatformMapper(codebase)
2958
setmap = mapper.walk(state)
30-
self.assertDictEqual(setmap, self.expected_setmap, "Mismatch in setmap")
59+
self.assertDictEqual(
60+
setmap,
61+
self.expected_setmap,
62+
"Mismatch in setmap",
63+
)
3164

3265

33-
if __name__ == '__main__':
66+
if __name__ == "__main__":
3467
unittest.main()

0 commit comments

Comments
 (0)