diff options
author | Sam Mikes <smikes@cubane.com> | 2014-07-21 15:15:04 +0100 |
---|---|---|
committer | Sam Mikes <smikes@cubane.com> | 2014-07-21 15:15:04 +0100 |
commit | d4a3479a1ea95b073e7f7e16ef8e984714b0b395 (patch) | |
tree | d29433d1ce9e0795f93d8f88479e966cf9046086 /test/harness | |
parent | 33c8399de842515918bf64e42f44aae341fc469b (diff) | |
download | qtdeclarative-testsuites-d4a3479a1ea95b073e7f7e16ef8e984714b0b395.tar.gz |
test262.py: only include helper scripts when needed
test262.py: only supply async helper scripts when test is async
sth.js: factor out function isAsyncTest()
timer.js: improve workaround for async tests when Promise is defined but setTimeout is noot
timer.js emulates setTimeout using Promise by doing a busy loop that checks
if `timeout` milliseconds have elapsed. Modified check to (timeLeft > 0) instead
of (!timeLeft) to prevent infinite loop when check does not happen to run
at precise millisecond timeout expires.
Because test262.py did not support the $INCLUDE directive, some helper
scripts were added to every test -- notably testIntl, timer, and donePrintHandle
Now that $INCLUDE is supported, these can be dropped, speeding overall test run time
Diffstat (limited to 'test/harness')
-rw-r--r-- | test/harness/sth.js | 19 | ||||
-rw-r--r-- | test/harness/timer.js | 2 |
2 files changed, 12 insertions, 9 deletions
diff --git a/test/harness/sth.js b/test/harness/sth.js index cd05685e1..d100e160d 100644 --- a/test/harness/sth.js +++ b/test/harness/sth.js @@ -91,6 +91,9 @@ function BrowserRunner() { currentTest.code = codeString;
}
+ function isAsyncTest(code) {
+ return /\$DONE()/.test(code));
+ }
/* Run the test. */
this.run = function (test, code) {
@@ -208,8 +211,8 @@ function BrowserRunner() { //this is mainly applicable for consoles that do not have setTimeout support
//idoc.writeln("<script type='text/javascript' src='harness/timer.js' defer>" + "</script>");
- if(setTimeout === undefined && /\$DONE()/.test(code)){
- idoc.writeln("<script type='text/javascript'>");
+ if(setTimeout === undefined && isAsyncTest(code)) {
+ idoc.writeln("<script type='text/javascript'>");
idoc.writeln(timerContents);
idoc.writeln("</script>");
}
@@ -225,15 +228,15 @@ function BrowserRunner() { idoc.writeln("<script type='text/javascript'>");
- if(!/\$DONE()/.test(code))
- //if the test is synchronous - call $DONE immediately
+ if (!isAsyncTest(code)) {
+ //if the test is synchronous - call $DONE immediately
idoc.writeln("if(typeof $DONE === 'function') $DONE()");
- else{
- //in case the test does not call $DONE asynchronously then
- //bailout after 1 min or given bailout time by calling $DONE
+ } else {
+ //in case the test does not call $DONE asynchronously then
+ //bailout after 1 min or given bailout time by calling $DONE
var asyncval = parseInt(test.timeout);
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.close();
diff --git a/test/harness/timer.js b/test/harness/timer.js index 69762d83f..4dddbb3a1 100644 --- a/test/harness/timer.js +++ b/test/harness/timer.js @@ -12,7 +12,7 @@ if(Promise !== undefined && this.setTimeout === undefined) var end = start + delay; function check(){ var timeLeft = end - Date.now(); - if(timeLeft) + if(timeLeft > 0) p.then(check); else callback(); |