From eeb62e3346f1403b42769330f6551bab3e794bc2 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 8 Oct 2024 00:18:07 +0200 Subject: [PATCH] cli: few extra comments for repo test Signed-off-by: Patrik Oldsberg --- packages/cli/src/commands/repo/test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/cli/src/commands/repo/test.ts b/packages/cli/src/commands/repo/test.ts index 4e11e07515..06e96b766b 100644 --- a/packages/cli/src/commands/repo/test.ts +++ b/packages/cli/src/commands/repo/test.ts @@ -289,6 +289,7 @@ export async function command(opts: OptionValues, cmd: Command): Promise { // are picked up by the config script itself, as well as the custom result processor. const globalWithCache = global as GlobalWithCache; globalWithCache.__backstageCli_jestSuccessCache = { + // This is called by `config/jest.js` after the project configs have been gathered async filterConfigs(projectConfigs, globalRootConfig) { const cache = await readCache(cacheDir); const lockfile = await Lockfile.load( @@ -340,9 +341,11 @@ export async function command(opts: OptionValues, cmd: Command): Promise { return project; }); }, + // This is called by `config/jestCacheResultProcess.cjs` after all tests have run async reportResults(results) { const successful = new Set(); const failed = new Set(); + for (const testResult of results.testResults) { for (const [pkgName, pkg] of graph) { if (isChildPath(pkg.dir, testResult.testFilePath)) { @@ -360,12 +363,14 @@ export async function command(opts: OptionValues, cmd: Command): Promise { } } } + for (const pkgName of successful) { const sha = projectHashes.get(pkgName); if (sha) { outputSuccessCache.push(sha); } } + await writeCache(cacheDir, outputSuccessCache); }, };