Skip to content

Commit 1c2b906

Browse files
committed
tests: fix macos tests
1 parent aa563e6 commit 1c2b906

File tree

5 files changed

+171
-155
lines changed

5 files changed

+171
-155
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_remove_template_defaults.py

pyproject.toml

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

src/pygccxml/declarations/container_traits.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def normalize(self, type_str):
2929
return type_str.replace(' ', '')
3030

3131
def replace_basic_string(self, cls_name):
32-
32+
print("replace_basic_string", cls_name)
3333
# Take the lists of all possible string variations
3434
# and clean them up by replacing ::std by std.
3535
str_eq = [
@@ -99,10 +99,13 @@ def erase_recursive(self, cls_name):
9999
return self.no_end_const(cls_name)
100100

101101
def erase_allocator(self, cls_name, default_allocator='std::allocator'):
102+
print("erase_allocator", cls_name)
102103
cls_name = self.replace_basic_string(cls_name)
104+
print("erase_allocator", cls_name)
103105
c_name, c_args = templates.split(cls_name)
106+
print("c_name, c_args", c_name, c_args)
104107
if len(c_args) != 2:
105-
return
108+
return cls_name
106109
value_type = c_args[0]
107110
tmpl = string.Template(
108111
"$container< $value_type, $allocator<$value_type> >")
@@ -119,12 +122,12 @@ def erase_container(self, cls_name, default_container_name='std::deque'):
119122
cls_name = self.replace_basic_string(cls_name)
120123
c_name, c_args = templates.split(cls_name)
121124
if len(c_args) != 2:
122-
return
125+
return cls_name
123126
value_type = c_args[0]
124127
dc_no_defaults = self.erase_recursive(c_args[1])
125128
if self.normalize(dc_no_defaults) != self.normalize(
126129
templates.join(default_container_name, [value_type])):
127-
return
130+
return cls_name
128131
return templates.join(
129132
c_name, [self.erase_recursive(value_type)])
130133

@@ -136,7 +139,7 @@ def erase_container_compare(
136139
cls_name = self.replace_basic_string(cls_name)
137140
c_name, c_args = templates.split(cls_name)
138141
if len(c_args) != 3:
139-
return
142+
return cls_name
140143
dc_no_defaults = self.erase_recursive(c_args[1])
141144
if self.normalize(dc_no_defaults) != self.normalize(
142145
templates.join(default_container_name, [c_args[0]])):
@@ -156,7 +159,7 @@ def erase_compare_allocator(
156159
cls_name = self.replace_basic_string(cls_name)
157160
c_name, c_args = templates.split(cls_name)
158161
if len(c_args) != 3:
159-
return
162+
return cls_name
160163
value_type = c_args[0]
161164
tmpl = string.Template(
162165
"$container< $value_type, $compare<$value_type>, " +
@@ -179,7 +182,7 @@ def erase_map_compare_allocator(
179182
cls_name = self.replace_basic_string(cls_name)
180183
c_name, c_args = templates.split(cls_name)
181184
if len(c_args) != 4:
182-
return
185+
return cls_name
183186
key_type = c_args[0]
184187
mapped_type = c_args[1]
185188
tmpls = [
@@ -209,7 +212,7 @@ def erase_hash_allocator(self, cls_name):
209212
cls_name = self.replace_basic_string(cls_name)
210213
c_name, c_args = templates.split(cls_name)
211214
if len(c_args) < 3:
212-
return
215+
return cls_name
213216

214217
default_less = 'std::less'
215218
default_equal_to = 'std::equal_to'
@@ -226,7 +229,7 @@ def erase_hash_allocator(self, cls_name):
226229
"$container< $value_type, $hash<$value_type >, " +
227230
"$equal_to<$value_type >, $allocator<$value_type> >")
228231
else:
229-
return
232+
return cls_name
230233

231234
value_type = c_args[0]
232235
template = string.Template(tmpl)
@@ -258,7 +261,7 @@ def erase_hashmap_compare_allocator(self, cls_name):
258261
key_type = c_args[0]
259262
mapped_type = c_args[1]
260263
else:
261-
return
264+
return cls_name
262265

263266
if len(c_args) == 4:
264267
default_hash = 'hash_compare'
@@ -305,7 +308,7 @@ def erase_hashmap_compare_allocator(self, cls_name):
305308
"$equal_to<$key_type>, " +
306309
"$allocator< $mapped_type > >")
307310
else:
308-
return
311+
return cls_name
309312

310313
for ns in std_namespaces:
311314
inst = tmpl.substitute(
@@ -520,14 +523,13 @@ def remove_defaults(self, type_or_string):
520523
std::vector< int >
521524
522525
"""
523-
524526
name = type_or_string
525527
if not isinstance(type_or_string, str):
526528
name = self.class_declaration(type_or_string).name
527529
if not self.remove_defaults_impl:
528530
return name
529531
no_defaults = self.remove_defaults_impl(name)
530-
if not no_defaults:
532+
if no_defaults is None:
531533
return name
532534
return no_defaults
533535

src/pygccxml/declarations/type_traits.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,22 +482,32 @@ def is_fundamental(type_):
482482

483483
string_equivalences = [
484484
(
485-
'::std::basic_string<char,std::char_traits<char>,'
485+
'std::basic_string<char, std::char_traits<char>, '
486+
'std::allocator<char>>, '
487+
'std::allocator<std::basic_string<'
488+
'char, std::char_traits<char>, std::allocator<char>>>'),
489+
(
490+
'::std::basic_string<char, std::char_traits<char>, '
486491
'std::allocator<char>>'),
487492
'::std::basic_string<char>', '::std::string']
488493

489494
wstring_equivalences = [
490495
(
491-
'::std::basic_string<wchar_t,std::char_traits<wchar_t>,' +
496+
'std::basic_string<wchar_t, std::char_traits<wchar_t>, '
497+
'std::allocator<wchar_t>>, '
498+
'std::allocator<std::basic_string<'
499+
'wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>>'),
500+
(
501+
'::std::basic_string<wchar_t, std::char_traits<wchar_t>, '
492502
'std::allocator<wchar_t>>'),
493503
'::std::basic_string<wchar_t>', '::std::wstring']
494504

495505
ostream_equivalences = [
496-
'::std::basic_ostream<char,std::char_traits<char>>',
506+
'::std::basic_ostream<char std::char_traits<char>>',
497507
'::std::basic_ostream<char>', '::std::ostream']
498508

499509
wostream_equivalences = [
500-
'::std::basic_ostream<wchar_t,std::char_traits<wchar_t>>',
510+
'::std::basic_ostream<wchar_t, std::char_traits<wchar_t>>',
501511
'::std::basic_ostream<wchar_t>', '::std::wostream']
502512

503513

0 commit comments

Comments
 (0)