diff --git a/Cargo.lock b/Cargo.lock index 17e66489..894d7601 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1088,9 +1088,9 @@ checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" [[package]] name = "snapbox" -version = "0.5.9" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ac441e1ecf678f68423d47f376d53fabce1afba92c8f68e31508eb27df8562a" +checksum = "9ad8c7be18cc9ec7f4d7948ad6b9df0e04fc649663e3c0ed59f304ed17ca69e9" dependencies = [ "anstream", "anstyle", @@ -1110,9 +1110,9 @@ dependencies = [ [[package]] name = "snapbox-macros" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1c4b838b05d15ab22754068cb73500b2f3b07bf09d310e15b27f88160f1de40" +checksum = "b1f4c14672714436c09254801c934b203196a51182a5107fb76591c7cc56424d" dependencies = [ "anstream", ] diff --git a/Cargo.toml b/Cargo.toml index 83c5dac7..ae53af4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -145,7 +145,7 @@ shlex = "1.3.0" [dev-dependencies] git-fixture = { version = "0.3.4", features = ["yaml"] } assert_fs = "1.1.1" -snapbox = { version = "0.5.9", features = ["cmd", "path"] } +snapbox = { version = "0.6.0", features = ["cmd", "dir"] } automod = "1.0.14" [profile.dev] diff --git a/tests/testsuite/alias.rs b/tests/testsuite/alias.rs index df7e8b02..3db29d15 100644 --- a/tests/testsuite/alias.rs +++ b/tests/testsuite/alias.rs @@ -1,9 +1,12 @@ // Not correctly overriding on Windows #![cfg(target_os = "linux")] +use snapbox::prelude::*; +use snapbox::str; + #[test] fn list_no_config() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let home_root = root_path.join("home"); @@ -19,7 +22,7 @@ fn list_no_config() { .assert() .success() .stdout_eq( - "\ + str![[r#" [alias] # next = stack next # unregistered # prev = stack previous # unregistered @@ -27,20 +30,21 @@ fn list_no_config() { # amend = stack amend # unregistered # sync = stack sync # unregistered # run = stack run # unregistered -", + +"#]] + .raw(), ) - .stderr_matches( - "\ + .stderr_eq(str![[r#" note: To register, pass `--register` -", - ); + +"#]]); root.close().unwrap(); } #[test] fn list_global_config() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let home_root = root_path.join("home"); @@ -64,7 +68,7 @@ fn list_global_config() { .assert() .success() .stdout_eq( - "\ + str![[r#" [alias] next = foo # instead of `stack next` # prev = stack previous # unregistered @@ -72,20 +76,21 @@ fn list_global_config() { # amend = stack amend # unregistered # sync = stack sync # unregistered # run = stack run # unregistered -", + +"#]] + .raw(), ) - .stderr_matches( - "\ + .stderr_eq(str![[r#" note: To register, pass `--register` -", - ); + +"#]]); root.close().unwrap(); } #[test] fn register_no_config() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let home_root = root_path.join("home"); @@ -101,19 +106,16 @@ fn register_no_config() { .env("HOME", &home_root) .assert() .success() - .stdout_eq( - "\ -", - ) - .stderr_matches( - r#"Registering: next="stack next" + .stdout_eq(str![].raw()) + .stderr_eq(str![[r#" +Registering: next="stack next" Registering: prev="stack previous" Registering: reword="stack reword" Registering: amend="stack amend" Registering: sync="stack sync" Registering: run="stack run" -"#, - ); + +"#]]); snapbox::cmd::Command::new(snapbox::cmd::cargo_bin!("git-stack")) .arg("alias") @@ -122,7 +124,7 @@ Registering: run="stack run" .assert() .success() .stdout_eq( - "\ + str![[r#" [alias] next = stack next # registered prev = stack previous # registered @@ -130,20 +132,21 @@ Registering: run="stack run" amend = stack amend # registered sync = stack sync # registered run = stack run # registered -", + +"#]] + .raw(), ) - .stderr_matches( - "\ + .stderr_eq(str![[r#" note: To unregister, pass `--unregister` -", - ); + +"#]]); root.close().unwrap(); } #[test] fn register_no_overwrite_alias() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let home_root = root_path.join("home"); @@ -168,18 +171,15 @@ fn register_no_overwrite_alias() { .env("HOME", &home_root) .assert() .failure() - .stdout_eq( - "\ -", - ) - .stderr_matches( - r#"error: next="foo" is registered, not overwriting with "stack next" + .stdout_eq(str![].raw()) + .stderr_eq(str![[r#" +error: next="foo" is registered, not overwriting with "stack next" Registering: reword="stack reword" Registering: amend="stack amend" Registering: sync="stack sync" Registering: run="stack run" -"#, - ); + +"#]]); snapbox::cmd::Command::new(snapbox::cmd::cargo_bin!("git-stack")) .arg("alias") @@ -188,27 +188,29 @@ Registering: run="stack run" .assert() .success() .stdout_eq( - r#"[alias] + str![[r#" +[alias] next = foo # instead of `stack next` prev = stack previous -v # diverged from "stack previous" reword = stack reword # registered amend = stack amend # registered sync = stack sync # registered run = stack run # registered -"#, + +"#]] + .raw(), ) - .stderr_matches( - "\ + .stderr_eq(str![[r#" note: To unregister, pass `--unregister` -", - ); + +"#]]); root.close().unwrap(); } #[test] fn register_unregister() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let home_root = root_path.join("home"); @@ -232,23 +234,23 @@ fn register_unregister() { .env("HOME", &home_root) .assert() .success() - .stdout_matches("") - .stderr_matches( - r#"Unregistering: next="stack next" + .stdout_eq(str![]) + .stderr_eq(str![[r#" +Unregistering: next="stack next" Unregistering: prev="stack previous" Unregistering: reword="stack reword" Unregistering: amend="stack amend" Unregistering: sync="stack sync" Unregistering: run="stack run" -"#, - ); + +"#]]); root.close().unwrap(); } #[test] fn reregister() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let home_root = root_path.join("home"); @@ -272,18 +274,15 @@ fn reregister() { .env("HOME", &home_root) .assert() .success() - .stdout_eq( - "\ -", - ) - .stderr_matches(r#""#); + .stdout_eq(str![].raw()) + .stderr_eq(str![]); root.close().unwrap(); } #[test] fn unregister_no_config() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let home_root = root_path.join("home"); @@ -299,18 +298,15 @@ fn unregister_no_config() { .env("HOME", &home_root) .assert() .success() - .stdout_eq( - "\ -", - ) - .stderr_matches(r#""#); + .stdout_eq(str![].raw()) + .stderr_eq(str![]); root.close().unwrap(); } #[test] fn unregister_existing_config() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let home_root = root_path.join("home"); @@ -336,15 +332,12 @@ fn unregister_existing_config() { .env("HOME", &home_root) .assert() .success() - .stdout_eq( - "\ -", - ) - .stderr_matches( - r#"Unregistering: prev="stack previous -v" + .stdout_eq(str![].raw()) + .stderr_eq(str![[r#" +Unregistering: prev="stack previous -v" Unregistering: reword="stack reword" -"#, - ); + +"#]]); snapbox::cmd::Command::new(snapbox::cmd::cargo_bin!("git-stack")) .arg("alias") @@ -353,7 +346,7 @@ Unregistering: reword="stack reword" .assert() .success() .stdout_eq( - "\ + str![[r#" [alias] next = foo # instead of `stack next` # prev = stack previous # unregistered @@ -361,13 +354,14 @@ Unregistering: reword="stack reword" # amend = stack amend # unregistered # sync = stack sync # unregistered # run = stack run # unregistered -", + +"#]] + .raw(), ) - .stderr_matches( - "\ + .stderr_eq(str![[r#" note: To register, pass `--register` -", - ); + +"#]]); root.close().unwrap(); } diff --git a/tests/testsuite/amend.rs b/tests/testsuite/amend.rs index 89c4d836..eaa1437a 100644 --- a/tests/testsuite/amend.rs +++ b/tests/testsuite/amend.rs @@ -1,8 +1,11 @@ use bstr::ByteSlice as _; +use snapbox::assert_data_eq; +use snapbox::prelude::*; +use snapbox::str; #[test] fn amend_noop() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let plan = git_fixture::TodoList { commands: vec![ @@ -49,27 +52,26 @@ fn amend_noop() { .current_dir(root_path) .assert() .failure() - .stdout_eq( - "\ -", - ) - .stderr_matches( - "\ + .stdout_eq(str![].raw()) + .stderr_eq(str![[r#" error: nothing to amend to [..]: C -", - ); + +"#]]); let new_head_id = repo.head_commit().id; assert_eq!(old_head_id, new_head_id); - snapbox::assert_eq(std::fs::read(root_path.join("a")).unwrap(), "unstaged a"); + assert_data_eq!( + std::fs::read(root_path.join("a")).unwrap(), + str!["unstaged a"].raw() + ); root.close().unwrap(); } #[test] fn reword_protected_fails() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let plan = git_fixture::TodoList { commands: vec![ @@ -100,27 +102,29 @@ fn reword_protected_fails() { .current_dir(root_path) .assert() .failure() - .stdout_eq( - "\ -", - ) + .stdout_eq(str![].raw()) .stderr_eq( - "\ + str![[r#" cannot amend protected commits -", + +"#]] + .raw(), ); let new_head_id = repo.head_commit().id; assert_eq!(old_head_id, new_head_id); - snapbox::assert_eq(std::fs::read(root_path.join("a")).unwrap(), "unstaged a"); + assert_data_eq!( + std::fs::read(root_path.join("a")).unwrap(), + str!["unstaged a"].raw() + ); root.close().unwrap(); } #[test] fn reword() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let plan = git_fixture::TodoList { commands: vec![ @@ -168,30 +172,29 @@ fn reword() { .current_dir(root_path) .assert() .success() - .stdout_eq( - "\ -", - ) - .stderr_matches( - "\ + .stdout_eq(str![].raw()) + .stderr_eq(str![[r#" Saved working directory and index state WIP on target (amend): [..] Amended to [..]: C Dropped refs/stash [..] note: to undo, run `git branch-stash pop git-stack` -", - ); + +"#]]); let new_head_id = repo.head_commit().id; assert_ne!(old_head_id, new_head_id); - snapbox::assert_eq(std::fs::read(root_path.join("a")).unwrap(), "unstaged a"); + assert_data_eq!( + std::fs::read(root_path.join("a")).unwrap(), + str!["unstaged a"].raw() + ); root.close().unwrap(); } #[test] fn reword_rebases() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let plan = git_fixture::TodoList { commands: vec![ @@ -241,34 +244,36 @@ fn reword_rebases() { .current_dir(root_path) .assert() .success() - .stdout_eq( - "\ -", - ) - .stderr_matches( - "\ + .stdout_eq(str![].raw()) + .stderr_eq(str![[r#" Saved working directory and index state WIP on local (amend): [..] Amended to [..]: B Dropped refs/stash [..] note: to undo, run `git branch-stash pop git-stack` -", - ); + +"#]]); let new_head_id = repo.head_commit().id; assert_ne!(old_head_id, new_head_id); let local_branch = repo.find_local_branch("local").unwrap(); let local_commit = repo.find_commit(local_branch.id).unwrap(); - snapbox::assert_eq(local_commit.summary.to_str_lossy().into_owned(), "C"); + assert_data_eq!( + local_commit.summary.to_str_lossy().into_owned(), + str!["C"].raw() + ); - snapbox::assert_eq(std::fs::read(root_path.join("a")).unwrap(), "unstaged a"); + assert_data_eq!( + std::fs::read(root_path.join("a")).unwrap(), + str!["unstaged a"].raw() + ); root.close().unwrap(); } #[test] fn amend_add() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let plan = git_fixture::TodoList { commands: vec![ @@ -316,17 +321,13 @@ fn amend_add() { .current_dir(root_path) .assert() .success() - .stdout_eq( - "\ -", - ) - .stderr_matches( - "\ + .stdout_eq(str![].raw()) + .stderr_eq(str![[r#" Adding c Amended to [..]: C note: to undo, run `git branch-stash pop git-stack` -", - ); + +"#]]); let new_head_id = repo.head_commit().id; assert_ne!(old_head_id, new_head_id); @@ -336,7 +337,7 @@ note: to undo, run `git branch-stash pop git-stack` #[test] fn amend_staged() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let plan = git_fixture::TodoList { commands: vec![ @@ -390,30 +391,29 @@ fn amend_staged() { .current_dir(root_path) .assert() .success() - .stdout_eq( - "\ -", - ) - .stderr_matches( - "\ + .stdout_eq(str![].raw()) + .stderr_eq(str![[r#" Saved working directory and index state WIP on target (amend): [..] Amended to [..]: C Dropped refs/stash [..] note: to undo, run `git branch-stash pop git-stack` -", - ); + +"#]]); let new_head_id = repo.head_commit().id; assert_ne!(old_head_id, new_head_id); - snapbox::assert_eq(std::fs::read(root_path.join("a")).unwrap(), "unstaged a"); + assert_data_eq!( + std::fs::read(root_path.join("a")).unwrap(), + str!["unstaged a"].raw() + ); root.close().unwrap(); } #[test] fn amend_detached() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let plan = git_fixture::TodoList { commands: vec![ @@ -468,34 +468,36 @@ fn amend_detached() { .current_dir(root_path) .assert() .success() - .stdout_eq( - "\ -", - ) - .stderr_matches( - "\ + .stdout_eq(str![].raw()) + .stderr_eq(str![[r#" Saved working directory and index state WIP on HEAD (amend): [..] Amended to [..]: B Dropped refs/stash [..] note: to undo, run `git branch-stash pop git-stack` -", - ); + +"#]]); let new_head_id = repo.head_commit().id; assert_ne!(old_head_id, new_head_id); let local_branch = repo.find_local_branch("local").unwrap(); let local_commit = repo.find_commit(local_branch.id).unwrap(); - snapbox::assert_eq(local_commit.summary.to_str_lossy().into_owned(), "C"); + assert_data_eq!( + local_commit.summary.to_str_lossy().into_owned(), + str!["C"].raw() + ); - snapbox::assert_eq(std::fs::read(root_path.join("a")).unwrap(), "unstaged a"); + assert_data_eq!( + std::fs::read(root_path.join("a")).unwrap(), + str!["unstaged a"].raw() + ); root.close().unwrap(); } #[test] fn amend_explicit_head() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let plan = git_fixture::TodoList { commands: vec![ @@ -550,30 +552,29 @@ fn amend_explicit_head() { .current_dir(root_path) .assert() .success() - .stdout_eq( - "\ -", - ) - .stderr_matches( - "\ + .stdout_eq(str![].raw()) + .stderr_eq(str![[r#" Saved working directory and index state WIP on target (amend): [..] Amended to [..]: C Dropped refs/stash [..] note: to undo, run `git branch-stash pop git-stack` -", - ); + +"#]]); let new_head_id = repo.head_commit().id; assert_ne!(old_head_id, new_head_id); - snapbox::assert_eq(std::fs::read(root_path.join("a")).unwrap(), "unstaged a"); + assert_data_eq!( + std::fs::read(root_path.join("a")).unwrap(), + str!["unstaged a"] + ); root.close().unwrap(); } #[test] fn amend_ancestor() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let plan = git_fixture::TodoList { commands: vec![ @@ -629,34 +630,36 @@ fn amend_ancestor() { .current_dir(root_path) .assert() .success() - .stdout_eq( - "\ -", - ) - .stderr_matches( - "\ + .stdout_eq(str![].raw()) + .stderr_eq(str![[r#" Saved working directory and index state WIP on local (amend): [..] Amended to [..]: B Dropped refs/stash [..] note: to undo, run `git branch-stash pop git-stack` -", - ); + +"#]]); let new_head_id = repo.head_commit().id; assert_ne!(old_head_id, new_head_id); let local_branch = repo.find_local_branch("local").unwrap(); let local_commit = repo.find_commit(local_branch.id).unwrap(); - snapbox::assert_eq(local_commit.summary.to_str_lossy().into_owned(), "C"); + assert_data_eq!( + local_commit.summary.to_str_lossy().into_owned(), + str!["C"].raw() + ); - snapbox::assert_eq(std::fs::read(root_path.join("a")).unwrap(), "unstaged a"); + assert_data_eq!( + std::fs::read(root_path.join("a")).unwrap(), + str!["unstaged a"].raw() + ); root.close().unwrap(); } #[test] fn amend_conflict() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let plan = git_fixture::TodoList { commands: vec![ @@ -712,31 +715,36 @@ fn amend_conflict() { .current_dir(root_path) .assert() .failure() - .stdout_eq( - "\ -", - ) - .stderr_matches( - "\ + .stdout_eq(str![].raw()) + .stderr_eq(str![[r#" Saved working directory and index state WIP on local (amend): [..] ERROR: Failed to re-stack branch `local`: squash conflicts: c ; class=Index (10); code=Unmerged (-10) Dropped refs/stash [..] note: to undo, run `git branch-stash pop git-stack` -", - ); + +"#]]); let new_head_id = repo.head_commit().id; assert_ne!(old_head_id, new_head_id); - snapbox::assert_eq(repo.head_commit().summary.to_str().unwrap(), "fixup! B"); + assert_data_eq!( + repo.head_commit().summary.to_str().unwrap(), + str!["fixup! B"].raw() + ); let local_branch = repo.find_local_branch("local").unwrap(); let local_commit = repo.find_commit(local_branch.id).unwrap(); - snapbox::assert_eq(local_commit.summary.to_str_lossy().into_owned(), "fixup! B"); - - snapbox::assert_eq(std::fs::read(root_path.join("a")).unwrap(), "unstaged a"); + assert_data_eq!( + local_commit.summary.to_str_lossy().into_owned(), + str!["fixup! B"].raw() + ); + + assert_data_eq!( + std::fs::read(root_path.join("a")).unwrap(), + str!["unstaged a"].raw() + ); root.close().unwrap(); } diff --git a/tests/testsuite/reword.rs b/tests/testsuite/reword.rs index 6d4da0dc..06cb3139 100644 --- a/tests/testsuite/reword.rs +++ b/tests/testsuite/reword.rs @@ -1,8 +1,11 @@ use bstr::ByteSlice; +use snapbox::assert_data_eq; +use snapbox::prelude::*; +use snapbox::str; #[test] fn reword_protected_fails() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let plan = git_fixture::TodoList { commands: vec![ @@ -31,14 +34,13 @@ fn reword_protected_fails() { .current_dir(root_path) .assert() .failure() - .stdout_eq( - "\ -", - ) + .stdout_eq(str![].raw()) .stderr_eq( - "\ + str![[r#" cannot reword protected commits -", + +"#]] + .raw(), ); let new_head_id = repo.head_commit().id; @@ -47,7 +49,7 @@ cannot reword protected commits #[test] fn reword_implicit_head() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let plan = git_fixture::TodoList { commands: vec![ @@ -87,7 +89,7 @@ fn reword_implicit_head() { let branch = repo.find_local_branch("target").unwrap(); let commit = repo.find_commit(branch.id).unwrap(); - snapbox::assert_eq(commit.summary.to_str().unwrap(), "C"); + assert_data_eq!(commit.summary.to_str().unwrap(), str!["C"].raw()); let old_head_id = repo.head_commit().id; @@ -97,19 +99,18 @@ fn reword_implicit_head() { .current_dir(root_path) .assert() .success() - .stdout_eq( - "\ -", - ) + .stdout_eq(str![].raw()) .stderr_eq( - "\ + str![[r#" note: to undo, run `git branch-stash pop git-stack` -", + +"#]] + .raw(), ); let branch = repo.find_local_branch("target").unwrap(); let commit = repo.find_commit(branch.id).unwrap(); - snapbox::assert_eq(commit.summary.to_str().unwrap(), "new C"); + assert_data_eq!(commit.summary.to_str().unwrap(), str!["new C"].raw()); let new_head_id = repo.head_commit().id; assert_ne!(old_head_id, new_head_id); @@ -119,7 +120,7 @@ note: to undo, run `git branch-stash pop git-stack` #[test] fn reword_explicit_head() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let plan = git_fixture::TodoList { commands: vec![ @@ -159,7 +160,7 @@ fn reword_explicit_head() { let branch = repo.find_local_branch("target").unwrap(); let commit = repo.find_commit(branch.id).unwrap(); - snapbox::assert_eq(commit.summary.to_str().unwrap(), "C"); + assert_data_eq!(commit.summary.to_str().unwrap(), str!["C"].raw()); let old_head_id = repo.head_commit().id; @@ -170,19 +171,18 @@ fn reword_explicit_head() { .current_dir(root_path) .assert() .success() - .stdout_eq( - "\ -", - ) + .stdout_eq(str![].raw()) .stderr_eq( - "\ + str![[r#" note: to undo, run `git branch-stash pop git-stack` -", + +"#]] + .raw(), ); let branch = repo.find_local_branch("target").unwrap(); let commit = repo.find_commit(branch.id).unwrap(); - snapbox::assert_eq(commit.summary.to_str().unwrap(), "new C"); + assert_data_eq!(commit.summary.to_str().unwrap(), str!["new C"].raw()); let new_head_id = repo.head_commit().id; assert_ne!(old_head_id, new_head_id); @@ -192,7 +192,7 @@ note: to undo, run `git branch-stash pop git-stack` #[test] fn reword_branch() { - let root = snapbox::path::PathFixture::mutable_temp().unwrap(); + let root = snapbox::dir::DirRoot::mutable_temp().unwrap(); let root_path = root.path().unwrap(); let plan = git_fixture::TodoList { commands: vec![ @@ -233,7 +233,7 @@ fn reword_branch() { let branch = repo.find_local_branch("target").unwrap(); let commit = repo.find_commit(branch.id).unwrap(); - snapbox::assert_eq(commit.summary.to_str().unwrap(), "B"); + assert_data_eq!(commit.summary.to_str().unwrap(), str!["B"].raw()); let old_head_id = repo.head_commit().id; @@ -246,30 +246,32 @@ fn reword_branch() { .current_dir(root_path) .assert() .success() - .stdout_eq( - "\ -", - ) - .stderr_matches( - "\ + .stdout_eq(str![].raw()) + .stderr_eq(str![[r#" Saved working directory and index state WIP on local (reword): [..] Dropped refs/stash [..] note: to undo, run `git branch-stash pop git-stack` -", - ); + +"#]]); let branch = repo.find_local_branch("target").unwrap(); let commit = repo.find_commit(branch.id).unwrap(); - snapbox::assert_eq(commit.summary.to_str().unwrap(), "new B"); + assert_data_eq!(commit.summary.to_str().unwrap(), str!["new B"].raw()); let local_branch = repo.find_local_branch("local").unwrap(); let local_commit = repo.find_commit(local_branch.id).unwrap(); - snapbox::assert_eq(local_commit.summary.to_str_lossy().into_owned(), "C"); + assert_data_eq!( + local_commit.summary.to_str_lossy().into_owned(), + str!["C"].raw() + ); let new_head_id = repo.head_commit().id; assert_ne!(old_head_id, new_head_id); - snapbox::assert_eq(std::fs::read(root_path.join("a")).unwrap(), "unstaged a"); + assert_data_eq!( + std::fs::read(root_path.join("a")).unwrap(), + str!["unstaged a"].raw() + ); root.close().unwrap(); }