Skip to content

Commit 063f849

Browse files
committed
Reverted to throwing a simple error
1 parent ac4f79a commit 063f849

File tree

3 files changed

+17
-37
lines changed

3 files changed

+17
-37
lines changed

packages/playwright/src/common/ipc.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ export type DonePayload = {
125125
fatalErrors: TestInfoErrorImpl[];
126126
skipTestsDueToSetupFailure: string[]; // test ids
127127
fatalUnknownTestIds?: string[];
128-
missingProjectById?: string;
129128
};
130129

131130
export type TestOutputPayload = {

packages/playwright/src/runner/dispatcher.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -412,18 +412,11 @@ class JobDispatcher {
412412
// - there are no remaining
413413
// - we are here not because something failed
414414
// - no unrecoverable worker error
415-
if (!this._remainingByTestId.size && !this._failedTests.size && !params.fatalErrors.length && !params.skipTestsDueToSetupFailure.length && !params.fatalUnknownTestIds && !params.missingProjectById && !params.unexpectedExitError) {
415+
if (!this._remainingByTestId.size && !this._failedTests.size && !params.fatalErrors.length && !params.skipTestsDueToSetupFailure.length && !params.fatalUnknownTestIds && !params.unexpectedExitError) {
416416
this._finished({ didFail: false });
417417
return;
418418
}
419419

420-
if (params.missingProjectById) {
421-
this._failureTracker.onWorkerError();
422-
this._reporter.onError?.({ message: `Project with name ${params.missingProjectById} not found. Make sure project name does not change.` });
423-
this._finished({ didFail: true, newJob: undefined });
424-
return;
425-
}
426-
427420
for (const testId of params.fatalUnknownTestIds || []) {
428421
const test = this._remainingByTestId.get(testId);
429422
if (test) {

packages/playwright/src/worker/workerMain.ts

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,17 @@ export class WorkerMain extends ProcessRunner {
105105
}
106106

107107
override async gracefullyClose() {
108-
if (this._isMissingProject) {
109-
// Never set anything up and we can crash on attempting cleanup
110-
return;
111-
}
112-
113108
try {
114109
await this._stop();
110+
if (this._isMissingProject) {
111+
// We never set anything up and we can crash on attempting cleanup
112+
return;
113+
}
115114
// Ignore top-level errors, they are already inside TestInfo.errors.
116115
const fakeTestInfo = new TestInfoImpl(this._config, this._project, this._params, undefined, 0, () => {}, () => {}, () => {});
117116
const runnable = { type: 'teardown' } as const;
118117
// We have to load the project to get the right deadline below.
119-
await fakeTestInfo._runAsStage({ title: 'worker cleanup', runnable }, () => this._load()).catch(() => {});
118+
await fakeTestInfo._runAsStage({ title: 'worker cleanup', runnable }, () => this._loadIfNeeded()).catch(() => {});
120119
await this._fixtureRunner.teardownScope('test', fakeTestInfo, runnable).catch(() => {});
121120
await this._fixtureRunner.teardownScope('worker', fakeTestInfo, runnable).catch(() => {});
122121
// Close any other browsers launched in this process. This includes anything launched
@@ -193,43 +192,33 @@ export class WorkerMain extends ProcessRunner {
193192
void this._stop();
194193
}
195194

196-
private async _load(): Promise<{
197-
config: FullConfigInternal,
198-
project: FullProjectInternal,
199-
poolBuilder: PoolBuilder,
200-
} | undefined> {
195+
private async _loadIfNeeded() {
201196
if (this._config)
202-
return { config: this._config, project: this._project, poolBuilder: this._poolBuilder };
197+
return;
203198

204199
this._config = await deserializeConfig(this._params.config);
205200
const project = this._config.projects.find(p => p.id === this._params.projectId);
206-
if (!project)
207-
return undefined;
201+
if (!project) {
202+
this._isMissingProject = true;
203+
throw new Error(`Project with name "${this._params.projectId}" not found. Make sure project name does not change`);
204+
}
208205
this._project = project;
209206
this._poolBuilder = PoolBuilder.createForWorker(this._project);
210-
211-
return { config: this._config, project: this._project, poolBuilder: this._poolBuilder };
212207
}
213208

214209
async runTestGroup(runPayload: RunPayload) {
215210
this._runFinished = new ManualPromise<void>();
216211
const entries = new Map(runPayload.entries.map(e => [e.testId, e]));
217212
let fatalUnknownTestIds: string[] | undefined;
218213
try {
219-
const workerState = await this._load();
220-
if (!workerState) {
221-
this._isMissingProject = true;
222-
void this._stop();
223-
return;
224-
}
225-
const { config, project, poolBuilder } = workerState;
226-
const fileSuite = await loadTestFile(runPayload.file, config.config.rootDir);
227-
const suite = bindFileSuiteToProject(project, fileSuite);
214+
await this._loadIfNeeded();
215+
const fileSuite = await loadTestFile(runPayload.file, this._config.config.rootDir);
216+
const suite = bindFileSuiteToProject(this._project, fileSuite);
228217
if (this._params.repeatEachIndex)
229-
applyRepeatEachIndex(project, suite, this._params.repeatEachIndex);
218+
applyRepeatEachIndex(this._project, suite, this._params.repeatEachIndex);
230219
const hasEntries = filterTestsRemoveEmptySuites(suite, test => entries.has(test.id));
231220
if (hasEntries) {
232-
poolBuilder.buildPools(suite);
221+
this._poolBuilder.buildPools(suite);
233222
this._activeSuites = new Map();
234223
this._didRunFullCleanup = false;
235224
const tests = suite.allTests();
@@ -258,7 +247,6 @@ export class WorkerMain extends ProcessRunner {
258247
fatalErrors: this._fatalErrors,
259248
skipTestsDueToSetupFailure: [],
260249
fatalUnknownTestIds,
261-
missingProjectById: this._isMissingProject ? this._params.projectId : undefined
262250
};
263251
for (const test of this._skipRemainingTestsInSuite?.allTests() || []) {
264252
if (entries.has(test.id))

0 commit comments

Comments
 (0)