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

Add test time spent count #544

Merged
merged 1 commit into from
Mar 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions test/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ async function startEsmServer(onStart: () => void, single: boolean) {
await p.status();
}

async function runTest(name: string, retry?: boolean) {
async function runTest(name: string, retry?: boolean): Promise<number> {
const execBegin = Date.now();
const cmd = [
Deno.execPath(),
"test",
Expand All @@ -50,11 +51,12 @@ async function runTest(name: string, retry?: boolean) {
if (!retry) {
console.log("something wrong, retry...");
await new Promise((resolve) => setTimeout(resolve, 100));
await runTest(name, true);
return await runTest(name, true);
} else {
Deno.exit(code);
}
}
return Date.now() - execBegin
}

async function runCliTest() {
Expand Down Expand Up @@ -140,17 +142,18 @@ export async function existsFile(path: string): Promise<boolean> {
if (import.meta.main) {
const [testDir] = Deno.args;
startEsmServer(async () => {
let spentTimeCount = 0;
if (testDir) {
await runTest(testDir, true);
spentTimeCount += await runTest(testDir, true);
} else {
await runCliTest();
for await (const entry of Deno.readDir("./test")) {
if (entry.isDirectory && !entry.name.startsWith("_")) {
await runTest(entry.name);
spentTimeCount += await runTest(entry.name);
}
}
}
console.log("Done!");
console.log(`Done! Total time spent: ${spentTimeCount}`);
Deno.exit(0);
}, Boolean(testDir));
}