fix(test runner): do not print timeout message upon interrupt (#20574)

We should only print "Test was interrupted."

Regressed in #18321.
This commit is contained in:
Dmitry Gozman 2023-02-01 19:39:43 -08:00 committed by GitHub
parent 8f229fac9e
commit 5fb430a743
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -161,10 +161,12 @@ export class TestInfoImpl implements TestInfo {
async _runWithTimeout(cb: () => Promise<any>): Promise<void> {
const timeoutError = await this._timeoutManager.runWithTimeout(cb);
// Do not overwrite existing failure upon hook/teardown timeout.
if (timeoutError && !this._didTimeout) {
// When interrupting, we arrive here with a timeoutError, but we should not
// consider it a timeout.
if (this.status !== 'interrupted' && timeoutError && !this._didTimeout) {
this._didTimeout = true;
this.errors.push(timeoutError);
// Do not overwrite existing failure upon hook/teardown timeout.
if (this.status === 'passed' || this.status === 'skipped')
this.status = 'timedOut';
}

View File

@ -112,7 +112,7 @@ test('sigint should stop workers', async ({ runInlineTest }) => {
console.log('\\n%%skipped2');
});
`,
}, { 'workers': 2 }, {}, { sendSIGINTAfter: 2 });
}, { 'workers': 2, 'reporter': 'line,json' }, {}, { sendSIGINTAfter: 2 });
expect(result.exitCode).toBe(130);
expect(result.passed).toBe(0);
expect(result.failed).toBe(0);
@ -122,6 +122,8 @@ test('sigint should stop workers', async ({ runInlineTest }) => {
expect(result.output).toContain('%%SEND-SIGINT%%2');
expect(result.output).not.toContain('%%skipped1');
expect(result.output).not.toContain('%%skipped2');
expect(result.output).toContain('Test was interrupted.');
expect(result.output).not.toContain('Test timeout of');
const interrupted2 = result.report.suites[1].specs[0];
expect(interrupted2.title).toBe('interrupted2');