Build both coverage and non-coverage tester binaries in CI (#56538)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56538

The Fantom Jest `globalSetup` builds the `fantom-tester` native binaries
upfront, using `globalConfig.collectCoverage` to decide whether to build
the `-coverage` flavor.

However, `runner/coverageUtils.js`'s `shouldCollectCoverage()` returns
`false` for some tests even when `globalConfig.collectCoverage` is true:

- All benchmarks (filename matches `*Benchmark-itest.*`)
- Tests with the `fantom_disable_coverage` pragma

In CI coverage runs, those tests resolve their tester binary path with
`enableCoverage=false` (e.g. `fantom-tester-statichermesstable-opt`),
but `globalSetup` only built the `-coverage` variants, so spawn fails
with `ENOENT` and the test fails with an empty stdout/stderr and exit
code `-2`.

When `enableCoverage` is true, also build the non-coverage tester
variants so coverage-opt-out tests can find their binary.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D101819861

fbshipit-source-id: e82f7c8c548c9477d214e9265c813bf9b54ab141
This commit is contained in:
Rubén Norte authored and meta-codesync[bot] committed 2026-04-21 09:24:25 -07:00
1 parent 5f69a91186
commit dbd3255194
1 file changed
+17 -4
+17 -4
View File
@@ -50,12 +50,25 @@ export default async function build(
fs.mkdirSync(NATIVE_BUILD_OUTPUT_PATH, {recursive: true});
if (isCI) {
// When `enableCoverage` is true (CI coverage runs), we still need the
// non-coverage tester binaries because some tests opt out of coverage
// (benchmarks via filename, or tests with the `@fantom_disable_coverage`
// pragma — see `runner/coverageUtils.js`). Without these, those tests
// would fail to spawn with ENOENT.
const coverageVariants = enableCoverage ? [false, true] : [false];
for (const enableOptimized of [false, true]) {
for (const hermesVariant of HermesVariant.members()) {
buildFantomTester(
{enableOptimized, hermesVariant, enableCoverage},
env,
);
for (const variantEnableCoverage of coverageVariants) {
buildFantomTester(
{
enableOptimized,
hermesVariant,
enableCoverage: variantEnableCoverage,
},
env,
);
}
buildHermesCompiler({enableOptimized, hermesVariant, enableCoverage});
}
}