Commit 607b0c75 authored by Craig Scott's avatar Craig Scott
Browse files

Tests: Start DownloadServer.py in a RunCMake.ExternalProject subtest

The DownloadServer.py script was previously being executed directly
in the RunCMakeTest.cmake script. When using the RunCMake_TEST_FILTER
to control which subtests to run, this script was always executed even
when not needed. By starting it up via a run_cmake_command() call,
it now does honor the filter.
parent 639a6bd4
file(READ ${URL_FILE} SERVER_URL)
include(ExternalProject)
ExternalProject_Add(MyProj URL ${SERVER_URL} INACTIVITY_TIMEOUT 2 DOWNLOAD_NO_EXTRACT TRUE
CONFIGURE_COMMAND ""
......
file(READ ${URL_FILE} SERVER_URL)
include(ExternalProject)
ExternalProject_Add(MyProj URL ${SERVER_URL} INACTIVITY_TIMEOUT 2 DOWNLOAD_NO_EXTRACT TRUE
CONFIGURE_COMMAND ""
......
......@@ -85,36 +85,24 @@ function(__ep_test_with_build_with_server testName)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
set(URL_FILE ${RunCMake_BINARY_DIR}/${testName}.url)
if(EXISTS "${URL_FILE}")
file(REMOVE "${URL_FILE}")
endif()
execute_process(
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/DownloadServer.py --file "${URL_FILE}" ${ARGN}
OUTPUT_FILE ${RunCMake_BINARY_DIR}/${testName}-python.txt
ERROR_FILE ${RunCMake_BINARY_DIR}/${testName}-python.txt
RESULT_VARIABLE result
TIMEOUT 30
)
if(NOT result EQUAL 0)
message(FATAL_ERROR "Failed to start download server:\n ${result}")
endif()
foreach(i RANGE 1 8)
if(EXISTS ${URL_FILE})
break()
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${i})
endforeach()
if(NOT EXISTS ${URL_FILE})
message(FATAL_ERROR "Failed to load download server URL from:\n ${URL_FILE}")
endif()
file(READ ${URL_FILE} SERVER_URL)
message(STATUS "URL : ${URL_FILE} - ${SERVER_URL}")
run_cmake_with_options(${testName} ${CMAKE_COMMAND} -DSERVER_URL=${SERVER_URL} )
set(SERVER_ARGS ${ARGN})
set(serverScript ${CMAKE_CURRENT_LIST_DIR}/DownloadServer.py)
set(outFile ${RunCMake_BINARY_DIR}/${testName}-python.txt)
configure_file(
${CMAKE_CURRENT_LIST_DIR}/StartDownloadServer.cmake.in
${RunCMake_TEST_BINARY_DIR}/StartDownloadServer.cmake
@ONLY
)
run_cmake_command(${testName}-setup ${CMAKE_COMMAND}
-P ${RunCMake_TEST_BINARY_DIR}/StartDownloadServer.cmake
)
run_cmake_with_options(${testName} ${CMAKE_COMMAND} -DURL_FILE=${URL_FILE})
run_cmake_command(${testName}-clean ${CMAKE_COMMAND} --build . --target clean)
run_cmake_command(${testName}-build ${CMAKE_COMMAND} --build .)
#set_tests_properties(${testName}-setup FIXTURES_SETUP ${testName})
endfunction()
__ep_test_with_build(MultiCommand)
......
cmake_minimum_required(VERSION 3.18)
set(URL_FILE "@URL_FILE@")
set(SERVER_ARGS @SERVER_ARGS@)
set(Python3_EXECUTABLE "@Python3_EXECUTABLE@")
set(serverScript "@serverScript@")
set(outFile "@outFile@")
if(EXISTS "${URL_FILE}")
file(REMOVE "${URL_FILE}")
endif()
execute_process(
COMMAND ${Python3_EXECUTABLE} ${serverScript} --file "${URL_FILE}" ${SERVER_ARGS}
OUTPUT_FILE ${outFile}
ERROR_FILE ${outFile}
RESULT_VARIABLE result
TIMEOUT 30
)
if(NOT result EQUAL 0)
message(FATAL_ERROR "Failed to start download server:\n ${result}")
endif()
foreach(i RANGE 1 8)
if(EXISTS ${URL_FILE})
break()
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${i})
endforeach()
if(NOT EXISTS ${URL_FILE})
message(FATAL_ERROR "Failed to load download server URL from:\n ${URL_FILE}")
endif()
file(READ ${URL_FILE} SERVER_URL)
message(STATUS "URL : ${URL_FILE} - ${SERVER_URL}")
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