fix(tstest): Add timeout warning for long-running tests and introduce local settings configuration
This commit is contained in:
		| @@ -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 { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user