mirror of
https://github.com/tc39/test262.git
synced 2025-07-16 10:34:44 +02:00
Merge pull request #49 from smikes/faster-python-runner
test262.py: only include helper scripts when needed
This commit is contained in:
commit
66366d6961
@ -91,6 +91,9 @@ function BrowserRunner() {
|
|||||||
currentTest.code = codeString;
|
currentTest.code = codeString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isAsyncTest(code) {
|
||||||
|
return /\$DONE()/.test(code));
|
||||||
|
}
|
||||||
|
|
||||||
/* Run the test. */
|
/* Run the test. */
|
||||||
this.run = function (test, code) {
|
this.run = function (test, code) {
|
||||||
@ -208,8 +211,8 @@ function BrowserRunner() {
|
|||||||
|
|
||||||
//this is mainly applicable for consoles that do not have setTimeout support
|
//this is mainly applicable for consoles that do not have setTimeout support
|
||||||
//idoc.writeln("<script type='text/javascript' src='harness/timer.js' defer>" + "</script>");
|
//idoc.writeln("<script type='text/javascript' src='harness/timer.js' defer>" + "</script>");
|
||||||
if(setTimeout === undefined && /\$DONE()/.test(code)){
|
if(setTimeout === undefined && isAsyncTest(code)) {
|
||||||
idoc.writeln("<script type='text/javascript'>");
|
idoc.writeln("<script type='text/javascript'>");
|
||||||
idoc.writeln(timerContents);
|
idoc.writeln(timerContents);
|
||||||
idoc.writeln("</script>");
|
idoc.writeln("</script>");
|
||||||
}
|
}
|
||||||
@ -225,15 +228,15 @@ function BrowserRunner() {
|
|||||||
|
|
||||||
idoc.writeln("<script type='text/javascript'>");
|
idoc.writeln("<script type='text/javascript'>");
|
||||||
|
|
||||||
if(!/\$DONE()/.test(code))
|
if (!isAsyncTest(code)) {
|
||||||
//if the test is synchronous - call $DONE immediately
|
//if the test is synchronous - call $DONE immediately
|
||||||
idoc.writeln("if(typeof $DONE === 'function') $DONE()");
|
idoc.writeln("if(typeof $DONE === 'function') $DONE()");
|
||||||
else{
|
} else {
|
||||||
//in case the test does not call $DONE asynchronously then
|
//in case the test does not call $DONE asynchronously then
|
||||||
//bailout after 1 min or given bailout time by calling $DONE
|
//bailout after 1 min or given bailout time by calling $DONE
|
||||||
var asyncval = parseInt(test.timeout);
|
var asyncval = parseInt(test.timeout);
|
||||||
var testTimeout = asyncval !== asyncval ? 2000 : asyncval;
|
var testTimeout = asyncval !== asyncval ? 2000 : asyncval;
|
||||||
idoc.writeln("setTimeout(function() {$ERROR(\" Test Timed Out at " + testTimeout +"\" )} ," + testTimeout + ")");
|
idoc.writeln("setTimeout(function() {$ERROR(\" Test Timed Out at " + testTimeout +"\" )} ," + testTimeout + ")");
|
||||||
}
|
}
|
||||||
idoc.writeln("</script>");
|
idoc.writeln("</script>");
|
||||||
idoc.close();
|
idoc.close();
|
||||||
|
@ -12,7 +12,7 @@ if(Promise !== undefined && this.setTimeout === undefined)
|
|||||||
var end = start + delay;
|
var end = start + delay;
|
||||||
function check(){
|
function check(){
|
||||||
var timeLeft = end - Date.now();
|
var timeLeft = end - Date.now();
|
||||||
if(timeLeft)
|
if(timeLeft > 0)
|
||||||
p.then(check);
|
p.then(check);
|
||||||
else
|
else
|
||||||
callback();
|
callback();
|
||||||
|
@ -260,11 +260,14 @@ class TestCase(object):
|
|||||||
# "var testDescrip = " + str(self.testRecord) + ';\n\n' + \
|
# "var testDescrip = " + str(self.testRecord) + ';\n\n' + \
|
||||||
source = self.suite.GetInclude("cth.js") + \
|
source = self.suite.GetInclude("cth.js") + \
|
||||||
self.suite.GetInclude("sta.js") + \
|
self.suite.GetInclude("sta.js") + \
|
||||||
self.suite.GetInclude("ed.js") + \
|
self.suite.GetInclude("ed.js")
|
||||||
self.suite.GetInclude("testBuiltInObject.js") + \
|
|
||||||
self.suite.GetInclude("testIntl.js") + \
|
if self.IsAsyncTest():
|
||||||
self.suite.GetInclude("timer.js") + \
|
source = source + \
|
||||||
self.suite.GetInclude("doneprintHandle.js").replace('print', self.suite.print_handle) + \
|
self.suite.GetInclude("timer.js") + \
|
||||||
|
self.suite.GetInclude("doneprintHandle.js").replace('print', self.suite.print_handle)
|
||||||
|
|
||||||
|
source = source + \
|
||||||
self.GetAdditionalIncludes() + \
|
self.GetAdditionalIncludes() + \
|
||||||
self.test + '\n'
|
self.test + '\n'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user