-
Notifications
You must be signed in to change notification settings - Fork 6.1k
fix(reporter): expose setup/teardown projects to preprocessSuite #41731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
f71ca45
22a6054
8a4b6f6
a04af33
5e2b04f
8c413d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,12 +165,23 @@ export async function createRootSuite(testRun: TestRun, errors: TestError[], sho | |
| } | ||
| } | ||
|
|
||
| // Prepend dependency projects without filtration. | ||
| for (const [project, type] of projectClosure) { | ||
| if (type !== 'dependency') | ||
| continue; | ||
| const dependencySuite = buildProjectSuite(project, projectSuites.get(project)!); | ||
| dependencySuite._isDependency = true; | ||
| rootSuite._prependSuite(dependencySuite); | ||
| } | ||
|
|
||
| const preprocessResult = await testRun.reporter.preprocessSuite(config.config, rootSuite); | ||
| // Shard only the top-level projects. | ||
| if (config.config.shard && !preprocessResult?.implementsSharding) { | ||
| // Create test groups for top-level projects. | ||
| const testGroups: TestGroup[] = []; | ||
| for (const projectSuite of rootSuite.suites) { | ||
| if (projectSuite._isDependency) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of relying on the flag we set on suites, let's make decisions based on the local variables in this method, e.g. |
||
| continue; | ||
| // Split beforeAll-grouped tests into "config.shard.total" groups when needed. | ||
| // Later on, we'll re-split them between workers by using "config.workers" instead. | ||
| for (const group of createTestGroups(projectSuite, config.config.shard.total)) | ||
|
|
@@ -186,26 +197,19 @@ export async function createRootSuite(testRun: TestRun, errors: TestError[], sho | |
| } | ||
|
|
||
| // Update project suites, removing empty ones. | ||
| suiteUtils.filterTestsRemoveEmptySuites(rootSuite, test => testsInThisShard.has(test)); | ||
| suiteUtils.filterTestsRemoveEmptySuites(rootSuite, test => test.parent._isInDependencyProject() || testsInThisShard.has(test)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, let's not rely on |
||
| } | ||
|
|
||
| if (testRun.postShardTestFilters.length) | ||
| suiteUtils.filterTestsRemoveEmptySuites(rootSuite, test => testRun.postShardTestFilters.every(filter => filter(test))); | ||
|
|
||
| const topLevelProjects = []; | ||
| // Now prepend dependency projects without filtration. | ||
| { | ||
| // Filtering 'only' and sharding might have reduced the number of top-level projects. | ||
| // Build the project closure to only include dependencies that are still needed. | ||
| const projectClosure = new Map(buildProjectsClosure(rootSuite.suites.map(suite => suite._fullProject!))); | ||
|
|
||
| // Clone file suites for dependency projects. | ||
| for (const [project, level] of projectClosure.entries()) { | ||
| if (level === 'dependency') | ||
| rootSuite._prependSuite(buildProjectSuite(project, projectSuites.get(project)!)); | ||
| else | ||
| topLevelProjects.push(project); | ||
| } | ||
| suiteUtils.filterTestsRemoveEmptySuites(rootSuite, test => test.parent._isInDependencyProject() || testRun.postShardTestFilters.every(filter => filter(test))); | ||
|
|
||
| // Filtering 'only' and sharding might have reduced the number of top-level projects. | ||
| // Prune the project closure to only include dependencies that are still needed. | ||
| const topLevelProjects = rootSuite.suites.filter(suite => !suite._isDependency).map(suite => suite._fullProject!); | ||
| const neededClosure = buildProjectsClosure(topLevelProjects); | ||
| for (const projectSuite of [...rootSuite.suites]) { | ||
| if (projectSuite._isDependency && !neededClosure.has(projectSuite._fullProject!)) | ||
| rootSuite._detach(projectSuite); | ||
| } | ||
|
|
||
| testRun.rootSuite = rootSuite; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we unify
_isDependencyand_preprocessinginto a single enum? I'd likeSuiteto be as independent as possible from the environment around it.