Skip to content

Commit d23fb27

Browse files
committed
Skip compiling diamond pattern tests by default
1 parent dbb6c7e commit d23fb27

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

tests/test_virtual_functions.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,11 @@ class Final: public virtual Interface {
472472
}
473473
};
474474

475+
#ifndef RUN_DIAMOND
476+
#define RUN_DIAMOND 0
477+
#endif /* ifndef RUN_DIAMOND */
478+
479+
#if RUN_DIAMOND
475480
class B_Concrete: public virtual Interface {
476481
public:
477482
virtual int run(Interface* ptr) {
@@ -496,10 +501,13 @@ class Diamond: public C_Concrete, public B_Concrete {
496501
#pragma warning(pop)
497502
#endif
498503

504+
#endif /* if RUN_DIAMOND */
505+
499506
void initialize_virtual_inheritance(py::module &m) {
500507
py::class_<Interface>(m, "Interface").def("run", &Interface::run);
501508
py::class_<Final, Interface>(m, "Final").def(py::init<>());
502509

510+
#if RUN_DIAMOND
503511
py::class_<B_Concrete, Interface>(m, "B_Concrete");
504512
py::class_<C_Concrete, Interface>(m, "C_Concrete");
505513
py::class_<Diamond, B_Concrete, C_Concrete>(m, "Diamond").def(py::init<>());
@@ -508,4 +516,5 @@ void initialize_virtual_inheritance(py::module &m) {
508516
Diamond d = Diamond();
509517
return d.run(&d);
510518
}, "Runs the diamond test in c++");
519+
#endif /* if RUN_DIAMOND */
511520
}

tests/test_virtual_functions.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def get_string2(self):
4040

4141
with pytest.raises(RuntimeError) as excinfo:
4242
m.runExampleVirtVirtual(ex12)
43-
assert msg(excinfo.value) == 'Tried to call pure virtual function "ExampleVirt::pure_virtual"'
43+
assert msg(
44+
excinfo.value
45+
) == 'Tried to call pure virtual function "ExampleVirt::pure_virtual"'
4446

4547
ex12p = ExtendedExampleVirt(10)
4648
with capture:
@@ -79,6 +81,7 @@ def test_alias_delay_initialization1(capture):
7981
If we just create and use an A instance directly, the trampoline initialization is
8082
bypassed and we only initialize an A() instead (for performance reasons).
8183
"""
84+
8285
class B(m.A):
8386
def __init__(self):
8487
super(B, self).__init__()
@@ -115,6 +118,7 @@ def test_alias_delay_initialization2(capture):
115118
performance penalty, it also allows us to do more things with the trampoline
116119
class such as defining local variables and performing construction/destruction.
117120
"""
121+
118122
class B2(m.A2):
119123
def __init__(self):
120124
super(B2, self).__init__()
@@ -160,7 +164,8 @@ def f(self):
160164
# PyPy: Reference count > 1 causes call with noncopyable instance
161165
# to fail in ncv1.print_nc()
162166
@pytest.unsupported_on_pypy
163-
@pytest.mark.skipif(not hasattr(m, "NCVirt"), reason="NCVirt test broken on ICPC")
167+
@pytest.mark.skipif(
168+
not hasattr(m, "NCVirt"), reason="NCVirt test broken on ICPC")
164169
def test_move_support():
165170
class NCVirtExt(m.NCVirt):
166171
def get_noncopyable(self, a, b):
@@ -209,6 +214,7 @@ def get_movable(self, a, b):
209214

210215
def test_dispatch_issue(msg):
211216
"""#159: virtual function dispatch has problems with similar-named functions"""
217+
212218
class PyClass1(m.DispatchIssue):
213219
def dispatch(self):
214220
return "Yay.."
@@ -217,7 +223,9 @@ class PyClass2(m.DispatchIssue):
217223
def dispatch(self):
218224
with pytest.raises(RuntimeError) as excinfo:
219225
super(PyClass2, self).dispatch()
220-
assert msg(excinfo.value) == 'Tried to call pure virtual function "Base::dispatch"'
226+
assert msg(
227+
excinfo.value
228+
) == 'Tried to call pure virtual function "Base::dispatch"'
221229

222230
p = PyClass1()
223231
return m.dispatch_issue_go(p)
@@ -372,9 +380,12 @@ def lucky_number(self):
372380

373381

374382
def test_virtual_inheritance():
375-
376383
final = m.Final()
377384
assert final.run(final) == 6
378-
diamond = m.Diamond()
379-
assert diamond.run(diamond) == 4
380-
assert m.run_virtual_inheritance() == 4
385+
try:
386+
diamond = m.Diamond()
387+
except AttributeError:
388+
pass
389+
else:
390+
assert diamond.run(diamond) == 4
391+
assert m.run_virtual_inheritance() == 4

0 commit comments

Comments
 (0)