cargo test: change directory to the build directory again

Some tests create files like "./test/test-home".  Traditionally the did so
in the first parent directory that contained tests/test.fish; so either a
build directory or the root.

The new rust version always changes directory to the root.  This blows up
when running with our docker/ files, which mount the source as read-only.

Fix this by always changing directory to the build directory.

In future we could extend this to not chdir if FISH_BUILD_DIR was not
specified, to match traditional behavior. No strong opinions here.
This commit is contained in:
Johannes Altmanninger 2024-01-12 09:11:56 +01:00
parent 7686c39d76
commit 6c2271a6da

View file

@ -34,6 +34,7 @@ pub mod prelude {
use crate::{env::EnvStack, proc::proc_init};
use once_cell::sync::Lazy;
use once_cell::sync::OnceCell;
use std::env::set_current_dir;
use std::ffi::CString;
use std::sync::Mutex;
@ -60,6 +61,7 @@ pub mod prelude {
pub fn test_init() {
static DONE: OnceCell<()> = OnceCell::new();
DONE.get_or_init(|| {
set_current_dir(env!("FISH_BUILD_DIR")).unwrap();
{
let s = CString::new("").unwrap();
unsafe {