Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / test / data / third_party / spaceport / js / testRunner.js
blobf082ad59a9129830b40d1a1ab2bff6480c1edf1f
1 define([ 'util/ensureCallback', 'util/chainAsync' ], function (ensureCallback, chainAsync) {
2 var testRunner = {
3 run: function run(name, test, callbacks) {
4 var stepCallback = callbacks.step || function () { };
5 var doneCallback = ensureCallback(callbacks.done);
7 if (typeof test === 'function') {
8 // We run the test twice (sadly): once to warm up the JIT and once for the actual test.
9 //test(function (_, _) {
10 test(function (err, results) {
11 stepCallback(err, name, results);
12 doneCallback(err, results);
13 });
14 //});
15 } else {
16 var allResults = { };
18 var subTests = Object.keys(test).map(function (subName) {
19 var newName = name ? name + '.' + subName : subName;
20 return function (next) {
21 testRunner.run(newName, test[subName], {
22 step: stepCallback,
23 done: function (err, results) {
24 if (!err) {
25 allResults[subName] = results;
28 next();
30 });
32 });
34 chainAsync(subTests.concat([
35 function () {
36 doneCallback(null, allResults);
38 ]));
43 return testRunner;
44 });