Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: GTest 1.13 won't compile on UWP #4165

Closed
horenmar opened this issue Feb 22, 2023 · 1 comment
Closed

[Bug]: GTest 1.13 won't compile on UWP #4165

horenmar opened this issue Feb 22, 2023 · 1 comment
Assignees

Comments

@horenmar
Copy link

Describe the issue

Compiling GTest 1.13 for UWP (Universal Windows Platform) fails, with the following error message

D:\buildtrees\gtest\src\v1.13.0-530d8ac571.clean\googletest\src/gtest.cc(5417): error C2065: 'in_death_test_child_process': undeclared identifier
[3/12] C:\PROGRA~1\MICROS~1\2022\ENTERP~1\VC\Tools\MSVC\1434~1.319\bin\Hostx64\x64\cl.exe   /TP -DGTEST_CREATE_SHARED_LIBRARY=1 -Dgmock_main_EXPORTS -ID:\buildtrees\gtest\src\v1.13.0-530d8ac571.clean\googlemock\include -ID:\buildtrees\gtest\src\v1.13.0-530d8ac571.clean\googlemock -ID:\buildtrees\gtest\src\v1.13.0-530d8ac571.clean\googletest\include -ID:\buildtrees\gtest\src\v1.13.0-530d8ac571.clean\googletest /DWIN32 /D_WINDOWS /D_UNICODE /DUNICODE /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB__ /nologo /Z7 /MP /GS /Gd /Gm- /W4 /WX- /Zc:wchar_t /Zc:inline /Zc:forScope /fp:precise /Oy-   /utf-8  /D_DEBUG /MDd /Od /RTC1  -GS -W4 -WX -wd4251 -wd4275 -nologo -J -D_UNICODE -DUNICODE -DWIN32 -D_WIN32 -DSTRICT -DWIN32_LEAN_AND_MEAN -wd4702 -utf-8 -DGTEST_HAS_PTHREAD=0 -EHsc -D_HAS_EXCEPTIONS=1 /showIncludes /Fogooglemock\CMakeFiles\gmock_main.dir\__\googletest\src\gtest-all.cc.obj /Fdlib\gmock_mainpdb_debug_postfix-NOTFOUND.pdb /FS -c D:\buildtrees\gtest\src\v1.13.0-530d8ac571.clean\googletest\src\gtest-all.cc
FAILED: googlemock/CMakeFiles/gmock_main.dir/__/googletest/src/gtest-all.cc.obj 

The issue is that in UnitTest::Run(), in_death_test_child_process is defined inside conditional block guarded by GTEST_HAS_DEATH_TEST, but later on, it is referred to from another conditional code block, this one guarded by GTEST_OS_WINDOWS. Since UWP is Windows, but GTEST_HAS_DEATH_TEST (likely correctly) is false on UWP, this fails the compilation.

Steps to reproduce the problem

Compile GTest for UWP.

What version of GoogleTest are you using?

1.13.0

What operating system and version are you using?

Windows

What compiler and version are you using?

MSVC, but the version is irrelevant.

What build system are you using?

cmake 3.25 + ninja, but again, irrelevant

Additional context

The current main branch still has the same issue, see

#if GTEST_HAS_DEATH_TEST
const bool in_death_test_child_process =
GTEST_FLAG_GET(internal_run_death_test).length() > 0;
and
#if GTEST_OS_WINDOWS
// Either the user wants Google Test to catch exceptions thrown by the
// tests or this is executing in the context of death test child
// process. In either case the user does not want to see pop-up dialogs
// about crashes - they are expected.
if (impl()->catch_exceptions() || in_death_test_child_process) {

I think the simplest way to fix this would be to change the main #if GTEST_OS_WINDOWS to #if GTEST_OS_WINDOWS && GTEST_HAS_DEATH_TEST, so that all the death test related set up is skipped when it is not supported.

@higher-performance
Copy link
Collaborator

Thanks for reporting. This should be resolved along with #4164.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants