зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1343749
. Part 1 - Let MediaTestManager manage timeout of each test. r=jya
MozReview-Commit-ID: HocDk9FCi6Q --HG-- extra : rebase_source : f88280fc3d11e14275c5d41c5607cb6c77d90da5
This commit is contained in:
Родитель
8f883113a7
Коммит
d004dc1ef7
|
@ -1612,6 +1612,10 @@ const DEBUG_TEST_LOOP_FOREVER = false;
|
|||
// or end the mochitest if all the tests are done.
|
||||
function MediaTestManager() {
|
||||
|
||||
// Set a very large timeout to prevent Mochitest timeout.
|
||||
// Instead MediaTestManager will manage timeout of each test.
|
||||
SimpleTest.requestLongerTimeout(1000);
|
||||
|
||||
// Return how many seconds elapsed since |begin|.
|
||||
function elapsedTime(begin) {
|
||||
var end = new Date();
|
||||
|
@ -1635,6 +1639,7 @@ function MediaTestManager() {
|
|||
this.isShutdown = false;
|
||||
this.numTestsRunning = 0;
|
||||
this.handlers = {};
|
||||
this.timers = {};
|
||||
|
||||
// Always wait for explicit finish.
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -1661,6 +1666,14 @@ function MediaTestManager() {
|
|||
this.tokens.push(token);
|
||||
this.numTestsRunning++;
|
||||
this.handlers[token] = handler;
|
||||
|
||||
var onTimeout = function() {
|
||||
ok(false, `${token} timed out!`);
|
||||
this.finished(token);
|
||||
}.bind(this);
|
||||
// Default timeout to 180s for each test.
|
||||
this.timers[token] = setTimeout(onTimeout, 180000);
|
||||
|
||||
is(this.numTestsRunning, this.tokens.length,
|
||||
"[started " + token + " t=" + elapsedTime(this.startTime) + "] Length of array should match number of running tests");
|
||||
}
|
||||
|
@ -1676,6 +1689,12 @@ function MediaTestManager() {
|
|||
this.tokens.splice(i, 1);
|
||||
}
|
||||
|
||||
if (this.timers[token]) {
|
||||
// Cancel the timer when the test finishes.
|
||||
clearTimeout(this.timers[token]);
|
||||
this.timers[token] = null;
|
||||
}
|
||||
|
||||
info("[finished " + token + "] remaining= " + this.tokens);
|
||||
this.numTestsRunning--;
|
||||
is(this.numTestsRunning, this.tokens.length,
|
||||
|
|
Загрузка…
Ссылка в новой задаче