mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(runner): do not hang on worker exit before tests (#22742)
This commit is contained in:
parent
fcd966c4e5
commit
a4e90f20dc
@ -214,8 +214,10 @@ export class Dispatcher {
|
||||
|
||||
const remainingByTestId = new Map(testGroup.tests.map(e => [e.id, e]));
|
||||
const failedTestIds = new Set<string>();
|
||||
let runningTest = false;
|
||||
|
||||
const onTestBegin = (params: TestBeginPayload) => {
|
||||
runningTest = true;
|
||||
const data = this._testById.get(params.testId)!;
|
||||
const result = data.test._appendTestResult();
|
||||
data.resultByWorkerIndex.set(worker.workerIndex, { result, steps: new Map() });
|
||||
@ -228,6 +230,7 @@ export class Dispatcher {
|
||||
worker.addListener('testBegin', onTestBegin);
|
||||
|
||||
const onTestEnd = (params: TestEndPayload) => {
|
||||
runningTest = false;
|
||||
remainingByTestId.delete(params.testId);
|
||||
if (this._hasReachedMaxFailures()) {
|
||||
// Do not show more than one error to avoid confusion, but report
|
||||
@ -339,7 +342,7 @@ export class Dispatcher {
|
||||
if (runData) {
|
||||
result = runData.result;
|
||||
} else {
|
||||
if (onlyStartedTests)
|
||||
if (onlyStartedTests && runningTest)
|
||||
return true;
|
||||
result = data.test._appendTestResult();
|
||||
this._reporter.onTestBegin(test, result);
|
||||
|
@ -526,3 +526,19 @@ throw new Error('should not load nomap.spec.js');`,
|
||||
expect(result.output).not.toContain('should not load');
|
||||
expect(result.output).toContain('gherkin.feature:1');
|
||||
});
|
||||
|
||||
test('should not hang on worker error in test file', async ({ runInlineTest }) => {
|
||||
const result = await runInlineTest({
|
||||
'example.spec.js': `
|
||||
import { test, expect } from '@playwright/test';
|
||||
if (process.env.TEST_WORKER_INDEX)
|
||||
process.exit(1);
|
||||
test('test 1', async () => {});
|
||||
test('test 2', async () => {});
|
||||
`,
|
||||
}, { 'timeout': 3000 });
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.results[0].status).toBe('failed');
|
||||
expect(result.results[0].error.message).toContain('Internal error: worker process exited unexpectedly');
|
||||
expect(result.results[1].status).toBe('skipped');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user