Skip to content

Commit a15eddf

Browse files
committed
Add skip functional test...
ignore speces in trace output
1 parent 15a3c66 commit a15eddf

3 files changed

Lines changed: 26 additions & 24 deletions

File tree

test/functional/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""
2+
Functional tests. In contrast to most unit tesets,
3+
these tests work with a Trepan debugger object and traces or debugs some code with it, testing some particular
4+
aspect of debugging, such as the ability to step, skip or jump to debugged lines, hit breakpoints, etc.
5+
"""

test/functional/fn_helper.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,36 @@ def strarray_setup(debugger_cmds):
2525
trepan_loc = re.compile(r"^\(.+:\d+\): ")
2626

2727

28-
def filter_line_cmd(a):
28+
def filter_line_cmd(a: list) -> list:
2929
"""Return output with source lines prompt and command removed"""
3030
# Remove extra leading spaces.
3131
# For example:
3232
# -- 42 y = 5
3333
# becomes
3434
# -- y = 5
3535
a1 = [re.sub(r"^(..) \d+\s+", r"\1 ", s) for s in a if re.match(r"^.. \d+\s+", s)]
36+
3637
# Remove debugger prompts
3738
# For example:
3839
# (trepan3k)
3940
a2 = [re.sub(r"\n\(trepan3k\) .*", "", s) for s in a1]
4041

4142
# Remove locations (test-next.py:41): test_next_between_fn
4243
a3 = [re.sub(r"\n\(.*:\d+\):.*", "", s) for s in a2]
43-
return a3
44+
45+
# Strip leading and trailing blanks.
46+
a4 = [s.strip() for s in a3]
47+
48+
return a4
4449

4550

46-
def get_lineno():
51+
def get_lineno() -> int:
4752
"""Return the caller's line number"""
4853
caller = sys._getframe(1)
4954
return caller.f_lineno
5055

5156

52-
def compare_output(obj, right, d):
57+
def compare_output(obj, right: list, d):
5358
got = filter_line_cmd(d.intf[-1].output.output)
5459
if got != right:
5560
for i in range(len(got)):
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
#!/usr/bin/env python
2-
import os, unittest
3-
from fn_helper import strarray_setup, compare_output
1+
import unittest
2+
from test.functional.fn_helper import compare_output, strarray_setup
43

54

65
class TestSkip(unittest.TestCase):
7-
@unittest.skip("FIXME: figure out why this doesn't work")
86
def test_skip(self):
9-
107
# See that we can skip without parameter. (Same as 'skip 1'.)
11-
cmds = ['skip', 'continue']
8+
cmds = ["skip", "continue"]
129
d = strarray_setup(cmds)
1310
d.core.start()
1411
##############################
@@ -17,29 +14,24 @@ def test_skip(self):
1714
y = 7 # NOQA
1815
##############################
1916
d.core.stop()
20-
out = ['-- x = 4', # x = 4 is shown in prompt, but not *run*.
21-
'-- x = 5']
22-
compare_output(self, out, d, cmds)
17+
out = ["-- x = 4", "-- x = 5"] # x = 4 is shown in prompt, but not *run*.
18+
compare_output(self, out, d)
2319
self.assertEqual(5, x) # Make sure lines were skipped.
2420

2521
# See that we can skip with a count value
26-
print("skipping second skip test")
27-
return
28-
cmds = ['skip 2', 'continue']
22+
cmds = ["skip 2", "continue"]
2923
d = strarray_setup(cmds)
3024
d.core.start()
3125
##############################
3226
x = 10
3327
x = 9
3428
z = 7 # NOQA
3529
##############################
36-
d.core.stop(options={'remove': True})
37-
out = ['-- x = 10', # x = 10 is shown in prompt, but not run.
38-
'-- z = 7']
39-
compare_output(self, out, d, cmds)
30+
d.core.stop(options={"remove": True})
31+
out = [
32+
"-- x = 10",
33+
"-- z = 7 # NOQA",
34+
] # x = 10 is shown in prompt, but not run.
35+
compare_output(self, out, d)
4036
self.assertEqual(5, x) # Make sure x = 10, 9 were skipped.
4137
return
42-
pass
43-
44-
if __name__ == '__main__':
45-
unittest.main()

0 commit comments

Comments
 (0)