forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: support parallel tsurge unit combining in batch test infra (ang…
…ular#58280) This allows the batch test for the signal input migration to pass. PR Close angular#58280
- Loading branch information
1 parent
8735543
commit cb34e40
Showing
4 changed files
with
58 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/core/schematics/utils/tsurge/helpers/combine_units.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.dev/license | ||
*/ | ||
|
||
import {TsurgeMigration} from '../migration'; | ||
|
||
/** | ||
* Synchronously combines unit data for the given migration. | ||
* | ||
* Note: This helper is useful for testing and execution of | ||
* Tsurge migrations in non-batchable environments. In general, | ||
* prefer parallel execution of combining via e.g. Beam combiners. | ||
*/ | ||
export async function synchronouslyCombineUnitData<UnitData>( | ||
migration: TsurgeMigration<UnitData, unknown>, | ||
unitDatas: UnitData[], | ||
): Promise<UnitData | null> { | ||
if (unitDatas.length === 0) { | ||
return null; | ||
} | ||
if (unitDatas.length === 1) { | ||
return unitDatas[0]; | ||
} | ||
|
||
let combined = unitDatas[0]; | ||
|
||
for (let i = 1; i < unitDatas.length; i++) { | ||
const other = unitDatas[i]; | ||
combined = await migration.combine(combined, other); | ||
} | ||
|
||
return combined; | ||
} |