forked from rosa/hakurei
Compare commits
11 Commits
dcf70a458b
...
85bb66154f
| Author | SHA1 | Date | |
|---|---|---|---|
|
85bb66154f
|
|||
|
ab87cee557
|
|||
|
168637de85
|
|||
|
ff23daa997
|
|||
|
6a7fcfab00
|
|||
|
0214998eff
|
|||
|
4a123b11c4
|
|||
|
d94c0ee181
|
|||
|
b1825c7b24
|
|||
|
48a60fecec
|
|||
|
f143986a19
|
@@ -1,7 +1,48 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
// Many editors have terminal emulators built in, so running tests with NodeJS
|
// Many editors have terminal emulators built in, so running tests with NodeJS
|
||||||
// provides faster iteration, especially for those acclimated to test-driven
|
// provides faster iteration, especially for those acclimated to test-driven
|
||||||
// development.
|
// development.
|
||||||
|
|
||||||
import "./all_tests.js";
|
import "./all_tests.js";
|
||||||
import { StreamReporter, TESTS } from "./test.js";
|
import { StreamReporter, TESTS } from "./test.js";
|
||||||
TESTS.run(new StreamReporter({ writeln: console.log }));
|
|
||||||
|
// TypeScript doesn't like process and Deno as their type definitions aren't
|
||||||
|
// installed, but doesn't seem to complain if they're accessed through
|
||||||
|
// globalThis.
|
||||||
|
const process: any = globalThis.process;
|
||||||
|
const Deno: any = globalThis.Deno;
|
||||||
|
|
||||||
|
function getArgs(): string[] {
|
||||||
|
if (process) {
|
||||||
|
const [runtime, program, ...args] = process.argv;
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
if (Deno) return Deno.args;
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function exit(code?: number): never {
|
||||||
|
if (Deno) Deno.exit(code);
|
||||||
|
if (process) process.exit(code);
|
||||||
|
throw `exited with code ${code ?? 0}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const args = getArgs();
|
||||||
|
let verbose = false;
|
||||||
|
if (args.length > 1) {
|
||||||
|
console.error("Too many arguments");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (args.length === 1) {
|
||||||
|
if (args[0] === "-v" || args[0] === "--verbose" || args[0] === "-verbose") {
|
||||||
|
verbose = true;
|
||||||
|
} else if (args[0] !== "--") {
|
||||||
|
console.error(`Unknown argument '${args[0]}'`);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let reporter = new StreamReporter({ writeln: console.log }, verbose);
|
||||||
|
TESTS.run(reporter);
|
||||||
|
exit(reporter.succeeded() ? 0 : 1);
|
||||||
|
|||||||
@@ -198,6 +198,10 @@ export class StreamReporter implements Reporter {
|
|||||||
this.#skips = [];
|
this.#skips = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
succeeded(): boolean {
|
||||||
|
return this.#successes.length > 0 && this.#failures.length === 0;
|
||||||
|
}
|
||||||
|
|
||||||
register(suites: TestGroup[]) {}
|
register(suites: TestGroup[]) {}
|
||||||
|
|
||||||
update(path: string[], result: TestResult) {
|
update(path: string[], result: TestResult) {
|
||||||
|
|||||||
Reference in New Issue
Block a user