Skip to content

Commit

Permalink
test: Make protobuf-generate test not destroy vcpkg's installed depen…
Browse files Browse the repository at this point in the history
…dencies
  • Loading branch information
Tradias committed Apr 26, 2022
1 parent 6cbe486 commit 4426b2b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ add_test(
COMMAND
"${CMAKE_COMMAND}" "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
"-DCMAKE_GENERATOR=${CMAKE_GENERATOR}" "-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}"
"-DPWD=${CMAKE_CURRENT_BINARY_DIR}/protobuf-generate" "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DWORKING_DIRECTORY=${CMAKE_CURRENT_BINARY_DIR}/protobuf-generate" "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DSOURCE_DIR=${CMAKE_SOURCE_DIR}" "-DTEST_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" "-DVCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}"
"-DVCPKG_OVERLAY_TRIPLETS=${VCPKG_OVERLAY_TRIPLETS}" "-DVCPKG_OVERLAY_PORTS=${VCPKG_OVERLAY_PORTS}"
Expand Down
26 changes: 13 additions & 13 deletions test/cmake/Test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
function(run_process)
execute_process(
COMMAND ${ARGN}
WORKING_DIRECTORY "${PWD}"
WORKING_DIRECTORY "${WORKING_DIRECTORY}"
TIMEOUT 200
RESULT_VARIABLE _result
OUTPUT_VARIABLE _output
Expand All @@ -26,45 +26,45 @@ function(run_process)
endif()
endfunction()

file(REMOVE_RECURSE "${PWD}/.")
file(MAKE_DIRECTORY "${PWD}")
file(REMOVE_RECURSE "${WORKING_DIRECTORY}/.")
file(MAKE_DIRECTORY "${WORKING_DIRECTORY}")

# configure asio-grpc
run_process(
"${CMAKE_COMMAND}"
"-B"
"${PWD}/build"
"${WORKING_DIRECTORY}/build"
"-G${CMAKE_GENERATOR}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DCMAKE_INSTALL_PREFIX=${PWD}/install"
"-DCMAKE_INSTALL_PREFIX=${WORKING_DIRECTORY}/install"
"-DASIO_GRPC_USE_BOOST_CONTAINER=${ASIO_GRPC_USE_BOOST_CONTAINER}"
"${SOURCE_DIR}")

# install asio-grpc
run_process(
"${CMAKE_COMMAND}"
--build
"${PWD}/build"
"${WORKING_DIRECTORY}/build"
--config
${CMAKE_BUILD_TYPE}
--target
install)

file(COPY "${TEST_SOURCE_DIR}/." DESTINATION "${PWD}")
file(COPY "${TEST_SOURCE_DIR}/." DESTINATION "${WORKING_DIRECTORY}")

# configure test project
run_process(
"${CMAKE_COMMAND}"
"-B"
"${PWD}/test-build"
"${WORKING_DIRECTORY}/test-build"
"-G${CMAKE_GENERATOR}"
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
"-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}"
"-DBoost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}"
"-DCMAKE_PREFIX_PATH=${PWD}/install"
"-DCMAKE_PREFIX_PATH=${WORKING_DIRECTORY}/install"
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
"-DVCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}"
"-DVCPKG_OVERLAY_TRIPLETS=${VCPKG_OVERLAY_TRIPLETS}"
Expand All @@ -74,11 +74,11 @@ run_process(
"-DVCPKG_INSTALL_OPTIONS=${VCPKG_INSTALL_OPTIONS}"
"-DVCPKG_INSTALLED_DIR=${VCPKG_INSTALLED_DIR}"
# Use generator-expression to prevent multi-config generators from creating a subdirectory
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${PWD}/test-install/\$<BOOL:on>"
"${PWD}")
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${WORKING_DIRECTORY}/test-install/\$<BOOL:on>"
"${WORKING_DIRECTORY}")

# build test project
run_process("${CMAKE_COMMAND}" --build "${PWD}/test-build" --config ${CMAKE_BUILD_TYPE})
run_process("${CMAKE_COMMAND}" --build "${WORKING_DIRECTORY}/test-build" --config ${CMAKE_BUILD_TYPE})

# run test project
run_process("${PWD}/test-install/1/asio-grpc-cmake-test${CMAKE_EXECUTABLE_SUFFIX}")
run_process("${WORKING_DIRECTORY}/test-install/1/asio-grpc-cmake-test${CMAKE_EXECUTABLE_SUFFIX}")
23 changes: 20 additions & 3 deletions test/cmake/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,32 @@
"name": "asio-grpc-cmake-test",
"version": "1",
"dependencies": [
"doctest",
{
"name": "grpc",
"features": [
"codegen"
]
},
"boost-coroutine",
"boost-asio",
"asio",
"boost-container"
"boost-interprocess",
"boost-thread",
"boost-container",
"boost-process",
{
"name": "asio",
"features": [
"coroutine"
]
},
"libunifex"
],
"builtin-baseline": "8ea52bad1ac13e1afb892ccba6c261d8e82d06fd"
"builtin-baseline": "8ea52bad1ac13e1afb892ccba6c261d8e82d06fd",
"overrides": [
{
"name": "doctest",
"version": "2.4.6"
}
]
}

0 comments on commit 4426b2b

Please sign in to comment.