fix(tstest): Improve timeout and error handling in test execution along with TAP parser timeout logic improvements.

This commit is contained in:
2025-05-24 02:22:34 +00:00
parent 23addc2d2f
commit 63280e4a9a
4 changed files with 49 additions and 14 deletions

View File

@@ -36,18 +36,20 @@ export class TapParser {
* Handle test file timeout
*/
public handleTimeout(timeoutSeconds: number) {
// If no tests have been defined yet, set expected to 1
if (this.expectedTests === 0) {
this.expectedTests = 1;
}
// Create a fake failing test result for timeout
this._getNewTapTestResult();
this.activeTapTestResult.testOk = false;
this.activeTapTestResult.testSettled = true;
this.testStore.push(this.activeTapTestResult);
// Set expected vs received to force failure
this.expectedTests = 1;
this.receivedTests = 0;
// Log the timeout error
if (this.logger) {
// First log the test result
this.logger.testResult(
`Test file timeout`,
false,
@@ -55,9 +57,9 @@ export class TapParser {
`Error: Test file exceeded timeout of ${timeoutSeconds} seconds`
);
this.logger.testErrorDetails(`Test execution was terminated after ${timeoutSeconds} seconds`);
// Force file end with failure
this.logger.testFileEnd(0, 1, timeoutSeconds * 1000);
}
// Don't call evaluateFinalResult here, let the caller handle it
}
private _getNewTapTestResult() {