Skip to content

GH-47442: [C++] Use one bundled GoogleTest runtime on MSVC - #54782

Open
xgbtxy wants to merge 2 commits into
apache:mainfrom
xgbtxy:fix/gh-47442-shared-gtest-runtime
Open

xgbtxy wants to merge 2 commits into
apache:mainfrom
xgbtxy:fix/gh-47442-shared-gtest-runtime

Conversation

@xgbtxy

@xgbtxy xgbtxy commented Oct 20, 2026 •

Copy link
Copy Markdown

Rationale for this change

On MSVC, the bundled Google Mock DLLs embed their own GoogleTest runtime. Arrow's runners use gmock_main, while exported ArrowTesting assertions use gtest. Failures can therefore reach a different reporter: EXPECT_FATAL_FAILURE misses the assertion, and an ordinary helper failure can be printed while the process exits 0 and XML records success.

This addresses #47442 for the bundled-GTest MSVC CMake build, following #47434/#47455 and the earlier #4380 work.

What changes are included in this PR?

  • Select the same gmock_main runtime for Arrow's bundled MSVC GTest/GMock consumers.
  • Use that runtime in ArrowTesting's installed CMake interface and pkg-config metadata.
  • Restore Windows expected-failure checks when GoogleTest is shared or ArrowTesting is static, and add a regression for the exported array-equality assertion.

Windows shared ArrowTesting with a SYSTEM static GoogleTest still has separate reporters. Preserve the existing restriction on its expected-failure checks and explicitly skip the new reporter test in that configuration. Existing GTest targets remain available; SYSTEM and non-MSVC dependency mappings are unchanged.

Are these changes tested?

Windows x64, MSVC 19.44, Release, bundled GoogleTest 1.18.0, shared Arrow with static Arrow disabled:

  • Baseline: the two focused gtest-util cases and three scalar cases all fail because the runner captures zero expected failures.
  • Patched full suites: arrow-gtest-util-test 10 passed; arrow-scalar-test 168 passed.
  • Installed-package consumer linking only ArrowTesting::arrow_testing_shared: captured-failure test exits 0 with XML 1/0; an explicitly enabled uncaptured-failure probe exits 1 with XML 1/1.
  • DLL inspection confirms the consumer and ArrowTesting use arrow_gmock_main.dll. Installed CMake and pkg-config dependencies select that same runtime.
  • clang-format 18.1.8, cmake-format 0.6.13 and git diff --check pass.

Additional Windows x64/MSVC validation uses SYSTEM static GoogleTest 1.18.0 with shared ArrowTesting:

  • Before the linkage-specific guards, the two focused gtest-util cases and three scalar cases fail to capture helper assertions.
  • With the guards, the full gtest-util suite has 9 passed, 1 explicitly skipped; scalar has 168 passed. Logs and XML agree. The separate-runtime limitation remains; it is not fixed by this PR.
  • The bundled shared configuration was rebuilt after the guard adjustment: 10 + 168 passed, including the reporter regression without skipping.

Meson and SYSTEM shared-GoogleTest builds were not executed.

Are there any user-facing changes?

In bundled MSVC builds, failures from shared ArrowTesting helpers are correctly recorded by the test runner, including after installation. Arrow libraries remain shared.

Was AI used for this PR?

Codex generated the code and tests, performed code review, and ran the local validation described above.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

Copilot AI balanced review requested due to automatic review settings October 20, 2026 17:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #47442 has been automatically assigned in GitHub to PR creator.

Keep negative assertion capture disabled when Windows links static GoogleTest into both shared ArrowTesting and the runner. Continue checking shared GoogleTest and static ArrowTesting configurations, and explicitly skip the reporter test for separate runtimes.

Generated-by: OpenAI Codex
Copilot AI balanced review requested due to automatic review settings October 20, 2026 18:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants