Skip to content

Commit 6e46fd2

Browse files
committed
Run tests using ctest after all targets are built to reduce build contention
Reuse test runner compilation unit to reduce extra source files compiled by 189 Only build macOS tests for build host architecture that will be running them to reduce wasted CI time Signed-off-by: Rye <[email protected]>
1 parent 60a4033 commit 6e46fd2

File tree

10 files changed

+151
-76
lines changed

10 files changed

+151
-76
lines changed

autobuild.xml

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,7 +3018,7 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
30183018
<key>options</key>
30193019
<array>
30203020
<string>-G</string>
3021-
<string>Unix Makefiles</string>
3021+
<string>Ninja</string>
30223022
</array>
30233023
</map>
30243024
<key>build</key>
@@ -3076,7 +3076,7 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
30763076
<key>options</key>
30773077
<array>
30783078
<string>-G</string>
3079-
<string>Unix Makefiles</string>
3079+
<string>Ninja</string>
30803080
</array>
30813081
</map>
30823082
<key>build</key>
@@ -3163,19 +3163,15 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
31633163
<key>build</key>
31643164
<map>
31653165
<key>command</key>
3166-
<string>msbuild.exe</string>
3166+
<string>cmake</string>
31673167
<key>options</key>
31683168
<array>
3169-
<string>/p:Configuration=RelWithDebInfo</string>
3170-
<string>/p:Platform=${AUTOBUILD_WIN_VSPLATFORM|NOTWIN}</string>
3171-
<string>/t:Build</string>
3172-
<string>/p:useenv=true</string>
3173-
<string>/verbosity:minimal</string>
3174-
<string>/p:VCBuildAdditionalOptions= /incremental</string>
3175-
</array>
3176-
<key>arguments</key>
3177-
<array>
3178-
<string>SecondLife.sln</string>
3169+
<string>--build</string>
3170+
<string>.</string>
3171+
<string>--config</string>
3172+
<string>RelWithDebInfo</string>
3173+
<string>--parallel</string>
3174+
<string>$AUTOBUILD_CPU_COUNT</string>
31793175
</array>
31803176
</map>
31813177
<key>name</key>
@@ -3237,19 +3233,15 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string>
32373233
<key>build</key>
32383234
<map>
32393235
<key>command</key>
3240-
<string>msbuild.exe</string>
3236+
<string>cmake</string>
32413237
<key>options</key>
32423238
<array>
3243-
<string>/p:Configuration=Release</string>
3244-
<string>/p:Platform=${AUTOBUILD_WIN_VSPLATFORM|NOTWIN}</string>
3245-
<string>/t:Build</string>
3246-
<string>/p:useenv=true</string>
3247-
<string>/verbosity:minimal</string>
3248-
<string>/p:VCBuildAdditionalOptions= /incremental</string>
3249-
</array>
3250-
<key>arguments</key>
3251-
<array>
3252-
<string>SecondLife.sln</string>
3239+
<string>--build</string>
3240+
<string>.</string>
3241+
<string>--config</string>
3242+
<string>Release</string>
3243+
<string>--parallel</string>
3244+
<string>$AUTOBUILD_CPU_COUNT</string>
32533245
</array>
32543246
</map>
32553247
<key>name</key>

build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ build()
254254
"$autobuild" build --no-configure -c $variant \
255255
$eval_autobuild_build_parameters \
256256
|| fatal "failed building $variant"
257+
258+
ctest -C Release --test-dir "${build_dir}" --output-on-failure -j $(nproc --all) \
259+
|| fatal "failed testing $variant"
260+
257261
echo true >"$build_dir"/build_ok
258262
end_section "autobuild $variant"
259263

indra/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,32 @@ if (NOT CMAKE_BUILD_TYPE)
5656
"Build type. One of: Debug Release RelWithDebInfo" FORCE)
5757
endif (NOT CMAKE_BUILD_TYPE)
5858

