Skip to content

Commit d7f9c4a

Browse files
committed
Sync with trepan3k
1 parent 73ef437 commit d7f9c4a

8 files changed

Lines changed: 534 additions & 333 deletions

File tree

test/data/highlight.right

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(gcd.py:10): <module>
2-
-> 10 """
2+
-> 10 """
33
Set basename (short filenames) in debugger output is on.
44
Set event tracing is on.
55
Set stopping before def or class statements is off.

test/data/step.right

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
(gcd.py:10): <module>
2-
-> 10 """
2+
-> 10 """
33
Set basename (short filenames) in debugger output is on.
44
Set event tracing is on.
55
Set stopping before def or class statements is off.
66
Set confirmation of potentially dangerous operations is off.
77
line - gcd.py:10
88
line - gcd.py:11
99
(gcd.py:11): <module>
10-
-- 11 import sys
11-
11 -> import sys
10+
-- 11 import sys
11+
11 -> import sys
1212
Set stopping before def or class statements is on.
1313
line - gcd.py:13
1414
line - gcd.py:26
1515
line - gcd.py:40
1616
(gcd.py:40): <module>
17-
-- 40 if __name__=='__main__':
18-
40 -> if __name__=='__main__':
17+
-- 40 if __name__=='__main__':
18+
40 -> if __name__=='__main__':
1919
Set stopping before def or class statements is off.
2020
line - gcd.py:41
2121
(gcd.py:41): <module>
22-
-- 41 check_args()
23-
41 -> check_args()
22+
-- 41 check_args()
23+
41 -> check_args()
2424
trepan2: That's all, folks...

test/integration/helper.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
1-
import difflib, os, re, sys, time
21
from xdis import IS_PYPY
3-
4-
srcdir = os.path.abspath(os.path.dirname(__file__))
2+
import difflib, os, re, sys, time
3+
import os.path as osp
4+
srcdir = osp.abspath(osp.dirname(__file__))
55

66

77
def run_debugger(testname, python_file, dbgr_opts='', args='',
8-
outfile=None):
9-
datadir = os.path.join(srcdir, '..', 'data')
10-
progdir = os.path.join(srcdir, '..', 'example')
11-
dbgrdir = os.path.join(srcdir, '..', '..', 'trepan')
8+
outfile=None, right_template=None):
9+
datadir = osp.join(srcdir, '..', 'data')
10+
progdir = osp.join(srcdir, '..', 'example')
11+
dbgrdir = osp.join(srcdir, '..', '..', 'trepan')
1212
dbgr_short= "__main__.py"
13-
dbgr_path = os.path.join(dbgrdir, dbgr_short)
13+
dbgr_path = osp.join(dbgrdir, dbgr_short)
1414

15-
if IS_PYPY:
16-
rightfile = os.path.join(datadir, "%s-pypy.right" % testname)
17-
else:
18-
rightfile = os.path.join(datadir, "%s.right" % testname)
15+
if not right_template:
16+
if IS_PYPY:
17+
right_template = "%s-pypy.right"
18+
else:
19+
right_template = "%s.right"
20+
21+
rightfile = osp.join(datadir, right_template % testname)
1922

20-
sys.path.insert(0, os.path.join(srcdir, '..', '..'))
23+
sys.path.insert(0, osp.join(srcdir, '..', '..'))
2124
os.environ['PYTHONPATH'] = os.pathsep.join(sys.path)
22-
cmdfile = os.path.join(datadir, "%s.cmd" % testname)
23-
outfile = os.path.join(srcdir, "%s.out" % testname)
25+
cmdfile = osp.join(datadir, "%s.cmd" % testname)
26+
outfile = osp.join(srcdir, "%s.out" % testname)
2427
if python_file:
25-
programfile = os.path.join(progdir, python_file)
28+
programfile = osp.join(progdir, python_file)
2629
else:
2730
programfile = ''
2831
pass
2932

3033
outfile_opt = '--output=%s ' % outfile
3134

32-
if os.path.exists(outfile): os.unlink(outfile)
35+
if osp.exists(outfile): os.unlink(outfile)
3336

3437
cmd = "%s --command %s %s %s %s %s" % \
3538
(dbgr_path, cmdfile, outfile_opt, dbgr_opts, programfile, args)
3639

37-
print(cmd)
40+
# print(cmd)
3841
os.system(cmd)
3942
fromfile = rightfile
4043
fromdate = time.ctime(os.stat(fromfile).st_mtime)

test/integration/test-general.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@ class GeneralTests(unittest.TestCase):
99

1010
def test_step(self):
1111
"""Test stepping, set skip, set trace"""
12-
result=Mhelper.run_debugger(testname='step',
13-
dbgr_opts='--basename --highlight=plain',
14-
python_file='gcd.py')
12+
right_template = None
13+
result = Mhelper.run_debugger(
14+
testname="step",
15+
dbgr_opts="--basename --highlight=plain",
16+
python_file="gcd.py",
17+
right_template=right_template,
18+
)
19+
1520
self.assertEqual(True, result, "debugger 'step' command comparision")
1621
return
1722
pass

test/integration/test-highlight.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,27 @@
33
import unittest
44

55
import helper as Mhelper
6+
from xdis import PYTHON_VERSION_TRIPLE
67

78

89
class GeneralTests(unittest.TestCase):
9-
1010
def test_macro(self):
1111
"""Test set/show highlight"""
12-
result=Mhelper.run_debugger(testname='highlight',
13-
dbgr_opts='--basename ' +
14-
'--highlight=plain --nx',
15-
python_file='gcd.py')
12+
if PYTHON_VERSION_TRIPLE >= (3, 8):
13+
right_template = "%s-38.right"
14+
else:
15+
right_template = None
16+
result = Mhelper.run_debugger(
17+
testname="highlight",
18+
dbgr_opts="--basename " + "--highlight=plain --nx",
19+
python_file="gcd.py",
20+
right_template=right_template,
21+
)
1622
self.assertEqual(True, result, "'highlight' command comparision")
1723
return
24+
1825
pass
1926

27+
2028
if __name__ == "__main__":
2129
unittest.main()

0 commit comments

Comments
 (0)