|
1 | | -import difflib, os, re, sys, time |
2 | 1 | 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__)) |
5 | 5 |
|
6 | 6 |
|
7 | 7 | 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') |
12 | 12 | dbgr_short= "__main__.py" |
13 | | - dbgr_path = os.path.join(dbgrdir, dbgr_short) |
| 13 | + dbgr_path = osp.join(dbgrdir, dbgr_short) |
14 | 14 |
|
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) |
19 | 22 |
|
20 | | - sys.path.insert(0, os.path.join(srcdir, '..', '..')) |
| 23 | + sys.path.insert(0, osp.join(srcdir, '..', '..')) |
21 | 24 | 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) |
24 | 27 | if python_file: |
25 | | - programfile = os.path.join(progdir, python_file) |
| 28 | + programfile = osp.join(progdir, python_file) |
26 | 29 | else: |
27 | 30 | programfile = '' |
28 | 31 | pass |
29 | 32 |
|
30 | 33 | outfile_opt = '--output=%s ' % outfile |
31 | 34 |
|
32 | | - if os.path.exists(outfile): os.unlink(outfile) |
| 35 | + if osp.exists(outfile): os.unlink(outfile) |
33 | 36 |
|
34 | 37 | cmd = "%s --command %s %s %s %s %s" % \ |
35 | 38 | (dbgr_path, cmdfile, outfile_opt, dbgr_opts, programfile, args) |
36 | 39 |
|
37 | | - print(cmd) |
| 40 | + # print(cmd) |
38 | 41 | os.system(cmd) |
39 | 42 | fromfile = rightfile |
40 | 43 | fromdate = time.ctime(os.stat(fromfile).st_mtime) |
|
0 commit comments