From 33f705d9613e9f7d79563769c3d3c7a37a6f341c Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sat, 24 May 2025 10:52:15 +0000 Subject: [PATCH] fix(tstest): Add timeout warning for long-running tests and introduce local settings configuration --- changelog.md | 8 ++++++++ ts/00_commitinfo_data.ts | 2 +- ts/tstest.classes.tstest.ts | 20 +++++++++++++++++--- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 7939e31..a24df3a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ # Changelog +## 2025-05-24 - 1.11.3 - fix(tstest) +Add timeout warning for long-running tests and introduce local settings configuration + +- Add .claude/settings.local.json with permission configuration for local development +- Implement a timeout warning timer that notifies when tests run longer than 1 minute without an explicit timeout +- Clear the timeout warning timer upon test completion +- Remove unused import of logPrefixes in tstest.classes.tstest.ts + ## 2025-05-24 - 1.11.2 - fix(tstest) Improve timeout and error handling in test execution along with TAP parser timeout logic improvements. diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 825d788..b866063 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: '1.11.2', + version: '1.11.3', description: 'a test utility to run tests that match test/**/*.ts' } diff --git a/ts/tstest.classes.tstest.ts b/ts/tstest.classes.tstest.ts index 936b4bc..28a2a73 100644 --- a/ts/tstest.classes.tstest.ts +++ b/ts/tstest.classes.tstest.ts @@ -1,6 +1,5 @@ import * as plugins from './tstest.plugins.js'; import * as paths from './tstest.paths.js'; -import * as logPrefixes from './tstest.logprefixes.js'; import { coloredString as cs } from '@push.rocks/consolecolor'; @@ -19,6 +18,7 @@ export class TsTest { public startFromFile: number | null; public stopAtFile: number | null; public timeoutSeconds: number | null; + private timeoutWarningTimer: NodeJS.Timeout | null = null; public smartshellInstance = new plugins.smartshell.Smartshell({ executor: 'bash', @@ -45,6 +45,16 @@ export class TsTest { await this.movePreviousLogFiles(); } + // Start timeout warning timer if no timeout was specified + if (this.timeoutSeconds === null) { + this.timeoutWarningTimer = setTimeout(() => { + // Use the logger instead of console.error to ensure the warning is visible + this.logger.error('Warning: Test is running for more than 1 minute.'); + this.logger.error('Consider using --timeout option to set a timeout for test files.'); + this.logger.error('Example: tstest test --timeout=300 (for 5 minutes)'); + }, 60000); // 1 minute + } + const testGroups = await this.testDir.getTestFileGroups(); const allFiles = [...testGroups.serial, ...Object.values(testGroups.parallelGroups).flat()]; @@ -83,6 +93,12 @@ export class TsTest { } } + // Clear the timeout warning timer if it was set + if (this.timeoutWarningTimer) { + clearTimeout(this.timeoutWarningTimer); + this.timeoutWarningTimer = null; + } + tapCombinator.evaluate(); } @@ -303,7 +319,6 @@ export class TsTest { ); // Handle timeout if specified - let hasTimedOut = false; if (this.timeoutSeconds !== null) { const timeoutMs = this.timeoutSeconds * 1000; let timeoutId: NodeJS.Timeout; @@ -323,7 +338,6 @@ export class TsTest { clearTimeout(timeoutId); } catch (error) { // Handle timeout error - hasTimedOut = true; tapParser.handleTimeout(this.timeoutSeconds); } } else {