Skip to content

Commit 1113679

Browse files
committed
Use gdb app yield
1 parent 16a6fce commit 1113679

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

numba_dpex/tests/debugging/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66

77
import pytest
88

9+
from .gdb import gdb
10+
911

1012
@pytest.fixture
1113
def app():
12-
from .gdb import gdb
14+
g = gdb()
15+
16+
yield g
1317

14-
return gdb()
18+
g.teardown_gdb()

numba_dpex/tests/debugging/gdb.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ def __init__(self):
2424
self.spawn()
2525
self.setup_gdb()
2626

27-
def __del__(self):
28-
self.teardown_gdb()
29-
3027
def spawn(self):
3128
env = os.environ.copy()
3229
env["NUMBA_OPT"] = "0"
@@ -50,8 +47,10 @@ def teardown_gdb(self):
5047
self.child.sendintr()
5148
self.child.expect("(gdb)", timeout=5)
5249
self.child.sendline("quit")
53-
self.child.expect("Quit anyway?", timeout=5)
54-
self.child.sendline("y")
50+
# We want to force quit only if program did not do it itself.
51+
index = self.child.expect(["Quit anyway?", pexpect.EOF], timeout=5)
52+
if index == 0:
53+
self.child.sendline("y")
5554

5655
def _command(self, command):
5756
self.child.expect("(gdb)", timeout=5)

0 commit comments

Comments
 (0)