chore: apply only filtration to deps (#24268)

This commit is contained in:
Pavel Feldman 2023-07-17 16:48:52 -07:00 committed by GitHub
parent f6540f89ea
commit 5ff1fadd7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View file

@ -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) {
@ -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.

View file

@ -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: [
@ -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 }) => {