Skip to content

Commit

Permalink
test: fix tests on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
oknozor committed Oct 22, 2024
1 parent 94e5b23 commit 03bba46
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions src/dots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -423,7 +422,7 @@ mod tests {
vars: Dot::default_vars(),
};

run_cmd! {ls -larth}?;
run_cmd! {ls -larth;}?;

dot.traverse_and_copy(
&source,
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
)
Expand Down

0 comments on commit 03bba46

Please sign in to comment.