Skip to content

Commit

Permalink
chore: apply only filtration to deps (#24268)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman committed Jul 17, 2023
1 parent f6540f8 commit 5ff1fad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 12 additions & 4 deletions packages/playwright-test/src/runner/loadUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@ export async function createRootSuite(testRun: TestRun, errors: TestError[], sho
}
}

if (shouldFilterOnly) {
// Create a fake root to execute the exclusive semantics across the projects.
const filteredRoot = new Suite('', 'root');
for (const filteredProjectSuite of filteredProjectSuites.values())
filteredRoot._addSuite(filteredProjectSuite);
filterOnly(filteredRoot);
for (const [project, filteredProjectSuite] of filteredProjectSuites) {
if (!filteredRoot.suites.includes(filteredProjectSuite))
filteredProjectSuites.delete(project);
}
}

// Add post-filtered top-level projects to the root suite for sharding and 'only' processing.
const projectClosure = buildProjectsClosure([...filteredProjectSuites.keys()], project => filteredProjectSuites.get(project)!._hasTests());
for (const [project, type] of projectClosure) {
Expand All @@ -162,10 +174,6 @@ export async function createRootSuite(testRun: TestRun, errors: TestError[], sho
}
}

// Filter only for top-level projects.
if (shouldFilterOnly)
filterOnly(rootSuite);

// Shard only the top-level projects.
if (config.config.shard) {
// Create test groups for top-level projects.
Expand Down
4 changes: 2 additions & 2 deletions tests/playwright-test/deps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ test('should not filter dependency by file name', async ({ runInlineTest }) => {
expect(result.output).toContain('1) [A] › one.spec.ts:3:11 › fails');
});

test('should not filter dependency by only', async ({ runInlineTest }) => {
test('should filter dependency by only', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `
module.exports = { projects: [
Expand All @@ -235,7 +235,7 @@ test('should not filter dependency by only', async ({ runInlineTest }) => {
`,
});
expect(result.exitCode).toBe(0);
expect(result.outputLines).toEqual(['setup in setup', 'setup 2 in setup', 'test in browser']);
expect(result.outputLines).toEqual(['setup 2 in setup']);
});

test('should filter dependency by only when running explicitly', async ({ runInlineTest }) => {
Expand Down

0 comments on commit 5ff1fad

Please sign in to comment.