Skip to content

Commit ce87716

Browse files
committed
tests: fix macos tests
1 parent 682dc7e commit ce87716

File tree

4 files changed

+167
-163
lines changed

4 files changed

+167
-163
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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,6 @@ examples = [
6565
"notebook",
6666
]
6767
[tool.pytest.ini_options]
68-
pythonpath = [
69-
"src"]
68+
pythonpath = [
69+
"src"
70+
]

src/pygccxml/declarations/container_traits.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ def erase_recursive(self, cls_name):
9696
return self.no_end_const(cls_name)
9797

9898
def erase_allocator(self, cls_name, default_allocator='std::allocator'):
99-
cls_name = self.replace_basic_string(cls_name)
99+
print("erase_allocator", cls_name)
100100
c_name, c_args = templates.split(cls_name)
101+
print("c_name, c_args", c_name, c_args)
101102
if len(c_args) != 2:
102-
return
103+
return cls_name
103104
value_type = c_args[0]
104105
tmpl = string.Template(
105106
"$container< $value_type, $allocator<$value_type> >")
@@ -109,19 +110,22 @@ def erase_allocator(self, cls_name, default_allocator='std::allocator'):
109110
allocator=default_allocator)
110111
if self.normalize(cls_name) == \
111112
self.normalize(tmpl):
112-
return templates.join(
113+
result = templates.join(
113114
c_name, [self.erase_recursive(value_type)])
115+
print("result", result)
116+
print("c_name", c_name)
117+
print("value_type", value_type)
118+
return result
114119

115120
def erase_container(self, cls_name, default_container_name='std::deque'):
116-
cls_name = self.replace_basic_string(cls_name)
117121
c_name, c_args = templates.split(cls_name)
118122
if len(c_args) != 2:
119-
return
123+
return cls_name
120124
value_type = c_args[0]
121125
dc_no_defaults = self.erase_recursive(c_args[1])
122126
if self.normalize(dc_no_defaults) != self.normalize(
123127
templates.join(default_container_name, [value_type])):
124-
return
128+
return None
125129
return templates.join(
126130
c_name, [self.erase_recursive(value_type)])
127131

@@ -130,10 +134,9 @@ def erase_container_compare(
130134
cls_name,
131135
default_container_name='std::vector',
132136
default_compare='std::less'):
133-
cls_name = self.replace_basic_string(cls_name)
134137
c_name, c_args = templates.split(cls_name)
135138
if len(c_args) != 3:
136-
return
139+
return cls_name
137140
dc_no_defaults = self.erase_recursive(c_args[1])
138141
if self.normalize(dc_no_defaults) != self.normalize(
139142
templates.join(default_container_name, [c_args[0]])):
@@ -150,10 +153,9 @@ def erase_compare_allocator(
150153
cls_name,
151154
default_compare='std::less',
152155
default_allocator='std::allocator'):
153-
cls_name = self.replace_basic_string(cls_name)
154156
c_name, c_args = templates.split(cls_name)
155157
if len(c_args) != 3:
156-
return
158+
return cls_name
157159
value_type = c_args[0]
158160
tmpl = string.Template(
159161
"$container< $value_type, $compare<$value_type>, " +
@@ -173,10 +175,9 @@ def erase_map_compare_allocator(
173175
cls_name,
174176
default_compare='std::less',
175177
default_allocator='std::allocator'):
176-
cls_name = self.replace_basic_string(cls_name)
177178
c_name, c_args = templates.split(cls_name)
178179
if len(c_args) != 4:
179-
return
180+
return cls_name
180181
key_type = c_args[0]
181182
mapped_type = c_args[1]
182183
tmpls = [
@@ -203,10 +204,9 @@ def erase_map_compare_allocator(
203204
self.erase_recursive(mapped_type)])
204205

205206
def erase_hash_allocator(self, cls_name):
206-
cls_name = self.replace_basic_string(cls_name)
207207
c_name, c_args = templates.split(cls_name)
208208
if len(c_args) < 3:
209-
return
209+
return cls_name
210210

211211
default_less = 'std::less'
212212
default_equal_to = 'std::equal_to'
@@ -223,7 +223,7 @@ def erase_hash_allocator(self, cls_name):
223223
"$container< $value_type, $hash<$value_type >, " +
224224
"$equal_to<$value_type >, $allocator<$value_type> >")
225225
else:
226-
return
226+
return cls_name
227227

228228
value_type = c_args[0]
229229
template = string.Template(tmpl)
@@ -241,7 +241,6 @@ def erase_hash_allocator(self, cls_name):
241241
c_name, [self.erase_recursive(value_type)])
242242

243243
def erase_hashmap_compare_allocator(self, cls_name):
244-
cls_name = self.replace_basic_string(cls_name)
245244
c_name, c_args = templates.split(cls_name)
246245

247246
if self.unordered_maps_and_sets:
@@ -255,7 +254,7 @@ def erase_hashmap_compare_allocator(self, cls_name):
255254
key_type = c_args[0]
256255
mapped_type = c_args[1]
257256
else:
258-
return
257+
return cls_name
259258

260259
if len(c_args) == 4:
261260
default_hash = 'hash_compare'
@@ -302,7 +301,7 @@ def erase_hashmap_compare_allocator(self, cls_name):
302301
"$equal_to<$key_type>, " +
303302
"$allocator< $mapped_type > >")
304303
else:
305-
return
304+
return cls_name
306305

307306
for ns in std_namespaces:
308307
inst = tmpl.substitute(
@@ -517,15 +516,18 @@ def remove_defaults(self, type_or_string):
517516
std::vector< int >
518517
519518
"""
520-
521519
name = type_or_string
522520
if not isinstance(type_or_string, str):
521+
print(
522+
"xxxx",
523+
type(self.class_declaration(type_or_string)),
524+
self.class_declaration(type_or_string).name
525+
)
523526
name = self.class_declaration(type_or_string).name
524527
if not self.remove_defaults_impl:
525528
return name
529+
name = self.replace_basic_string(name)
526530
no_defaults = self.remove_defaults_impl(name)
527-
if not no_defaults:
528-
return name
529531
return no_defaults
530532

531533

0 commit comments

Comments
 (0)