Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Revert "Bug 887914 - Unit tests execute all top-level code before any…
Browse files Browse the repository at this point in the history
… test cases"
  • Loading branch information
erikvold committed Sep 4, 2014
1 parent a581fe1 commit 912cc91
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 39 deletions.
28 changes: 5 additions & 23 deletions lib/sdk/deprecated/unit-test-finder.js
Expand Up @@ -135,19 +135,9 @@ TestFinder.prototype = {
let { fileFilter, testFilter } = makeFilters({ filter: this.filter });

return getSuites({ id: id, filter: fileFilter }).then(suites => {
let testsRemaining = [];

let getNextTest = () => {
if (testsRemaining.length) {
return testsRemaining.shift();
}

if (!suites.length) {
return null;
}

let suite = suites.shift();
let tests = [];

suites.forEach(suite => {
// Load each test file as a main module in its own loader instance
// `suite` is defined by cuddlefish/manifest.py:ManifestBuilder.build
let suiteModule;
Expand All @@ -172,7 +162,7 @@ TestFinder.prototype = {
if (this.testInProcess) {
for (let name of Object.keys(suiteModule).sort()) {
if (NOT_TESTS.indexOf(name) === -1 && testFilter(name)) {
testsRemaining.push({
tests.push({
setup: suiteModule.setup,
teardown: suiteModule.teardown,
testFunction: suiteModule[name],
Expand All @@ -181,17 +171,9 @@ TestFinder.prototype = {
}
}
}
})

return getNextTest();
};

return {
getNext: () => {
let { promise, resolve } = defer();
resolve(getNextTest());
return promise;
}
};
return tests;
});
}
};
26 changes: 10 additions & 16 deletions lib/sdk/deprecated/unit-test.js
Expand Up @@ -486,23 +486,17 @@ TestRunner.prototype = {

startMany: function startMany(options) {
function runNextTest(self) {
let { tests, onDone } = options;

return tests.getNext().then((test) => {
if (options.stopOnError && self.test && self.test.failed) {
self.console.error("aborted: test failed and --stop-on-error was specified");
onDone(self);
}
else if (test) {
self.start({test: test, onDone: runNextTest});
}
else {
onDone(self);
}
});
var test = options.tests.shift();
if (options.stopOnError && self.test && self.test.failed) {
self.console.error("aborted: test failed and --stop-on-error was specified");
options.onDone(self);
} else if (test) {
self.start({test: test, onDone: runNextTest});
} else {
options.onDone(self);
}
}

return runNextTest(this).catch(console.exception);
runNextTest(this);
},

start: function start(options) {
Expand Down

0 comments on commit 912cc91

Please sign in to comment.