Skip to content

Commit 234375f

Browse files
committed
Rewrite nesting test without YAML
Signed-off-by: John Pennycook <john.pennycook@intel.com>
1 parent 5f98245 commit 234375f

File tree

2 files changed

+45
-21
lines changed

2 files changed

+45
-21
lines changed

tests/nesting/nesting.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/nesting/test_nesting.py

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +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

9-
class TestExampleFile(unittest.TestCase):
11+
12+
class TestNesting(unittest.TestCase):
1013
"""
1114
Simple test of ability to handle nested definition scopes
1215
"""
@@ -15,18 +18,50 @@ def setUp(self):
1518
self.rootdir = "./tests/nesting/"
1619
logging.getLogger("codebasin").disabled = True
1720

18-
self.expected_setmap = {frozenset(['CPU']): 6,
19-
frozenset(['GPU']): 6,
20-
frozenset(['CPU', 'GPU']): 5}
21+
self.expected_setmap = {
22+
frozenset(["CPU"]): 6,
23+
frozenset(["GPU"]): 6,
24+
frozenset(["CPU", "GPU"]): 5,
25+
}
2126

2227
def test_yaml(self):
2328
"""nesting/nesting.yaml"""
24-
codebase, configuration = config.load("./tests/nesting/nesting.yaml", self.rootdir)
29+
codebase = {
30+
"files": [
31+
os.path.realpath(os.path.join(self.rootdir, "main.cpp")),
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+
}
2556
state = finder.find(self.rootdir, codebase, configuration)
2657
mapper = PlatformMapper(codebase)
2758
setmap = mapper.walk(state)
28-
self.assertDictEqual(setmap, self.expected_setmap, "Mismatch in setmap")
59+
self.assertDictEqual(
60+
setmap,
61+
self.expected_setmap,
62+
"Mismatch in setmap",
63+
)
2964

3065

31-
if __name__ == '__main__':
66+
if __name__ == "__main__":
3267
unittest.main()

0 commit comments

Comments
 (0)