refactor: change test reporter output (#4371)

This commit changes output of default test reporter to resemble output from Rust test runner;
first the name of running test is printed with "...", then after test has run result is printed on the same line.

* Split "Deno.TestEvent.Result" into "TestStart" and "TestEnd";
* changes TestReporter interface to support both events; 

Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
This commit is contained in:
Bartek Iwańczuk 2020-03-15 17:58:59 +01:00 committed by GitHub
parent 620dd9724d
commit 70434b5bfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 160 additions and 126 deletions

View file

@ -17,6 +17,7 @@ interface PermissionSetTestResult {
stats: Deno.TestStats;
permsStr: string;
duration: number;
results: Deno.TestResult[];
}
const PERMISSIONS: Deno.PermissionName[] = [
@ -144,16 +145,17 @@ async function runTestsForPermissionSet(
expectedPassedTests = msg.tests;
await reporter.start(msg);
continue;
}
if (msg.kind === Deno.TestEvent.Result) {
await reporter.result(msg);
} else if (msg.kind === Deno.TestEvent.TestStart) {
await reporter.testStart(msg);
continue;
} else if (msg.kind === Deno.TestEvent.TestEnd) {
await reporter.testEnd(msg);
continue;
} else {
endEvent = msg;
await reporter.end(msg);
break;
}
endEvent = msg;
await reporter.end(msg);
break;
}
} catch (e) {
hasThrown = true;
@ -183,14 +185,16 @@ async function runTestsForPermissionSet(
workerProcess.close();
const passed = expectedPassedTests === endEvent.stats.passed;
const passed =
expectedPassedTests === endEvent.stats.passed + endEvent.stats.ignored;
return {
perms,
passed,
permsStr: permsFmt,
duration: endEvent.duration,
stats: endEvent.stats
stats: endEvent.stats,
results: endEvent.results
};
}
@ -225,13 +229,13 @@ async function masterRunnerMain(
let testsPassed = true;
for (const testResult of testResults) {
const { permsStr, stats, duration } = testResult;
const { permsStr, stats, duration, results } = testResult;
console.log(`Summary for ${permsStr}`);
await consoleReporter.end({
kind: Deno.TestEvent.End,
stats,
duration,
results: []
results
});
testsPassed = testsPassed && testResult.passed;
}