Skip to content

Commit

Permalink
fix: print milliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Oct 24, 2024
1 parent 4101153 commit 536f436
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ if (flavor.match(/^test/)) {
const files = globSync(list, { ignore });

function msToHumanDuration(ms) {
if (ms < 1000) return `${ms}ms`;
const seconds = Math.floor(ms / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
Expand Down Expand Up @@ -174,17 +175,27 @@ async function run() {

const promises = files.sort().map(async (file) => {
file = path.resolve(file);
const startTest = Date.now();
try {
await runTest(file);
ok++;
addLog(pc.green(`✔ ${file} ok`));
addLog(
pc.green(
`✔ ${file} ok - ${msToHumanDuration(Date.now() - startTest)}`,
),
);
} catch (error) {
failed.push({
file,
error: error.message,
output: error.logOutput,
});
addLog(pc.red(`✖ ${file} FAILED (in ${target})`), true);
addLog(
pc.red(
`✖ ${file} FAILED (in ${target}) - ${msToHumanDuration(Date.now() - startTest)}`,
),
true,
);
addLog(pc.red(error.message), true);
}

Expand Down

0 comments on commit 536f436

Please sign in to comment.