Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved progress reporting #599

Merged
merged 1 commit into from Mar 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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