Commit 1c15eb39 authored by Brad King's avatar Brad King
Browse files

Tests: Suppress failures on macOS arm64 due to separate Xcode signing phase

Some tests fail because Xcode runs `POST_BUILD` commands before signing
the binaries they run.  Tell the linker to perform ad-hoc codesign even
though Xcode normally tells it not to.

Other tests fail because `install_name_tool` does not revise ad-hoc
signatures without the codesign `linker-signed` flag.  Add that flag
ourselves where needed by our tests.

For now these changes help our test suite pass so we can use it to cover
everything else.  Both of these cases may need further investigation to
update CMake to help projects in general.

Issue: #21845, #21854
parent 92418ac0
Pipeline #215592 waiting for manual action with stages
in 54 minutes and 49 seconds
......@@ -3,6 +3,15 @@ project(BundleTest)
set(MACOSX_BUNDLE_INFO_STRING "bundle_info_string")
set(CMAKE_MacOSX_Content_COMPILE_OBJECT "\"${CMAKE_COMMAND}\" -E copy_if_different <SOURCE> <OBJECT>")
if(CMAKE_GENERATOR STREQUAL "Xcode" AND
"${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64")
# Tell Xcode to pretend the linker signed binaries so that
# editing with install_name_tool preserves ad-hoc signatures.
# See CMake Issue 21854.
# This option is supported by codesign on macOS 11 or higher.
set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "-o linker-signed")
endif()
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
COMMAND /bin/cp
......
cmake_minimum_required(VERSION 2.8.12)
project(BundleUtilities)
if(CMAKE_GENERATOR STREQUAL "Xcode" AND
"${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64")
# Tell Xcode to pretend the linker signed binaries so that
# editing with install_name_tool preserves ad-hoc signatures.
# See CMake Issue 21854.
# This option is supported by codesign on macOS 11 or higher.
set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "-o linker-signed")
endif()
###### the various types of dependencies we can have
# a shared library
......
......@@ -3,7 +3,10 @@ include(GoogleTest)
enable_testing()
include(xcode_sign_adhoc.cmake)
add_executable(fake_gtest fake_gtest.cpp)
xcode_sign_adhoc(fake_gtest)
gtest_discover_tests(
fake_gtest
......@@ -22,6 +25,7 @@ gtest_discover_tests(
)
add_executable(no_tests_defined no_tests_defined.cpp)
xcode_sign_adhoc(no_tests_defined)
gtest_discover_tests(
no_tests_defined
......@@ -33,6 +37,7 @@ gtest_discover_tests(
# 3.10.3 and later behavior, old behavior added in 3.10.1
# is not supported.
add_executable(property_timeout_test timeout_test.cpp)
xcode_sign_adhoc(property_timeout_test)
target_compile_definitions(property_timeout_test PRIVATE sleepSec=10)
gtest_discover_tests(
......@@ -50,6 +55,7 @@ gtest_discover_tests(
)
add_executable(skip_test skip_test.cpp)
xcode_sign_adhoc(skip_test)
gtest_discover_tests(
skip_test
......
......@@ -3,7 +3,10 @@ include(GoogleTest)
enable_testing()
include(xcode_sign_adhoc.cmake)
add_executable(configuration_gtest configuration_gtest.cpp)
xcode_sign_adhoc(configuration_gtest)
target_compile_definitions(configuration_gtest PRIVATE $<$<CONFIG:Debug>:DEBUG=1>)
gtest_discover_tests(
......
......@@ -3,7 +3,10 @@ include(GoogleTest)
enable_testing()
include(xcode_sign_adhoc.cmake)
add_executable(discovery_timeout_test timeout_test.cpp)
xcode_sign_adhoc(discovery_timeout_test)
target_compile_definitions(discovery_timeout_test PRIVATE discoverySleepSec=10)
gtest_discover_tests(
discovery_timeout_test
......
......@@ -3,6 +3,8 @@ include(GoogleTest)
enable_testing()
include(xcode_sign_adhoc.cmake)
# This creates the folder structure for the paramterized tests
# to avoid handling missing folders in C++
#
......@@ -15,6 +17,7 @@ enable_testing()
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/GoogleTestXMLSpecial/cases.case")
add_executable(xml_output xml_output.cpp)
xcode_sign_adhoc(xml_output)
gtest_discover_tests(
xml_output
XML_OUTPUT_DIR ${CMAKE_BINARY_DIR}
......
function(xcode_sign_adhoc target)
if(CMAKE_GENERATOR STREQUAL "Xcode" AND
"${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64")
# Xcode runs POST_BUILD before signing, so let the linker use ad-hoc signing.
# See CMake Issue 21845.
target_link_options(${target} PRIVATE LINKER:-adhoc_codesign)
endif()
endfunction()
......@@ -12,4 +12,10 @@ add_executable(LinkObjLHSShared LinkObjLHSShared.c)
target_link_libraries(LinkObjLHSShared AnObjLib)
# Verify that our dependency on OtherLib generated its versioning symlinks.
if(CMAKE_GENERATOR STREQUAL "Xcode" AND
"${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Darwin;arm64")
# Xcode runs POST_BUILD before signing, so let the linker use ad-hoc signing.
# See CMake Issue 21845.
target_link_options(LinkObjLHSShared PRIVATE LINKER:-adhoc_codesign)
endif()
add_custom_command(TARGET LinkObjLHSShared POST_BUILD COMMAND LinkObjLHSShared)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment