Skip to content

Commit 81d50c0

Browse files
committed
First batch of functional tests
1 parent 1db47a5 commit 81d50c0

10 files changed

Lines changed: 77 additions & 22 deletions

File tree

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LINT =o flake8
1212
PHONY=check clean dist distclean test test-unit test-functional rmChangeLog nosetests flake8
1313

1414
#: Default target - same as "check"
15-
all: test-unit
15+
all: check
1616

1717
#: Same as "check"
1818
test: check
@@ -27,15 +27,15 @@ flake8:
2727

2828
#: Run all tests: unit, functional and integration verbosely
2929
# check: test-unit test-functional test-integration # flake8
30-
check: test-unit
30+
check: test-unit test-functional
3131

3232
#: Run unit (transparent-box) tests
3333
test-unit:
3434
$(PYTHON) -m pytest test/unit
3535

3636
#: Run functional tests
37-
test-functional:
38-
(cd test/functional && $(PYTHON) ./setup.py nosetests)
37+
check-functional test-functional:
38+
(cd test/functional && $(PYTHON) -m pytest .)
3939

4040
#: Run functional tests
4141
test-functional-short:

test/functional/test_jump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_skip(self):
2525
##############################
2626
d.core.stop(options={"remove": True})
2727
out = [
28-
"-- x = 4\n", # x = 4 is shown in prompt, but not run.
28+
"-- x = 4", # x = 4 is shown in prompt, but not run.
2929
"-- x = 5",
3030
"-- z = 7 # NOQA",
3131
]

test/unit/lib/test_lib_eval.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python3
2-
"Unit test for trepan.lib.eval"
1+
"""Unit test for trepan.lib.eval"""
32

43
from trepan.lib import eval as Meval
54

test/unit/lib/test_lib_format.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"Unit test for trepan.lib.file"
1+
"""Unit test for trepan.lib.file"""
22
import sys
33

44
from pygments.lexers import RstLexer
@@ -50,6 +50,3 @@ def test_mono():
5050
"End of test. " == got
5151
)
5252
return
53-
54-
55-
pass

test/unit/lib/test_lib_kill.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python3
2-
"Unit test for trepan.processor.command.kill"
1+
"""Unit test for trepan.processor.command.kill"""
32

43
import signal
54
import sys

test/unit/lib/test_lib_sig.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python3
2-
"Unit test for trepan.lib.sighandler"
1+
"""Unit test for trepan.lib.sighandler"""
32
import signal
43

54
from trepan.lib import sighandler as Msig
@@ -57,6 +56,3 @@ def test_lookup_signame_signum():
5756
pass
5857
pass
5958
return
60-
61-
62-
pass

test/unit/processor/command/test_cmd_alias.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"Unit test for trepan.processor.command.alias and unalias"
1+
"""Unit test for trepan.processor.command.alias and unalias"""
22
import inspect
33
from test.unit.cmdhelper import setup_unit_test_debugger
44

test/unit/processor/command/test_cmd_help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"Unit test for trepan.processor.command.help"
1+
"""Unit test for trepan.processor.command.help"""
22

33
from test.unit.cmdhelper import setup_unit_test_debugger
44

test/unit/test_api.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
"""
2+
Unit test of trepan.api
3+
"""
4+
5+
import sys
6+
7+
import tracer
8+
9+
from trepan.api import run_call, run_eval
10+
from trepan.inout.stringarray import StringArrayInput, StringArrayOutput
11+
from trepan.lib.default import DEBUGGER_SETTINGS
12+
13+
14+
def plus5(n: int) -> int:
15+
return n + 5
16+
17+
18+
def test_run_xxx():
19+
"""
20+
test run_eval() and run_call()
21+
"""
22+
settings = dict(DEBUGGER_SETTINGS)
23+
settings.update({"trace": True, "printset": tracer.ALL_EVENTS})
24+
debugger_input = StringArrayInput()
25+
debugger_output = StringArrayOutput()
26+
debug_opts = {
27+
"step_ignore": -1,
28+
"settings": settings,
29+
"input": debugger_input,
30+
"output": debugger_output,
31+
}
32+
print('Issuing: run_eval("1+2")')
33+
print(run_eval("1+2", debug_opts=debug_opts))
34+
print(debugger_output.output)
35+
start_lineno = "1" if sys.version_info[:2] < (3, 10) else "0"
36+
assert debugger_output.output[0:3] == [
37+
"call - <string>:%s" % start_lineno,
38+
"line - <string>:1",
39+
"return - <string>:1, 3 ",
40+
]
41+
debugger_input = StringArrayInput([""])
42+
debugger_output = StringArrayOutput()
43+
debug_opts = {
44+
"step_ignore": -1,
45+
"settings": settings,
46+
"input": debugger_input,
47+
"output": debugger_output,
48+
}
49+
print('Issuing: run_call(foo, 3")')
50+
x = run_call(plus5, 3, debug_opts=debug_opts)
51+
assert x == 8
52+
call_lineno = "12"
53+
for i, (prefix, suffix) in enumerate(
54+
(
55+
("call - ", "test/unit/test_api.py:%s" % call_lineno),
56+
("line - ", "test/unit/test_api.py:13"),
57+
("return - ", "test/unit/test_api.py:13, 8 "),
58+
)
59+
):
60+
assert debugger_output.output[i].startswith(prefix), debugger_output.output[i]
61+
if not debugger_output.output[i].endswith(suffix):
62+
from trepan.api import debug
63+
64+
debug()
65+
assert debugger_output.output[i].endswith(suffix), debugger_output.output[i]

test/unit/test_clifns.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#!/usr/bin/env python3
2-
"Unit test for trepan.clifns"
1+
"""Unit test for trepan.clifns"""
32
import inspect
43
import os
54
import sys

0 commit comments

Comments
 (0)