Skip to content

Commit 18477d7

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

File tree

2 files changed

+45
-20
lines changed

2 files changed

+45
-20
lines changed

tests/once/once.yaml

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

tests/once/test_once.py

Lines changed: 45 additions & 9 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 TestOnce(unittest.TestCase):
1013
"""
1114
Simple test of ability to obey #pragma once directives.
1215
"""
@@ -15,17 +18,50 @@ def setUp(self):
1518
self.rootdir = "./tests/once/"
1619
logging.getLogger("codebasin").disabled = True
1720

18-
self.expected_setmap = {frozenset([]): 4,
19-
frozenset(['CPU', 'GPU']): 10}
21+
self.expected_setmap = {
22+
frozenset([]): 4,
23+
frozenset(["CPU", "GPU"]): 10,
24+
}
2025

2126
def test_yaml(self):
2227
"""once/once.yaml"""
23-
codebase, configuration = config.load("./tests/once/once.yaml", self.rootdir)
28+
codebase = {
29+
"files": [
30+
os.path.realpath(os.path.join(self.rootdir, "main.cpp")),
31+
os.path.realpath(os.path.join(self.rootdir, "once.h")),
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+
}
2456
state = finder.find(self.rootdir, codebase, configuration)
2557
mapper = PlatformMapper(codebase)
2658
setmap = mapper.walk(state)
27-
self.assertDictEqual(setmap, self.expected_setmap, "Mismatch in setmap")
59+
self.assertDictEqual(
60+
setmap,
61+
self.expected_setmap,
62+
"Mismatch in setmap",
63+
)
2864

2965

30-
if __name__ == '__main__':
66+
if __name__ == "__main__":
3167
unittest.main()

0 commit comments

Comments
 (0)