Skip to content

Commit 8fc1e04

Browse files
committed
Rewrite disjoint test without YAML
Signed-off-by: John Pennycook <john.pennycook@intel.com>
1 parent fefd7d0 commit 8fc1e04

File tree

2 files changed

+58
-20
lines changed

2 files changed

+58
-20
lines changed

tests/disjoint/disjoint.yaml

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

tests/disjoint/test_disjoint.py

Lines changed: 58 additions & 9 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 TestDisjointCodebase(unittest.TestCase):
1113
"""
1214
Test of handling for disjoint code bases:
1315
- Separate file lists for each platform
@@ -18,17 +20,64 @@ def setUp(self):
1820
self.rootdir = "./tests/disjoint/"
1921
logging.getLogger("codebasin").disabled = True
2022

21-
self.expected_setmap = {frozenset(['CPU']): 6,
22-
frozenset(['GPU']): 6}
23+
self.expected_setmap = {frozenset(["CPU"]): 6, frozenset(["GPU"]): 6}
2324

2425
def test_yaml(self):
2526
"""disjoint/disjoint.yaml"""
26-
codebase, configuration = config.load("./tests/disjoint/disjoint.yaml", self.rootdir)
27+
files = [
28+
"cpu.cpp",
29+
"gpu.cpp",
30+
"cpu_headers/header.h",
31+
"gpu_headers/header.h",
32+
]
33+
codebase = {
34+
"files": [
35+
os.path.realpath(os.path.join(self.rootdir, f)) for f in files
36+
],
37+
"platforms": ["CPU", "GPU"],
38+
"exclude_files": set(),
39+
"exclude_patterns": [],
40+
"rootdir": self.rootdir,
41+
}
42+
configuration = {
43+
"CPU": [
44+
{
45+
"file": os.path.realpath(
46+
os.path.join(self.rootdir, "cpu.cpp"),
47+
),
48+
"defines": ["CPU"],
49+
"include_paths": [
50+
os.path.realpath(
51+
os.path.join(self.rootdir, "cpu_headers"),
52+
),
53+
],
54+
"include_files": [],
55+
},
56+
],
57+
"GPU": [
58+
{
59+
"file": os.path.realpath(
60+
os.path.join(self.rootdir, "gpu.cpp"),
61+
),
62+
"defines": ["GPU"],
63+
"include_paths": [
64+
os.path.realpath(
65+
os.path.join(self.rootdir, "gpu_headers"),
66+
),
67+
],
68+
"include_files": [],
69+
},
70+
],
71+
}
2772
state = finder.find(self.rootdir, codebase, configuration)
2873
mapper = PlatformMapper(codebase)
2974
setmap = mapper.walk(state)
30-
self.assertDictEqual(setmap, self.expected_setmap, "Mismatch in setmap")
75+
self.assertDictEqual(
76+
setmap,
77+
self.expected_setmap,
78+
"Mismatch in setmap",
79+
)
3180

3281

33-
if __name__ == '__main__':
82+
if __name__ == "__main__":
3483
unittest.main()

0 commit comments

Comments
 (0)