Skip to content

Commit ed6f6d7

Browse files
committed
Fail the install test if an internal ext header ships
Every other case here compiles against headers that are present, so putting the glob back over include/opentelemetry/ext would leave all of them passing while the package quietly grew five headers again. The check runs against the include directory the installed api target points at, not the test project's own prefix.
1 parent 6ade65d commit ed6f6d7

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

‎install/test/cmake/CMakeLists.txt‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,41 @@ endif()
4646

4747
message(STATUS "INSTALL_TEST_COMPONENTS = ${INSTALL_TEST_COMPONENTS}")
4848

49+
# The ext_common component installs a named list of headers rather than a glob
50+
# over include/opentelemetry/ext. Every other test here compiles against headers
51+
# that are present, so putting the glob back would leave them all passing. These
52+
# are the headers the component is meant to leave out, checked against the
53+
# prefix that was actually installed.
54+
if("ext_common" IN_LIST OPENTELEMETRY_CPP_COMPONENTS_INSTALLED)
55+
get_target_property(OTEL_API_INCLUDE_DIRS opentelemetry-cpp::api
56+
INTERFACE_INCLUDE_DIRECTORIES)
57+
list(GET OTEL_API_INCLUDE_DIRS 0 OTEL_INSTALLED_INCLUDE_DIR)
58+
message(
59+
STATUS
60+
"Checking ${OTEL_INSTALLED_INCLUDE_DIR} for headers that must not ship")
61+
62+
set(OTEL_EXT_HEADERS_NOT_INSTALLED
63+
"opentelemetry/ext/http/client/curl/http_client_curl.h"
64+
"opentelemetry/ext/http/client/curl/http_operation_curl.h"
65+
"opentelemetry/ext/http/client/detail/default_factory.h"
66+
"opentelemetry/ext/http/server/http_server.h"
67+
"opentelemetry/ext/http/server/socket_tools.h")
68+
69+
set(OTEL_UNEXPECTED_HEADERS "")
70+
foreach(header ${OTEL_EXT_HEADERS_NOT_INSTALLED})
71+
if(EXISTS "${OTEL_INSTALLED_INCLUDE_DIR}/${header}")
72+
list(APPEND OTEL_UNEXPECTED_HEADERS ${header})
73+
endif()
74+
endforeach()
75+
76+
if(OTEL_UNEXPECTED_HEADERS)
77+
message(
78+
FATAL_ERROR
79+
"The ext_common component installed headers it is meant to leave out: ${OTEL_UNEXPECTED_HEADERS}"
80+
)
81+
endif()
82+
endif()
83+
4984
set(INSTALL_TEST_SRC_DIR "${CMAKE_SOURCE_DIR}/../src")
5085

5186
enable_testing()

0 commit comments

Comments
 (0)