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

Feat (headless.js): improved progress reporting. #682

Merged
merged 1 commit into from
Apr 15, 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
27 changes: 17 additions & 10 deletions tests/headless.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const excludedFiles = new Set([
"manifest.html",
]);

const runRespec2html = async(function*(server) {
const runRespec2html = async(function* (server) {
// Run respec2html.js on each example file (except whatever gets filtered)
// and stops in error if any of them reports a warning or an error
let sources = fs.readdirSync("examples")
Expand All @@ -57,32 +57,35 @@ const runRespec2html = async(function*(server) {

// Incrementally spawn processes and add them to process counter.
const executables = sources.map((source) => {
let cmd = `node ./tools/respec2html.js ${server}/examples/${source} > /dev/null`;
let cmd = `node ./tools/respec2html.js -e --timeout 10 --src ${server}/examples/${source} > /dev/null`;
return cmd;
}).map(
toExecutable
);
var testCount = 1;
var errored = false;
let testCount = 1;
const errored = new Set();
const captureFile = /(\w+\.html)/;
for (const exe of executables) {
const filename = captureFile.exec(exe.cmd)[1];
try {
debug(` 🚄 Running test ${testCount++} of ${sources.length}.`);
debug(` 🚄 Generating ${filename} - test ${testCount++} of ${sources.length}.`);
yield exe.run();
} catch (err) {
console.error(colors.error(err));
errored = true;
errored.add(filename);
}
}
if(errored){
throw new Error(" ❌ A test generated an error");
if (errored.size) {
const files = Array.from(errored).join(", ");
throw new Error(` ❌ File(s) generated errors: ${files}.`);
}
});

function debug(msg) {
console.log(colors.debug(`${colors.input(moment().format("LTS"))} ${msg}`));
}

async.task(function*() {
async.task(function* () {
const port = process.env.PORT || 3000;
const server = "http://localhost:" + port;
debug(" ✅ Starting up Express...");
Expand All @@ -93,7 +96,11 @@ async.task(function*() {
debug(" ⏲ Building ReSpec...");
yield builder.buildW3C("latest");
debug(" ⏲ Running ReSpec2html tests...");
yield runRespec2html(server);
try {
yield runRespec2html(server);
} catch (err) {
throw err;
}
})
.then(
() => process.exit(0)
Expand Down