59+
if (LL_TESTS)
60+
set(CMAKE_SKIP_TEST_ALL_DEPENDENCY FALSE)
61+
include(ProcessorCount)
62+
ProcessorCount(NUM_CORES)
63+
64+
# Set parallel level to decrease test runtime
65+
set(CMAKE_CTEST_ARGUMENTS -j${NUM_CORES} --output-on-failure)
66+
67+
# Set up our test targets
68+
set(CTEST_TEST_TARGET_ALIAS BUILD_AND_RUN_TESTS)
69+
include(CTest)
70+
71+
set_target_properties(BUILD_AND_RUN_TESTS
72+
PROPERTIES
73+
FOLDER "CMakePredefinedTargets"
74+
)
75+
76+
add_custom_target(BUILD_TESTS)
77+
add_dependencies(BUILD_AND_RUN_TESTS BUILD_TESTS)
78+
79+
set_target_properties(BUILD_TESTS
80+
PROPERTIES
81+
FOLDER "CMakePredefinedTargets"
82+
)
83+
endif ()
84+
5985
add_subdirectory(cmake)
6086

6187
if (USE_PRECOMPILED_HEADERS)

indra/cmake/LLAddBuildTest.cmake

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# -*- cmake -*-
2+
3+
include_guard()
4+
5+
if( NOT LL_TESTS )
6+
return()
7+
endif()
8+
29
include(00-Common)
310
include(LLTestCommand)
411
include(bugsplat)
@@ -26,15 +33,14 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources)
2633
#project(UNITTEST_PROJECT_${project})
2734
# Setup includes, paths, etc
2835
set(alltest_SOURCE_FILES
29-
${CMAKE_SOURCE_DIR}/test/test.cpp
30-
${CMAKE_SOURCE_DIR}/test/lltut.cpp
3136
)
3237
set(alltest_DEP_TARGETS
3338
# needed by the test harness itself
3439
llcommon
3540
)
3641

3742
set(alltest_LIBRARIES
43+
lltut_runner_lib
3844
llcommon
3945
)
4046
if(NOT "${project}" STREQUAL "llmath")
@@ -137,6 +143,7 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources)
137143
# test binaries always need to be signed for local development
138144
set_target_properties(PROJECT_${project}_TEST_${name}
139145
PROPERTIES
146+
OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE}
140147
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-")
141148
endif ()
142149

@@ -159,24 +166,15 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources)
159166
endif()
160167

