test_cargo-test: inherit same variables as Corrosion build targets

In particular, pass the build directory, which is required in some test
scenarios (see next commit).
This commit is contained in:
Johannes Altmanninger 2024-01-12 12:00:38 +01:00
parent a20525c44f
commit 7686c39d76
2 changed files with 5 additions and 3 deletions

View file

@ -54,7 +54,7 @@ file(REAL_PATH "${CMAKE_BINARY_DIR}" fish_binary_dir)
string(JOIN "," CURSES_LIBRARY_LIST ${CURSES_LIBRARY} ${CURSES_EXTRA_LIBRARY})
# Tell Cargo where our build directory is so it can find config.h.
corrosion_set_env_vars(${fish_rust_target}
set(VARS_FOR_CARGO
"FISH_BUILD_DIR=${fish_binary_dir}"
"PREFIX=${CMAKE_INSTALL_PREFIX}"
# Temporary hack to propogate CMake flags/options to build.rs.
@ -66,3 +66,5 @@ corrosion_set_env_vars(${fish_rust_target}
"LOCALEDIR=${CMAKE_INSTALL_FULL_LOCALEDIR}"
"CURSES_LIBRARY_LIST=${CURSES_LIBRARY_LIST}"
)
corrosion_set_env_vars(${fish_rust_target} ${VARS_FOR_CARGO})

View file

@ -163,7 +163,7 @@ endif()
if(NOT DEFINED ASAN)
add_test(
NAME "cargo-test"
COMMAND 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 target ${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 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 target ${cargo_target_opt}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
add_test_target("cargo-test-widestring")