Skip to content

Commit

Permalink
Improved progress reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres committed Mar 3, 2016
1 parent cf4515c commit 97e2cf5
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions tests/headless.js
Expand Up @@ -8,7 +8,6 @@ const builder = require("../tools/build-w3c-common");
const colors = require("colors");
const exec = require("child_process").exec;
const express = require("express");
const noOp = function() {};
const moment = require("moment");
colors.setTheme({
data: "grey",
Expand All @@ -28,17 +27,13 @@ function toExecutable(cmd) {
return cmd;
},
run() {
const childProcess = exec(cmd, noOp);
childProcess.stdout.pipe(process.stdout);
childProcess.stderr.pipe(process.stderr);
return new Promise((resolve, reject) => {
let handler = function(code) {
if (code) {
return reject(new Error(`${cmd} (${code})`));
exec(cmd, (err, data) => {
if (err) {
return reject(err);
}
resolve();
};
childProcess.on("exit", handler);
resolve(data);
});
});
}
};
Expand Down Expand Up @@ -66,13 +61,20 @@ const runRespec2html = async(function*(server) {
}).map(
toExecutable
);
var testCount = 1;
var errored = false;
for (const exe of executables) {
try {
debug(` 🚄 Running test ${testCount++} of ${sources.length}.`);
yield exe.run();
} catch (err) {
console.error(colors.error(`${err}`));
console.error(colors.error(err));
errored = true;
}
}
if(errored){
throw new Error(" ❌ A test generated an error");
}
});

function debug(msg) {
Expand All @@ -82,14 +84,14 @@ function debug(msg) {
async.task(function*() {
const port = process.env.PORT || 3000;
const server = "http://localhost:" + port;
debug("Starting up Express...");
debug("Starting up Express...");
const app = express();
const dir = require("path").join(__dirname, "..");
app.use(express.static(dir));
app.listen(port);
debug("Building ReSpec...");
debug("Building ReSpec...");
yield builder.buildW3C("latest");
debug("Running ReSpec2html tests...");
debug("Running ReSpec2html tests...");
yield runRespec2html(server);
})
.then(
Expand Down

0 comments on commit 97e2cf5

Please sign in to comment.