161168
# Add test
162-
add_custom_command(
163-
OUTPUT ${TEST_OUTPUT}
169+
add_test(
170+
NAME PROJECT_${project}_TEST_${name}
164171
COMMAND ${TEST_SCRIPT_CMD}
165-
DEPENDS PROJECT_${project}_TEST_${name}
166172
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
167173
)
168-
# Why not add custom target and add POST_BUILD command?
169-
# Slightly less uncertain behavior
170-
# (OUTPUT commands run non-deterministically AFAIK) + poppy 2009-04-19
171-
# > I did not use a post build step as I could not make it notify of a
172-
# > failure after the first time you build and fail a test. - daveh 2009-04-20
174+
175+
add_dependencies(BUILD_TESTS PROJECT_${project}_TEST_${name})
173176
list(APPEND ${project}_TEST_OUTPUT ${TEST_OUTPUT})
174177
endforeach (source)
175-
176-
# Add the test runner target per-project
177-
# (replaces old _test_ok targets all over the place)
178-
add_custom_target(${project}_tests ALL DEPENDS ${${project}_TEST_OUTPUT})
179-
add_dependencies(${project} ${project}_tests)
180178
ENDMACRO(LL_ADD_PROJECT_UNIT_TESTS)
181179

182180
#*****************************************************************************
@@ -204,12 +202,11 @@ FUNCTION(LL_ADD_INTEGRATION_TEST
204202

205203
set(source_files
206204
tests/${testname}_test.cpp
207-
${CMAKE_SOURCE_DIR}/test/test.cpp
208-
${CMAKE_SOURCE_DIR}/test/lltut.cpp
209205
${additional_source_files}
210206
)
211207

212208
set(libraries
209+
lltut_runner_lib
213210
${library_dependencies}
214211
)
215212

@@ -239,6 +236,7 @@ FUNCTION(LL_ADD_INTEGRATION_TEST
239236
# test binaries always need to be signed for local development
240237
set_target_properties(INTEGRATION_TEST_${testname}
241238
PROPERTIES
239+
OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE}
242240
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-"
243241
BUILD_WITH_INSTALL_RPATH 1
244242
INSTALL_RPATH "@executable_path/Resources"
@@ -286,14 +284,9 @@ FUNCTION(LL_ADD_INTEGRATION_TEST
286284
message(STATUS "TEST_SCRIPT_CMD: ${TEST_SCRIPT_CMD}")
287285
endif()
288286

289-
add_custom_command(
290-
TARGET INTEGRATION_TEST_${testname}
291-
POST_BUILD
292-
COMMAND ${TEST_SCRIPT_CMD}
293-
)
287+
add_test(NAME INTEGRATION_TEST_RUNNER_${testname} COMMAND ${TEST_SCRIPT_CMD})
294288

295-
# Use CTEST? Not sure how to yet...
296-
# ADD_TEST(INTEGRATION_TEST_RUNNER_${testname} ${TEST_SCRIPT_CMD})
289+
add_dependencies(BUILD_TESTS INTEGRATION_TEST_${testname})
297290

298291
ENDFUNCTION(LL_ADD_INTEGRATION_TEST)
299292

indra/cmake/Variables.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
198198
set(CMAKE_XCODE_ATTRIBUTE_DISABLE_MANUAL_TARGET_ORDER_BUILD_WARNING YES)
199199
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_64_TO_32_BIT_CONVERSION NO)
200200
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "macOS Build Arch" FORCE)
201+
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
202+
set(LL_MACOS_TEST_ARCHITECTURE "arm64")
203+
else()
204+
set(LL_MACOS_TEST_ARCHITECTURE "x86_64")
205+
endif()
201206
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
202207

203208
# Default deploy grid

indra/cmake/run_build_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def main(command, arguments=[], libpath=[], vars={}):
133133
raise
134134
# In practice, the pathnames into CMake's build tree are so long as to
135135
# obscure the name of the test program. Just log its basename.
136-
log.warn("No such program %s; check for preceding build errors" % \
136+
log.warning("No such program %s; check for preceding build errors" % \
137137
os.path.basename(command[0]))
138138
# What rc should we simulate for missing executable? Windows produces
139139
# 9009.

indra/integration_tests/llimage_libtest/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ include(00-Common)
99
include(LLCommon)
1010
include(LLImage)
1111
include(LLMath)
12-
include(LLKDU)
1312

1413
set(llimage_libtest_SOURCE_FILES
1514
llimage_libtest.cpp
@@ -26,6 +25,18 @@ add_executable(llimage_libtest
2625
${llimage_libtest_SOURCE_FILES}
2726
)
2827

28+
set_target_properties(llimage_libtest
29+
PROPERTIES
30+
FOLDER "Tests"
31+
)
32+
33+
if(DARWIN)
34+
set_target_properties(llimage_libtest
35+
PROPERTIES
36+
OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE}
37+
)
38+
endif()
39+
2940
# Libraries on which this application depends on
3041
# Sort by high-level to low-level
3142
target_link_libraries(llimage_libtest

indra/integration_tests/llui_libtest/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,14 @@ target_link_libraries(llui_libtest
4949
llimagej2coj
5050
)
5151

52+
set_target_properties(llui_libtest
53+
PROPERTIES
54+
FOLDER "Tests"
55+
)
56+
5257
if (WINDOWS)
5358
set_target_properties(llui_libtest
54-
PROPERTIES
59+
PROPERTIES
5560
LINK_FLAGS "/NODEFAULTLIB:LIBCMT"
5661
)
5762

@@ -66,6 +71,13 @@ if (WINDOWS)
6671
)
6772
endif (WINDOWS)
6873

74+
if(DARWIN)
75+
set_target_properties(llui_libtest
76+
PROPERTIES
77+
OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE}
78+
)
79+
endif()
80+
6981
# Ensure people working on the viewer don't break this library
7082
# *NOTE: This could be removed, or only built by Parabuild, if the build
7183
# and link times become too long. JC

indra/llcorehttp/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ if (LL_TESTS AND LLCOREHTTP_TESTS)
169169
)
170170
endif (WINDOWS)
171171

172+
if(DARWIN)
173+
set_target_properties(http_texture_load
174+
PROPERTIES
175+
OSX_ARCHITECTURES ${LL_MACOS_TEST_ARCHITECTURE}
176+
)
177+
endif()
178+
172179
target_link_libraries(http_texture_load ${example_libs})
173180

174181
endif (LL_TESTS AND LLCOREHTTP_TESTS)

0 commit comments

Comments
 (0)