fix(tstest): Clear timeout identifiers after successful test execution and add local CLAUDE settings

This commit is contained in:
2025-05-24 01:42:24 +00:00
parent 2841aba8a4
commit 3649114c8d
3 changed files with 17 additions and 3 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/tstest',
version: '1.11.0',
version: '1.11.1',
description: 'a test utility to run tests that match test/**/*.ts'
}

View File

@ -153,8 +153,10 @@ export class TsTest {
// Handle timeout if specified
if (this.timeoutSeconds !== null) {
const timeoutMs = this.timeoutSeconds * 1000;
let timeoutId: NodeJS.Timeout;
const timeoutPromise = new Promise<void>((_resolve, reject) => {
setTimeout(() => {
timeoutId = setTimeout(() => {
execResultStreaming.childProcess.kill('SIGTERM');
reject(new Error(`Test file timed out after ${this.timeoutSeconds} seconds`));
}, timeoutMs);
@ -165,6 +167,8 @@ export class TsTest {
tapParser.handleTapProcess(execResultStreaming.childProcess),
timeoutPromise
]);
// Clear timeout if test completed successfully
clearTimeout(timeoutId);
} catch (error) {
// Handle timeout error
tapParser.handleTimeout(this.timeoutSeconds);
@ -294,8 +298,10 @@ export class TsTest {
// Handle timeout if specified
if (this.timeoutSeconds !== null) {
const timeoutMs = this.timeoutSeconds * 1000;
let timeoutId: NodeJS.Timeout;
const timeoutPromise = new Promise<void>((_resolve, reject) => {
setTimeout(() => {
timeoutId = setTimeout(() => {
reject(new Error(`Test file timed out after ${this.timeoutSeconds} seconds`));
}, timeoutMs);
});
@ -305,6 +311,8 @@ export class TsTest {
evaluatePromise,
timeoutPromise
]);
// Clear timeout if test completed successfully
clearTimeout(timeoutId);
} catch (error) {
// Handle timeout error
tapParser.handleTimeout(this.timeoutSeconds);