Skip to content

Commit 539174f

Browse files
committed
Go over testing
1 parent 81d50c0 commit 539174f

6 files changed

Lines changed: 119 additions & 89 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
function finish {
3+
cd $owd
4+
}
5+
6+
# FIXME put some of the below in a common routine
7+
owd=$(pwd)
8+
trap finish EXIT
9+
10+
cd $(dirname ${BASH_SOURCE[0]})
11+
if ! source ./pyenv-newer-versions ; then
12+
exit $?
13+
fi
14+
15+
. ./setup-master.sh
16+
17+
cd ..
18+
for version in $PYVERSIONS; do
19+
if ! pyenv local $version ; then
20+
exit $?
21+
fi
22+
python --version
23+
make clean && pip install -e .
24+
if ! make check; then
25+
exit $?
26+
fi
27+
done

admin-tools/setup-master.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ owd=$(pwd)
2121
bs=${BASH_SOURCE[0]}
2222
mydir=$(dirname $bs)
2323
fulldir=$(readlink -f $mydir)
24-
(cd ../python-uncompyle6 && ./admin-tools/setup-master.sh)
24+
cd $mydir
25+
(cd ../../python-uncompyle6 && ./admin-tools/setup-master.sh)
2526
cd $fulldir/..
2627
(cd $fulldir/.. && \
2728
checkout_version pycolumnize && \

admin-tools/setup-python-3.2.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ fulldir=$(readlink -f $mydir)
3636
cd $owd
3737
rm -v */.python-version || true
3838

39-
git checkout python-3.2 && pyenv local $PYTHON_VERSION && git pull
39+
git checkout python-3.2-to-3.5 && pyenv local $PYTHON_VERSION && git pull

test/unit/test_api.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,21 @@ def test_run_xxx():
4949
print('Issuing: run_call(foo, 3")')
5050
x = run_call(plus5, 3, debug_opts=debug_opts)
5151
assert x == 8
52-
call_lineno = "12"
52+
call_lineno = "14"
5353
for i, (prefix, suffix) in enumerate(
5454
(
5555
("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 "),
56+
("line - ", "test/unit/test_api.py:15"),
57+
("return - ", "test/unit/test_api.py:15, 8 "),
5858
)
5959
):
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]
60+
assert debugger_output.output[i].startswith(prefix), (
61+
prefix,
62+
suffix,
63+
debugger_output.output[i],
64+
)
65+
assert debugger_output.output[i].endswith(suffix), (
66+
prefix,
67+
suffix,
68+
debugger_output.output[i],
69+
)

trepan/debugger.py

