Skip to content

Set hermes_build_mode constraint when building tester with coverage#56541

Closed
rubennorte wants to merge 1 commit into
react:mainfrom
rubennorte:export-D101832028
Closed

Set hermes_build_mode constraint when building tester with coverage#56541
rubennorte wants to merge 1 commit into
react:mainfrom
rubennorte:export-D101832028

Conversation

@rubennorte

Copy link
Copy Markdown
Contributor

Summary:
The Fantom test runner spawns native fantom-tester binaries built in
either dev or opt mode based on each test's fantom_mode pragma. When
collecting C++ code coverage of the tester binary, however, the build
may switch to a coverage-instrumented build configuration that does not
define REACT_NATIVE_DEBUG.

That breaks dev-mode tests that rely on debug-only native APIs. For
example, installHighResTimeStampMock in
private/react-native-fantom/tester/src/NativeFantom.cpp is gated on
#ifdef REACT_NATIVE_DEBUG and throws "Mocking timers is not supported
in optimized builds" otherwise. Tests like LongTasksAPI-itest.js (no
fantom_mode pragma → defaults to dev) fail in CI coverage runs with
that error.

When invoking buck with coverage enabled, layer the hermes_build_mode
constraint on top of the build platform so rn_build_mode() (in
tools/build_defs/oss/rn_defs.bzl) picks up the right value and adds
-DREACT_NATIVE_DEBUG for dev tests.

Differential Revision: D101832028

Summary:
The Fantom test runner spawns native `fantom-tester` binaries built in
either dev or opt mode based on each test's `fantom_mode` pragma. When
collecting C++ code coverage of the tester binary, however, the build
may switch to a coverage-instrumented build configuration that does not
define `REACT_NATIVE_DEBUG`.

That breaks dev-mode tests that rely on debug-only native APIs. For
example, `installHighResTimeStampMock` in
`private/react-native-fantom/tester/src/NativeFantom.cpp` is gated on
`#ifdef REACT_NATIVE_DEBUG` and throws "Mocking timers is not supported
in optimized builds" otherwise. Tests like `LongTasksAPI-itest.js` (no
`fantom_mode` pragma → defaults to dev) fail in CI coverage runs with
that error.

When invoking buck with coverage enabled, layer the `hermes_build_mode`
constraint on top of the build platform so `rn_build_mode()` (in
`tools/build_defs/oss/rn_defs.bzl`) picks up the right value and adds
`-DREACT_NATIVE_DEBUG` for dev tests.

Differential Revision: D101832028
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 21, 2026
@meta-codesync

meta-codesync Bot commented Apr 21, 2026

Copy link
Copy Markdown

@rubennorte has exported this pull request. If you are a Meta employee, you can view the originating Diff in D101832028.

@meta-codesync meta-codesync Bot closed this in 5c55a61 Apr 21, 2026
@facebook-github-tools facebook-github-tools Bot added the Merged This PR has been merged. label Apr 21, 2026
@meta-codesync

meta-codesync Bot commented Apr 21, 2026

Copy link
Copy Markdown

This pull request has been merged in 5c55a61.

@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @rubennorte in 5c55a61

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants