From 03bba46874a2706bbfe5459df0b3bca738bc0c93 Mon Sep 17 00:00:00 2001 From: Paul Delafosse Date: Tue, 22 Oct 2024 08:40:06 +0200 Subject: [PATCH] test: fix tests on macos --- .github/workflows/CI.yaml | 4 ++-- src/dots.rs | 12 +++++------- src/lib.rs | 4 ++++ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 075dea28..815568b9 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -18,8 +18,8 @@ jobs: strategy: matrix: include: - # - os: macos-latest - # target: x86_64-osx + - os: macos-latest + target: x86_64-osx - os: ubuntu-latest target: x86_64-unknown-linux-gnu coverage: true diff --git a/src/dots.rs b/src/dots.rs index bbde5c6b..35af3e1f 100644 --- a/src/dots.rs +++ b/src/dots.rs @@ -306,11 +306,10 @@ mod tests { fn setup(dotfiles: &str) { env::set_var("HOME", env::current_dir().unwrap()); + #[cfg(target_os = "macos")] + run_cmd!(mkdir -p "Library/Application Support";).unwrap(); println!("Fake home: {}", env::var("HOME").unwrap()); - run_cmd!( - mkdir .config; - ) - .unwrap(); + run_cmd!(mkdir .config;).unwrap(); Bombadil::link_self_config(Some(PathBuf::from(dotfiles))).unwrap(); } @@ -423,7 +422,7 @@ mod tests { vars: Dot::default_vars(), }; - run_cmd! {ls -larth}?; + run_cmd! {ls -larth;}?; dot.traverse_and_copy( &source, @@ -598,10 +597,9 @@ mod tests { Ok(()) } - #[sealed_test(files = ["tests/dotfiles_with_local_vars"], env = [("HOME", ".")])] + #[sealed_test(files = ["tests/dotfiles_with_local_vars"], env = [("HOME", ".")], before = setup("dotfiles_with_local_vars"))] fn install_with_local_vars_default_path() -> Result<()> { run_cmd!( - mkdir .config; mkdir dotfiles_with_local_vars/source_dot; echo "{{name}} is {{verb}}" > dotfiles_with_local_vars/source_dot/file; echo "name=\"Tom\"" > dotfiles_with_local_vars/source_dot/vars.toml; diff --git a/src/lib.rs b/src/lib.rs index 8be7ce16..083df172 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -689,6 +689,10 @@ mod tests { fn setup(dotfiles: &str) { let home_dir = env::current_dir().unwrap().canonicalize().unwrap(); env::set_var("HOME", home_dir); + + #[cfg(target_os = "macos")] + run_cmd!(mkdir -p "Library/Application Support";).unwrap(); + run_cmd!( mkdir .config; )