NFC: Fix gmock integration in unit tests (#8879)
Tested with the following code which passes (in arena.cpp, not in source-map.cpp which would have already worked previously due to how it was handled in the build file): ```c++ #include "gmock/gmock-matchers.h" ... EXPECT_THAT(1, ::testing::Eq(1)); ``` This was written by Gemini. I didn't quite understand the fix but I figured it's worth doing to make tests easier to write. Below is Gemini's description of the fix. --- Previously, when `BUILD_FUZZTEST=ON`, the `fuzztest` dependency would download its own newer version of `googletest` (v1.14.0) via CMake `FetchContent`. The `gmock` headers bundled in Binaryen's `third_party/googletest/googlemock` were incompatible with this newer `googletest`. This caused compilation failures for tests using `gmock`. As a workaround, `source-map.cpp` was completely excluded from the test suite during fuzztest builds. This fix works because `fuzztest`'s `FetchContent` actually makes the `gmock` target available as well. By linking `binaryen-unittests` against the `gmock` target when `BUILD_FUZZTEST=ON`, CMake correctly configures the include paths to use the newly fetched `gmock` headers instead of the bundled ones, seamlessly resolving the incompatibility. - Unconditionally include `source-map.cpp` in unit tests, rather than conditionally disabling it when `BUILD_FUZZTEST` is ON. - Link against the `gmock` target for `binaryen-unittests` when `BUILD_FUZZTEST` is ON.
S
Steven Fontanella committed
8c3dfa2d66a8983bebe6f1b3460189ac048232a2
Parent: f109fcd
Committed by GitHub <noreply@github.com>
on 7/1/2026, 4:32:01 AM