Skip to content

Commit

Permalink
Merge pull request #5505 from epage/snapbox
Browse files Browse the repository at this point in the history
chore: Upgrade snapbox
  • Loading branch information
epage authored May 24, 2024
2 parents 4aefa3c + 75e2199 commit b917796
Show file tree
Hide file tree
Showing 25 changed files with 200 additions and 190 deletions.
36 changes: 14 additions & 22 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ clap_derive = { path = "./clap_derive", version = "=4.5.4", optional = true }
trybuild = "1.0.91"
rustversion = "1.0.15"
# Cutting out `filesystem` feature
trycmd = { version = "0.15.1", default-features = false, features = ["color-auto", "diff", "examples"] }
trycmd = { version = "0.15.3", default-features = false, features = ["color-auto", "diff", "examples"] }
humantime = "2.1.0"
snapbox = "0.5.9"
snapbox = "0.6.0"
shlex = "1.3.0"
automod = "1.0.14"

Expand Down
2 changes: 1 addition & 1 deletion clap_complete/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ shlex = { version = "1.1.0", optional = true }
unicode-xid = { version = "0.2.2", optional = true }

[dev-dependencies]
snapbox = { version = "0.5.9", features = ["diff", "path", "examples"] }
snapbox = { version = "0.6.0", features = ["diff", "dir", "examples"] }
# Cutting out `filesystem` feature
trycmd = { version = "0.15.1", default-features = false, features = ["color-auto", "diff", "examples"] }
completest = "0.4.0"
Expand Down
14 changes: 8 additions & 6 deletions clap_complete/tests/testsuite/bash.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use snapbox::assert_data_eq;

use crate::common;

#[test]
Expand Down Expand Up @@ -124,7 +126,7 @@ fn register_minimal() {
.unwrap();
snapbox::Assert::new()
.action_env("SNAPSHOTS")
.matches(snapbox::file!["../snapshots/register_minimal.bash"], buf);
.eq(buf, snapbox::file!["../snapshots/register_minimal.bash"]);
}

