Fix build failures when cmake never used

FISH_BUILD_DIR (nominally, ./build) is created by cmake. If you only check out
the project via git and then run `cargo build`, this directory won't exist and
many of the tests will fail.
This commit is contained in:
Mahmoud Al-Qudsi 2024-05-04 19:47:16 -05:00
parent 72259f658f
commit a99a7e65e7

View file

@ -65,6 +65,9 @@ pub mod prelude {
pub fn test_init() -> impl ScopeGuarding<Target = ()> {
static DONE: OnceCell<()> = OnceCell::new();
DONE.get_or_init(|| {
// If we are building with `cargo build` and have build w/ `cmake`, FISH_BUILD_DIR might
// not yet exist.
std::fs::create_dir_all(env!("FISH_BUILD_DIR")).unwrap();
set_current_dir(env!("FISH_BUILD_DIR")).unwrap();
{
let s = CString::new("").unwrap();