Skip to content

Commit 9d23c2a

Browse files
committed
test: debug test
1 parent 4beedf5 commit 9d23c2a

File tree

5 files changed

+63
-49
lines changed

5 files changed

+63
-49
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@ jobs:
102102
- name: Run tests
103103
run: |
104104
export PATH=~/castxml/bin:$PATH
105-
pytest tests
105+
pytest tests/test_vector_traits.py

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ docs = [
6464
examples = [
6565
"notebook",
6666
]
67+
[tool.pytest.ini_options]
68+
pythonpath = ["src"]

src/pygccxml/declarations/container_traits.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ def __find_xxx_type(
467467
xxx_typedef,
468468
cache_property_name):
469469
cls_declaration = self.class_declaration(type_)
470+
print(cls_declaration, cls_declaration.top_parent)
470471
result = getattr(cls_declaration.cache, cache_property_name)
471472
if not result:
472473
if isinstance(cls_declaration, class_declaration.class_t):
@@ -475,8 +476,10 @@ def __find_xxx_type(
475476
result = type_traits.remove_declarated(xxx_type)
476477
else:
477478
xxx_type_str = templates.args(cls_declaration.name)[xxx_index]
479+
print("xxx_type_str", xxx_type_str)
478480
result = traits_impl_details.impl_details.find_value_type(
479481
cls_declaration.top_parent, xxx_type_str)
482+
print("result", result)
480483
if None is result:
481484
raise RuntimeError(
482485
"Unable to find out %s '%s' key\\value type." %

src/pygccxml/declarations/traits_impl_details.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,16 @@ def is_defined_in_xxx(xxx, cls):
4444
@staticmethod
4545
def find_value_type(global_ns, value_type_str):
4646
"""implementation details"""
47+
print("find_value_type", value_type_str)
4748
if not value_type_str.startswith('::'):
4849
value_type_str = '::' + value_type_str
4950
found = global_ns.decls(
5051
name=value_type_str,
5152
function=lambda decl: not isinstance(decl, calldef.calldef_t),
5253
allow_empty=True)
54+
print("xxx", found, len(found))
55+
for d in found:
56+
print("found", d)
5357
if not found:
5458
no_global_ns_value_type_str = value_type_str[2:]
5559
if no_global_ns_value_type_str in cpptypes.FUNDAMENTAL_TYPES:

tests/test_vector_traits.py

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
"vector_traits.hpp",
1616
]
1717

18+
# import logging
19+
# from pygccxml import utils
20+
# utils.loggers.set_level(logging.DEBUG)
21+
1822

1923
@pytest.fixture
2024
def global_ns():
@@ -30,59 +34,60 @@ def global_ns():
3034
return global_ns
3135

3236

33-
def validate_yes(value_type, container):
34-
traits = declarations.vector_traits
35-
assert traits.is_my_case(container) is True
36-
assert declarations.is_same(
37-
value_type,
38-
traits.element_type(container)) is True
39-
assert traits.is_sequence(container) is True
40-
41-
42-
def test_global_ns(global_ns):
43-
value_type = global_ns.class_('_0_')
44-
container = global_ns.typedef('container', recursive=False)
45-
validate_yes(value_type, container)
46-
47-
48-
def test_yes(global_ns):
49-
yes_ns = global_ns.namespace('yes')
50-
for struct in yes_ns.classes():
51-
if not struct.name.startswith('_'):
52-
continue
53-
if not struct.name.endswith('_'):
54-
continue
55-
validate_yes(
56-
struct.typedef('value_type'),
57-
struct.typedef('container'))
58-
59-
60-
def test_no(global_ns):
61-
traits = declarations.vector_traits
62-
no_ns = global_ns.namespace('no')
63-
for struct in no_ns.classes():
64-
if not struct.name.startswith('_'):
65-
continue
66-
if not struct.name.endswith('_'):
67-
continue
68-
assert traits.is_my_case(struct.typedef('container')) is False
69-
70-
71-
def test_declaration():
72-
cnt = (
73-
'std::vector<std::basic_string<char, std::char_traits<char>, ' +
74-
'std::allocator<char>>,std::allocator<std::basic_string<char, ' +
75-
'std::char_traits<char>, std::allocator<char>>>>' +
76-
'@::std::vector<std::basic_string<char, std::char_traits<char>, ' +
77-
'std::allocator<char>>, std::allocator<std::basic_string<char, ' +
78-
'std::char_traits<char>, std::allocator<char>>>>')
79-
traits = declarations.find_container_traits(cnt)
80-
assert declarations.vector_traits == traits
37+
# def validate_yes(value_type, container):
38+
# traits = declarations.vector_traits
39+
# assert traits.is_my_case(container) is True
40+
# assert declarations.is_same(
41+
# value_type,
42+
# traits.element_type(container)) is True
43+
# assert traits.is_sequence(container) is True
44+
45+
46+
# def test_global_ns(global_ns):
47+
# value_type = global_ns.class_('_0_')
48+
# container = global_ns.typedef('container', recursive=False)
49+
# validate_yes(value_type, container)
50+
51+
52+
# def test_yes(global_ns):
53+
# yes_ns = global_ns.namespace('yes')
54+
# for struct in yes_ns.classes():
55+
# if not struct.name.startswith('_'):
56+
# continue
57+
# if not struct.name.endswith('_'):
58+
# continue
59+
# validate_yes(
60+
# struct.typedef('value_type'),
61+
# struct.typedef('container'))
62+
63+
64+
# def test_no(global_ns):
65+
# traits = declarations.vector_traits
66+
# no_ns = global_ns.namespace('no')
67+
# for struct in no_ns.classes():
68+
# if not struct.name.startswith('_'):
69+
# continue
70+
# if not struct.name.endswith('_'):
71+
# continue
72+
# assert traits.is_my_case(struct.typedef('container')) is False
73+
74+
75+
# def test_declaration():
76+
# cnt = (
77+
# 'std::vector<std::basic_string<char, std::char_traits<char>, ' +
78+
# 'std::allocator<char>>,std::allocator<std::basic_string<char, ' +
79+
# 'std::char_traits<char>, std::allocator<char>>>>' +
80+
# '@::std::vector<std::basic_string<char, std::char_traits<char>, ' +
81+
# 'std::allocator<char>>, std::allocator<std::basic_string<char, ' +
82+
# 'std::char_traits<char>, std::allocator<char>>>>')
83+
# traits = declarations.find_container_traits(cnt)
84+
# assert declarations.vector_traits == traits
8185

8286

8387
def test_element_type(global_ns):
8488
do_nothing = global_ns.free_function('do_nothing')
8589
v = declarations.remove_reference(
8690
declarations.remove_declarated(
8791
do_nothing.arguments[0].decl_type))
92+
print("v", v)
8893
declarations.vector_traits.element_type(v)

0 commit comments

Comments
 (0)