#[test]
Expand Down Expand Up @@ -173,19 +175,19 @@ fn complete() {
-h --global --help action value last hint help
-V --generate --version quote pacman alias complete "#;
let actual = runtime.complete(input, &term).unwrap();
snapbox::assert_eq(expected, actual);
assert_data_eq!(actual, expected);

// Issue 5239 (https://github.com/clap-rs/clap/issues/5239)
let input = "exhaustive hint --file test\t";
let expected = "exhaustive hint --file test % exhaustive hint --file tests/";
let actual = runtime.complete(input, &term).unwrap();
snapbox::assert_eq(expected, actual);
assert_data_eq!(actual, expected);

{
use std::fs::File;
use std::path::Path;

let testdir = snapbox::path::PathFixture::mutable_temp().unwrap();
let testdir = snapbox::dir::DirRoot::mutable_temp().unwrap();
let testdir_path = testdir.path().unwrap();

File::create(Path::new(testdir_path).join("a_file")).unwrap();
Expand Down Expand Up @@ -226,7 +228,7 @@ fn complete() {
use std::fs::File;
use std::path::Path;

let testdir = snapbox::path::PathFixture::mutable_temp().unwrap();
let testdir = snapbox::dir::DirRoot::mutable_temp().unwrap();
let testdir_path = testdir.path().unwrap();

File::create(Path::new(testdir_path).join("foo bar.txt")).unwrap();
Expand All @@ -243,7 +245,7 @@ fn complete() {
let input = "exhaustive hint --other \t";
let expected = snapbox::str!["exhaustive hint --other % exhaustive hint --other "];
let actual = runtime.complete(input, &term).unwrap();
snapbox::assert_eq(expected, actual);
assert_data_eq!(actual, expected);
}

#[test]
Expand Down
13 changes: 7 additions & 6 deletions clap_complete/tests/testsuite/common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use clap::builder::PossibleValue;
use snapbox::prelude::*;

pub(crate) fn basic_command(name: &'static str) -> clap::Command {
clap::Command::new(name)
Expand Down Expand Up @@ -284,7 +285,7 @@ pub(crate) fn subcommand_last(name: &'static str) -> clap::Command {
}

pub(crate) fn assert_matches(
expected: impl Into<snapbox::Data>,
expected: impl IntoData,
gen: impl clap_complete::Generator,
mut cmd: clap::Command,
name: &'static str,
Expand All @@ -293,15 +294,15 @@ pub(crate) fn assert_matches(
clap_complete::generate(gen, &mut cmd, name, &mut buf);

snapbox::Assert::new()
.action_env(snapbox::DEFAULT_ACTION_ENV)
.action_env(snapbox::assert::DEFAULT_ACTION_ENV)
.normalize_paths(false)
.matches(expected, buf);
.eq(buf, expected);
}

pub(crate) fn register_example<R: completest::RuntimeBuilder>(context: &str, name: &str) {
use completest::Runtime as _;

let scratch = snapbox::path::PathFixture::mutable_temp().unwrap();
let scratch = snapbox::dir::DirRoot::mutable_temp().unwrap();
let scratch_path = scratch.path().unwrap();

let shell_name = R::name();
Expand Down Expand Up @@ -367,7 +368,7 @@ where
.join(context)
.join(name)
.join(shell_name);
let scratch = snapbox::path::PathFixture::mutable_temp()
let scratch = snapbox::dir::DirRoot::mutable_temp()
.unwrap()
.with_template(&home)
.unwrap();
Expand Down Expand Up @@ -398,7 +399,7 @@ where

#[derive(Debug)]
struct ScratchRuntime {
_scratch: snapbox::path::PathFixture,
_scratch: snapbox::dir::DirRoot,
runtime: Box<dyn completest::Runtime>,
}

Expand Down
21 changes: 11 additions & 10 deletions clap_complete/tests/testsuite/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::path::Path;

use clap::{builder::PossibleValue, Command};
use snapbox::assert_data_eq;

macro_rules! complete {
($cmd:expr, $input:expr$(, current_dir = $current_dir:expr)? $(,)?) => {
Expand All @@ -22,13 +23,13 @@ fn suggest_subcommand_subset() {
.subcommand(Command::new("hello-moon"))
.subcommand(Command::new("goodbye-world"));

snapbox::assert_eq(
assert_data_eq!(
complete!(cmd, "he"),
snapbox::str![
"hello-moon
hello-world
help\tPrint this message or the help of the given subcommand(s)"
],
complete!(cmd, "he"),
);
}

Expand All @@ -51,13 +52,13 @@ fn suggest_long_flag_subset() {
.action(clap::ArgAction::Count),
);

snapbox::assert_eq(
assert_data_eq!(
complete!(cmd, "--he"),
snapbox::str![
"--hello-world
--hello-moon
--help\tPrint help"
],
complete!(cmd, "--he"),
);
}

Expand All @@ -70,12 +71,12 @@ fn suggest_possible_value_subset() {
"goodbye-world".into(),
]));

snapbox::assert_eq(
assert_data_eq!(
complete!(cmd, "hello"),
snapbox::str![
"hello-world\tSay hello to the world
hello-moon"
],
complete!(cmd, "hello"),
);
}

Expand All @@ -98,14 +99,14 @@ fn suggest_additional_short_flags() {
.action(clap::ArgAction::Count),
);

snapbox::assert_eq(
assert_data_eq!(
complete!(cmd, "-a"),
snapbox::str![
"-aa
-ab
-ac
-ah\tPrint help"
],
complete!(cmd, "-a"),
);
}

Expand All @@ -119,15 +120,15 @@ fn suggest_subcommand_positional() {
]),
));

snapbox::assert_eq(
assert_data_eq!(
complete!(cmd, "hello-world [TAB]"),
snapbox::str![
"--help\tPrint help (see more with '--help')
-h\tPrint help (see more with '--help')
hello-world\tSay hello to the world
hello-moon
goodbye-world"
],
complete!(cmd, "hello-world [TAB]"),
);
}

Expand Down
3 changes: 2 additions & 1 deletion clap_complete/tests/testsuite/elvish.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::common;
use snapbox::assert_data_eq;

#[test]
fn basic() {
Expand Down Expand Up @@ -171,5 +172,5 @@ quote quote
value value "#
];
let actual = runtime.complete(input, &term).unwrap();
snapbox::assert_eq(expected, actual);
assert_data_eq!(actual, expected);
}
9 changes: 5 additions & 4 deletions clap_complete/tests/testsuite/fish.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::common;
use snapbox::assert_data_eq;

#[test]
fn basic() {
Expand Down Expand Up @@ -155,13 +156,13 @@ fn complete() {
action complete (Register shell completions for this program) hint pacman value
alias help (Print this message or the help of the given subcommand(s)) last quote "#;
let actual = runtime.complete(input, &term).unwrap();
snapbox::assert_eq(expected, actual);
assert_data_eq!(actual, expected);

let input = "exhaustive quote --choice \t";
let actual = runtime.complete(input, &term).unwrap();
let expected = r#"% exhaustive quote --choice
bash (bash (shell)) fish (fish shell) zsh (zsh shell)"#;
snapbox::assert_eq(expected, actual);
assert_data_eq!(actual, expected);
}

#[cfg(all(unix, feature = "unstable-dynamic"))]
Expand Down Expand Up @@ -191,7 +192,7 @@ help (Print this message or the help of the given subcommand(s)) value
hint -h (Print help) --version (Print version)"#
];
let actual = runtime.complete(input, &term).unwrap();
snapbox::assert_eq(expected, actual);
assert_data_eq!(actual, expected);

let input = "exhaustive quote \t";
let expected = snapbox::str![
Expand All @@ -217,5 +218,5 @@ help (Print this message or the help of the given subcommand(s))
--version (Print version)"#
];
let actual = runtime.complete(input, &term).unwrap();
snapbox::assert_eq(expected, actual);
assert_data_eq!(actual, expected);
}
4 changes: 3 additions & 1 deletion clap_complete/tests/testsuite/zsh.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use snapbox::assert_data_eq;

use crate::common;

#[test]
Expand Down Expand Up @@ -158,5 +160,5 @@ help -- Print this message or the
pacman action alias value quote hint last -- "#
];
let actual = runtime.complete(input, &term).unwrap();
snapbox::assert_eq(expected, actual);
assert_data_eq!(actual, expected);
}
2 changes: 1 addition & 1 deletion clap_complete_fig/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ clap = { path = "../", version = "4.0.0", default-features = false, features = [
clap_complete = { path = "../clap_complete", version = "4.0.0" }

[dev-dependencies]
snapbox = { version = "0.5.9", features = ["diff"] }
snapbox = { version = "0.6.0", features = ["diff"] }
clap = { path = "../", version = "4.0.0", default-features = false, features = ["std", "help"] }

[lints]
Expand Down
Loading

0 comments on commit b917796

Please sign in to comment.