Skip to content

Commit b160b71

Browse files
committed
Add basic directory_cache test
This class was not tested at all. At least now the cache mechanism is run in it’s most basic form.
1 parent 43e257f commit b160b71

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

unittests/test_all.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import test_smart_pointer
7575
import test_pattern_parser
7676
import test_function_pointer
77+
import test_directory_cache
7778

7879
testers = [
7980
# , demangled_tester # failing right now
@@ -140,7 +141,8 @@
140141
test_argument_without_name,
141142
test_smart_pointer,
142143
test_pattern_parser,
143-
test_function_pointer
144+
test_function_pointer,
145+
test_directory_cache
144146
]
145147

146148
if 'posix' in os.name:

unittests/test_directory_cache.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2014-2016 Insight Software Consortium.
2+
# Copyright 2004-2009 Roman Yakovenko.
3+
# Distributed under the Boost Software License, Version 1.0.
4+
# See http://www.boost.org/LICENSE_1_0.txt
5+
6+
import unittest
7+
import parser_test_case
8+
9+
from pygccxml import parser
10+
11+
12+
class Test(parser_test_case.parser_test_case_t):
13+
14+
def __init__(self, *args):
15+
parser_test_case.parser_test_case_t.__init__(self, *args)
16+
self.header = "core_cache.hpp"
17+
18+
def test_elaborated_types(self):
19+
"""
20+
Test the directory cache
21+
22+
"""
23+
24+
cache = parser.directory_cache_t(
25+
directory="unittests/data/directory_cache_test")
26+
# Generate a cache on first read
27+
parser.parse([self.header], self.config, cache=cache)
28+
# Read from the cache the second time
29+
parser.parse([self.header], self.config, cache=cache)
30+
31+
32+
def create_suite():
33+
suite = unittest.TestSuite()
34+
suite.addTest(unittest.makeSuite(Test))
35+
return suite
36+
37+
38+
def run_suite():
39+
unittest.TextTestRunner(verbosity=2).run(create_suite())
40+
41+
if __name__ == "__main__":
42+
run_suite()

0 commit comments

Comments
 (0)