Skip to content

Commit

Permalink
skulpt.py and test.js changes to test in debug mode (without a breakp…
Browse files Browse the repository at this point in the history
…oint filter, this suspends before every statement)
  • Loading branch information
meredydd committed Sep 21, 2014
1 parent 0449aaf commit ae1b7b6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
30 changes: 24 additions & 6 deletions skulpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,13 @@ def is64bit():

#jsengine = "rhino"

def test():
def test(debug_mode=False):
"""runs the unit tests."""
ret1 = os.system("{0} {1} {2}".format(jsengine, ' '.join(getFileList(FILE_TYPE_TEST)), ' '.join(TestFiles)))
if debug_mode:
debugon = "--debug-mode"
else:
debugon = ""
ret1 = os.system("{0} {1} {2} -- {3}".format(jsengine, ' '.join(getFileList(FILE_TYPE_TEST)), ' '.join(TestFiles), debugon))
print "Running jshint"
ret2 = os.system("jshint src/*.js")
return ret1 | ret2
Expand Down Expand Up @@ -594,7 +598,7 @@ def docbi(options):
if options.verbose:
print ". Wrote {fileName}".format(fileName=builtinfn)

def run(fn, shell="", opt=False, p3=False):
def run(fn, shell="", opt=False, p3=False, debug_mode=False):
if not os.path.exists(fn):
print "%s doesn't exist" % fn
raise SystemExit()
Expand All @@ -606,15 +610,22 @@ def run(fn, shell="", opt=False, p3=False):
p3on = 'true'
else:
p3on = 'false'
if debug_mode:
debugon = 'true'
else:
debugon = 'false'
f.write("""
var input = read('%s');
print("-----");
print(input);
print("-----");
Sk.configure({syspath:["%s"], read:read, python3:%s});
Sk.importMain("%s", true);
Sk.configure({syspath:["%s"], read:read, python3:%s, debugging:%s});
var r = Sk.importMain("%s", true, true);
while (r instanceof Sk.misceval.Suspension) {
r = r.resume();
}
print("-----");
""" % (fn, os.path.split(fn)[0], p3on, modname))
""" % (fn, os.path.split(fn)[0], p3on, debugon, modname))
f.close()
if opt:
os.system("{0} {1}/{2} support/tmp/run.js".format(jsengine, DIST_DIR, OUTFILE_MIN))
Expand All @@ -627,6 +638,9 @@ def runopt(fn):
def run3(fn):
run(fn,p3=True)

def rundebug(fn):
run(fn,debug_mode=True)

def shell(fn):
run(fn, "--shell")

Expand Down Expand Up @@ -808,6 +822,8 @@ def main():

if cmd == "test":
test()
elif cmd == "testdebug":
test(True)
elif cmd == "dist":
dist(options)
elif cmd == "regengooglocs":
Expand All @@ -829,6 +845,8 @@ def main():
runopt(sys.argv[2])
elif cmd == "run3":
run3(sys.argv[2])
elif cmd == "rundebug":
rundebug(sys.argv[2])
elif cmd == "vmwareregr":
vmwareregr()
elif cmd == "regenparser":
Expand Down
6 changes: 4 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ var AllRunTests = [];
var runpass = 0;
var runfail = 0;
var rundisabled = 0;
function testRun(name, nocatch)
function testRun(name, nocatch, debugMode)
{
try { var input = read(name + ".py"); }
catch (e) {
Expand All @@ -211,6 +211,7 @@ function testRun(name, nocatch)
output: function(str) { got += str; },
sysargv: [ name + '.py' ],
read: read,
debugging: debugMode,
syspath: [ justpath ]
});

Expand Down Expand Up @@ -346,6 +347,7 @@ var doTestParse = false
var doTestTrans = false
var doTestSymtab = false
var doTestRun = true
var testInDebugMode = arguments.indexOf("--debug-mode") != -1;
function testsMain()
{
var i;
Expand Down Expand Up @@ -381,7 +383,7 @@ function testsMain()
if (doTestRun) {
for (i = 0; i <= 1000; ++i)
{
testRun(sprintf("test/run/t%02d", i));
testRun(sprintf("test/run/t%02d", i), undefined, testInDebugMode);
}
print(sprintf("run: %d/%d (+%d disabled)", runpass, runpass + runfail, rundisabled));
}
Expand Down

0 comments on commit ae1b7b6

Please sign in to comment.