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.
This commit is contained in:
Johannes Altmanninger 2024-01-12 08:25:06 +01:00
parent 6c2271a6da
commit 2d493621f4
2 changed files with 8 additions and 2 deletions

View file

@ -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")

View file

@ -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")