Skip to content

chore: Upgrade snapbox to 0.6 #355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
148 changes: 71 additions & 77 deletions tests/testsuite/alias.rs
Original file line number Diff line number Diff line change
@@ -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");
Expand All @@ -19,28 +22,29 @@ fn list_no_config() {
.assert()
.success()
.stdout_eq(
"\
str![[r#"
[alias]
# next = stack next # unregistered
# prev = stack previous # unregistered
# reword = stack reword # unregistered
# 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");
Expand All @@ -64,28 +68,29 @@ fn list_global_config() {
.assert()
.success()
.stdout_eq(
"\
str![[r#"
[alias]
next = foo # instead of `stack next`
# prev = stack previous # unregistered
# reword = stack reword # unregistered
# 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");
Expand All @@ -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")
Expand All @@ -122,28 +124,29 @@ Registering: run="stack run"
.assert()
.success()
.stdout_eq(
"\
str![[r#"
[alias]
next = stack next # registered
prev = stack previous # registered
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_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");
Expand All @@ -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")
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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");
Expand All @@ -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")
Expand All @@ -353,21 +346,22 @@ Unregistering: reword="stack reword"
.assert()
.success()
.stdout_eq(
"\
str![[r#"
[alias]
next = foo # instead of `stack next`
# prev = stack previous # unregistered
# reword = stack reword # unregistered
# 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();
}
Loading
Loading