From d1f8652fc7d5aa24bedb848b42b7ccc712e4850b Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Mon, 26 May 2025 05:01:06 +0000 Subject: [PATCH] fix(logging): Improve performance metrics reporting and add local permissions configuration --- changelog.md | 6 ++++++ ts/00_commitinfo_data.ts | 2 +- ts/tstest.logging.ts | 22 +++++++++++++++------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index 4974cb7..92ca6dc 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2025-05-26 - 2.2.4 - fix(logging) +Improve performance metrics reporting and add local permissions configuration + +- Add .claude/settings.local.json to configure allowed permissions for various commands +- Update tstest logging: compute average test duration from actual durations and adjust slowest test display formatting + ## 2025-05-26 - 2.2.3 - fix(readme/ts/tstest.plugins) Update npm package scope and documentation to use '@git.zone' instead of '@gitzone', and add local settings configuration. diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 63a166a..cf0d99a 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/tstest', - version: '2.2.3', + version: '2.2.4', description: 'a test utility to run tests that match test/**/*.ts' } diff --git a/ts/tstest.logging.ts b/ts/tstest.logging.ts index b270ef1..897ea11 100644 --- a/ts/tstest.logging.ts +++ b/ts/tstest.logging.ts @@ -425,15 +425,23 @@ export class TsTestLogger { // Performance metrics if (this.options.verbose) { - const avgDuration = Math.round(totalDuration / summary.totalTests); - const slowestTest = this.fileResults - .flatMap(r => r.tests) - .sort((a, b) => b.duration - a.duration)[0]; + // Calculate metrics based on actual test durations + const allTests = this.fileResults.flatMap(r => r.tests); + const testDurations = allTests.map(t => t.duration); + const sumOfTestDurations = testDurations.reduce((sum, d) => sum + d, 0); + const avgTestDuration = allTests.length > 0 ? Math.round(sumOfTestDurations / allTests.length) : 0; + + // Find slowest test (exclude 0ms durations unless all are 0) + const nonZeroDurations = allTests.filter(t => t.duration > 0); + const testsToSort = nonZeroDurations.length > 0 ? nonZeroDurations : allTests; + const slowestTest = testsToSort.sort((a, b) => b.duration - a.duration)[0]; this.log(this.format('\n⏱️ Performance Metrics:', 'cyan')); - this.log(this.format(` Average per test: ${avgDuration}ms`, 'white')); - if (slowestTest) { - this.log(this.format(` Slowest test: ${slowestTest.name} (${slowestTest.duration}ms)`, 'yellow')); + this.log(this.format(` Average per test: ${avgTestDuration}ms`, 'white')); + if (slowestTest && slowestTest.duration > 0) { + this.log(this.format(` Slowest test: ${slowestTest.name} (${slowestTest.duration}ms)`, 'orange')); + } else if (allTests.length > 0) { + this.log(this.format(` All tests completed in <1ms`, 'dim')); } }