Skip to content

Commit 4b5cdf7

Browse files
committed
[test] Allow setting extra environment for running tests.
In some situations, in order to set the correct environment during some tests, extra environment has to be provided to the LLVM Lit invocations. It seems that the preferred way is using `cmake -E env` to be cross-platform. The environment can be set using a cached variable so it can be set from CMake cache files, or passing parameters to the CMake configuration step.
1 parent fda3dc5 commit 4b5cdf7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ set(LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py")
135135
# consecutive execution, which makes local builds fail faster.
136136
set(SWIFT_LIT_ARGS "--incremental" CACHE STRING "Arguments to pass to lit")
137137

138+
set(SWIFT_LIT_ENVIRONMENT "" CACHE STRING "Environment to use for lit invocations")
139+
138140
if(NOT SWIFT_INCLUDE_TOOLS)
139141
list(APPEND SWIFT_LIT_ARGS
140142
"--path=${SWIFT_NATIVE_LLVM_TOOLS_PATH}"
@@ -390,6 +392,7 @@ foreach(SDK ${SWIFT_SDKS})
390392
${command_upload_swift_reflection_test}
391393
${command_clean_test_results_dir}
392394
COMMAND
395+
${CMAKE_COMMAND} -E env ${SWIFT_LIT_ENVIRONMENT}
393396
$<TARGET_FILE:Python3::Interpreter> "${LIT}"
394397
${LIT_ARGS}
395398
"--param" "swift_test_subset=${test_subset}"
@@ -409,6 +412,7 @@ foreach(SDK ${SWIFT_SDKS})
409412
${command_upload_swift_reflection_test}
410413
${command_clean_test_results_dir}
411414
COMMAND
415+
${CMAKE_COMMAND} -E env ${SWIFT_LIT_ENVIRONMENT}
412416
$<TARGET_FILE:Python3::Interpreter> "${LIT}"
413417
${LIT_ARGS}
414418
"--param" "swift_test_subset=${test_subset}"

0 commit comments

Comments
 (0)