Lines changed: 76 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,84 @@ class Trepan:
6565
Class for a top-level object.
6666
"""
6767

68-
def __init__(self):
68+
def __init__(self, opts=None):
69+
"""Create a debugger object. But depending on the value of
70+
key 'start' inside hash 'opts', we may or may not initially
71+
start debugging.
72+
73+
See also ``Debugger.start`` and ``Debugger.stop``.
74+
"""
75+
76+
self.mainpyfile = None
77+
self.thread = None
78+
self.eval_string = None
6979
self.settings = {}
7080

81+
def get_option(key: str) -> Any:
82+
return option_set(opts, key, self.DEFAULT_INIT_OPTS)
83+
84+
def completer(text: str, state):
85+
return self.complete(text, state)
86+
87+
# set the instance variables that come directly from options.
88+
for opt in ("settings", "orig_sys_argv", "from_ipython"):
89+
setattr(self, opt, get_option(opt))
90+
pass
91+
92+
core_opts = {}
93+
for opt in (
94+
"ignore_filter",
95+
"proc_opts",
96+
"processor",
97+
"step_ignore",
98+
"processor",
99+
):
100+
core_opts[opt] = get_option(opt)
101+
pass
102+
103+
# How are I/O for this debugger handled? This should
104+
# be set before calling DebuggerCore.
105+
interface_opts = {
106+
"complete": completer,
107+
"debugger_name": "trepan3k",
108+
}
109+
# FIXME when I pass in opts=opts things break
110+
111+
inp = opts.get("input", None) if opts else None
112+
interface = get_option("interface") or UserInterface(
113+
inp=inp, opts=interface_opts
114+
)
115+
self.intf = [interface]
116+
117+
out = get_option("output")
118+
if out:
119+
self.intf[-1].output = out
120+
pass
121+
122+
self.core = TrepanCore(self, core_opts)
123+
self.core.add_ignore(self.core.stop)
124+
125+
# When set True, we'll also suspend our debug-hook tracing.
126+
# This gives us a way to prevent or allow self debugging.
127+
self.core.trace_hook_suspend = False
128+
129+
if get_option("save_sys_argv"):
130+
# Save the debugged program's sys.argv? We do this so that
131+
# when the debugged script munges these, we have a good
132+
# copy to use for an exec restart
133+
self.program_sys_argv = list(sys.argv)
134+
else:
135+
self.program_sys_argv = None
136+
pass
137+
138+
self.sigmgr = SignalManager(self)
139+
140+
# Were we requested to activate immediately?
141+
if get_option("activate"):
142+
self.core.start(get_option("start_opts"))
143+
pass
144+
return
145+
71146
# The following functions have to be defined before
72147
# DEFAULT_INIT_OPTS which includes references to these.
73148

@@ -289,83 +364,6 @@ def restart_argv(self):
289364
"from_ipython": False,
290365
}
291366

292-
def __init__(self, opts=None):
293-
"""Create a debugger object. But depending on the value of
294-
key 'start' inside hash 'opts', we may or may not initially
295-
start debugging.
296-
297-
See also ``Debugger.start`` and ``Debugger.stop``.
298-
"""
299-
300-
self.mainpyfile = None
301-
self.thread = None
302-
self.eval_string = None
303-
304-
def get_option(key: str) -> Any:
305-
return option_set(opts, key, self.DEFAULT_INIT_OPTS)
306-
307-
def completer(text: str, state):
308-
return self.complete(text, state)
309-
310-
# set the instance variables that come directly from options.
311-
for opt in ("settings", "orig_sys_argv", "from_ipython"):
312-
setattr(self, opt, get_option(opt))
313-
pass
314-
315-
core_opts = {}
316-
for opt in (
317-
"ignore_filter",
318-
"proc_opts",
319-
"processor",
320-
"step_ignore",
321-
"processor",
322-
):
323-
core_opts[opt] = get_option(opt)
324-
pass
325-
326-
# How are I/O for this debugger handled? This should
327-
# be set before calling DebuggerCore.
328-
interface_opts = {
329-
"complete": completer,
330-
"debugger_name": "trepan3k",
331-
}
332-
# FIXME when I pass in opts=opts things break
333-
334-
inp = opts.get("input", None) if opts else None
335-
interface = get_option("interface") or UserInterface(
336-
inp=inp, opts=interface_opts
337-
)
338-
self.intf = [interface]
339-
340-
out = get_option("output")
341-
if out:
342-
self.intf[-1].output = out
343-
pass
344-
345-
self.core = TrepanCore(self, core_opts)
346-
self.core.add_ignore(self.core.stop)
347-
348-
# When set True, we'll also suspend our debug-hook tracing.
349-
# This gives us a way to prevent or allow self debugging.
350-
self.core.trace_hook_suspend = False
351-
352-
if get_option("save_sys_argv"):
353-
# Save the debugged program's sys.argv? We do this so that
354-
# when the debugged script munges these, we have a good
355-
# copy to use for an exec restart
356-
self.program_sys_argv = list(sys.argv)
357-
else:
358-
self.program_sys_argv = None
359-
pass
360-
361-
self.sigmgr = SignalManager(self)
362-
363-
# Were we requested to activate immediately?
364-
if get_option("activate"):
365-
self.core.start(get_option("start_opts"))
366-
pass
367-
return
368-
369367
def complete(self, last_token: str, state: int):
370368
"""
371369
In place expansion of top-level debugger command

0 commit comments

Comments
 (0)