From 2d493621f442f2c27859fd40dbbf4b569591109a Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 12 Jan 2024 08:25:06 +0100 Subject: [PATCH] test_cargo-test: use Corrosion target dir This makes "ninja test" write only to the build directory, not to the source tree. This enables our docker script which mounts the source as read-only. --- cmake/Rust.cmake | 6 ++++++ cmake/Tests.cmake | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/Rust.cmake b/cmake/Rust.cmake index 3f29464aa..60439863f 100644 --- a/cmake/Rust.cmake +++ b/cmake/Rust.cmake @@ -41,6 +41,12 @@ corrosion_import_crate( FLAGS "${CARGO_FLAGS}" ) +if (Rust_CARGO_TARGET) + set(rust_target_dir "${CMAKE_BINARY_DIR}/cargo/build/${_CORROSION_RUST_CARGO_TARGET}") +else() + set(rust_target_dir "${CMAKE_BINARY_DIR}/cargo/build/${_CORROSION_RUST_CARGO_HOST_TARGET}") +endif() + # Temporary hack to propogate CMake flags/options to build.rs. We need to get CMake to evaluate the # truthiness of the strings if they are set. set(CMAKE_WITH_GETTEXT "1") diff --git a/cmake/Tests.cmake b/cmake/Tests.cmake index 885cf367d..3c0b63058 100644 --- a/cmake/Tests.cmake +++ b/cmake/Tests.cmake @@ -163,7 +163,7 @@ endif() if(NOT DEFINED ASAN) add_test( NAME "cargo-test" - COMMAND env ${VARS_FOR_CARGO} cargo test ${CARGO_FLAGS} --package fish-rust --target-dir target ${cargo_target_opt} + COMMAND env ${VARS_FOR_CARGO} cargo test ${CARGO_FLAGS} --package fish-rust --target-dir ${rust_target_dir} ${cargo_target_opt} WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) set_tests_properties("cargo-test" PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE}) @@ -172,7 +172,7 @@ endif() add_test( NAME "cargo-test-widestring" - COMMAND env ${VARS_FOR_CARGO} cargo test ${CARGO_FLAGS} --package widestring-suffix --target-dir target ${cargo_target_opt} + COMMAND env ${VARS_FOR_CARGO} cargo test ${CARGO_FLAGS} --package widestring-suffix --target-dir ${rust_target_dir} ${cargo_target_opt} WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ) add_test_target("cargo-test-widestring")