Skip to content

Commit b917796

Browse files
authored
Merge pull request clap-rs#5505 from epage/snapbox
chore: Upgrade snapbox
2 parents 4aefa3c + 75e2199 commit b917796

File tree

25 files changed

+200
-190
lines changed

25 files changed

+200
-190
lines changed

Cargo.lock

Lines changed: 14 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ clap_derive = { path = "./clap_derive", version = "=4.5.4", optional = true }
182182
trybuild = "1.0.91"
183183
rustversion = "1.0.15"
184184
# Cutting out `filesystem` feature
185-
trycmd = { version = "0.15.1", default-features = false, features = ["color-auto", "diff", "examples"] }
185+
trycmd = { version = "0.15.3", default-features = false, features = ["color-auto", "diff", "examples"] }
186186
humantime = "2.1.0"
187-
snapbox = "0.5.9"
187+
snapbox = "0.6.0"
188188
shlex = "1.3.0"
189189
automod = "1.0.14"
190190

clap_complete/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ shlex = { version = "1.1.0", optional = true }
4242
unicode-xid = { version = "0.2.2", optional = true }
4343

4444
[dev-dependencies]
45-
snapbox = { version = "0.5.9", features = ["diff", "path", "examples"] }
45+
snapbox = { version = "0.6.0", features = ["diff", "dir", "examples"] }
4646
# Cutting out `filesystem` feature
4747
trycmd = { version = "0.15.1", default-features = false, features = ["color-auto", "diff", "examples"] }
4848
completest = "0.4.0"

clap_complete/tests/testsuite/bash.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use snapbox::assert_data_eq;
2+
13
use crate::common;
24

35
#[test]
@@ -124,7 +126,7 @@ fn register_minimal() {
124126
.unwrap();
125127
snapbox::Assert::new()
126128
.action_env("SNAPSHOTS")
127-
.matches(snapbox::file!["../snapshots/register_minimal.bash"], buf);
129+
.eq(buf, snapbox::file!["../snapshots/register_minimal.bash"]);
128130
}
129131

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

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

184186
{
185187
use std::fs::File;
186188
use std::path::Path;
187189

188-
let testdir = snapbox::path::PathFixture::mutable_temp().unwrap();
190+
let testdir = snapbox::dir::DirRoot::mutable_temp().unwrap();
189191
let testdir_path = testdir.path().unwrap();
190192

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

229-
let testdir = snapbox::path::PathFixture::mutable_temp().unwrap();
231+
let testdir = snapbox::dir::DirRoot::mutable_temp().unwrap();
230232
let testdir_path = testdir.path().unwrap();
231233

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

249251
#[test]

clap_complete/tests/testsuite/common.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use clap::builder::PossibleValue;
2+
use snapbox::prelude::*;
23

34
pub(crate) fn basic_command(name: &'static str) -> clap::Command {
45
clap::Command::new(name)
@@ -284,7 +285,7 @@ pub(crate) fn subcommand_last(name: &'static str) -> clap::Command {
284285
}
285286

286287
pub(crate) fn assert_matches(
287-
expected: impl Into<snapbox::Data>,
288+
expected: impl IntoData,
288289
gen: impl clap_complete::Generator,
289290
mut cmd: clap::Command,
290291
name: &'static str,
@@ -293,15 +294,15 @@ pub(crate) fn assert_matches(
293294
clap_complete::generate(gen, &mut cmd, name, &mut buf);
294295

295296
snapbox::Assert::new()
296-
.action_env(snapbox::DEFAULT_ACTION_ENV)
297+
.action_env(snapbox::assert::DEFAULT_ACTION_ENV)
297298
.normalize_paths(false)
298-
.matches(expected, buf);
299+
.eq(buf, expected);
299300
}
300301

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

304-
let scratch = snapbox::path::PathFixture::mutable_temp().unwrap();
305+
let scratch = snapbox::dir::DirRoot::mutable_temp().unwrap();
305306
let scratch_path = scratch.path().unwrap();
306307

307308
let shell_name = R::name();
@@ -367,7 +368,7 @@ where
367368
.join(context)
368369
.join(name)
369370
.join(shell_name);
370-
let scratch = snapbox::path::PathFixture::mutable_temp()
371+
let scratch = snapbox::dir::DirRoot::mutable_temp()
371372
.unwrap()
372373
.with_template(&home)
373374
.unwrap();
@@ -398,7 +399,7 @@ where
398399

399400
#[derive(Debug)]
400401
struct ScratchRuntime {
401-
_scratch: snapbox::path::PathFixture,
402+
_scratch: snapbox::dir::DirRoot,
402403
runtime: Box<dyn completest::Runtime>,
403404
}
404405

clap_complete/tests/testsuite/dynamic.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use std::path::Path;
44

55
use clap::{builder::PossibleValue, Command};
6+
use snapbox::assert_data_eq;
67

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

25-
snapbox::assert_eq(
26+
assert_data_eq!(
27+
complete!(cmd, "he"),
2628
snapbox::str![
2729
"hello-moon
2830
hello-world
2931
help\tPrint this message or the help of the given subcommand(s)"
3032
],
31-
complete!(cmd, "he"),
3233
);
3334
}
3435

@@ -51,13 +52,13 @@ fn suggest_long_flag_subset() {
5152
.action(clap::ArgAction::Count),
5253
);
5354

54-
snapbox::assert_eq(
55+
assert_data_eq!(
56+
complete!(cmd, "--he"),
5557
snapbox::str![
5658
"--hello-world
5759
--hello-moon
5860
--help\tPrint help"
5961
],
60-
complete!(cmd, "--he"),
6162
);
6263
}
6364

@@ -70,12 +71,12 @@ fn suggest_possible_value_subset() {
7071
"goodbye-world".into(),
7172
]));
7273

73-
snapbox::assert_eq(
74+
assert_data_eq!(
75+
complete!(cmd, "hello"),
7476
snapbox::str![
7577
"hello-world\tSay hello to the world
7678
hello-moon"
7779
],
78-
complete!(cmd, "hello"),
7980
);
8081
}
8182

@@ -98,14 +99,14 @@ fn suggest_additional_short_flags() {
9899
.action(clap::ArgAction::Count),
99100
);
100101

101-
snapbox::assert_eq(
102+
assert_data_eq!(
103+
complete!(cmd, "-a"),
102104
snapbox::str![
103105
"-aa
104106
-ab
105107
-ac
106108
-ah\tPrint help"
107109
],
108-
complete!(cmd, "-a"),
109110
);
110111
}
111112

@@ -119,15 +120,15 @@ fn suggest_subcommand_positional() {
119120
]),
120121
));
121122

122-
snapbox::assert_eq(
123+
assert_data_eq!(
124+
complete!(cmd, "hello-world [TAB]"),
123125
snapbox::str![
124126
"--help\tPrint help (see more with '--help')
125127
-h\tPrint help (see more with '--help')
126128
hello-world\tSay hello to the world
127129
hello-moon
128130
goodbye-world"
129131
],
130-
complete!(cmd, "hello-world [TAB]"),
131132
);
132133
}
133134

clap_complete/tests/testsuite/elvish.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::common;
2+
use snapbox::assert_data_eq;
23

34
#[test]
45
fn basic() {
@@ -171,5 +172,5 @@ quote quote
171172
value value "#
172173
];
173174
let actual = runtime.complete(input, &term).unwrap();
174-
snapbox::assert_eq(expected, actual);
175+
assert_data_eq!(actual, expected);
175176
}

clap_complete/tests/testsuite/fish.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::common;
2+
use snapbox::assert_data_eq;
23

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

160161
let input = "exhaustive quote --choice \t";
161162
let actual = runtime.complete(input, &term).unwrap();
162163
let expected = r#"% exhaustive quote --choice
163164
bash (bash (shell)) fish (fish shell) zsh (zsh shell)"#;
164-
snapbox::assert_eq(expected, actual);
165+
assert_data_eq!(actual, expected);
165166
}
166167

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

196197
let input = "exhaustive quote \t";
197198
let expected = snapbox::str![
@@ -217,5 +218,5 @@ help (Print this message or the help of the given subcommand(s))
217218
--version (Print version)"#
218219
];
219220
let actual = runtime.complete(input, &term).unwrap();
220-
snapbox::assert_eq(expected, actual);
221+
assert_data_eq!(actual, expected);
221222
}

clap_complete/tests/testsuite/zsh.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use snapbox::assert_data_eq;
2+
13
use crate::common;
24

35
#[test]
@@ -158,5 +160,5 @@ help -- Print this message or the
158160
pacman action alias value quote hint last -- "#
159161
];
160162
let actual = runtime.complete(input, &term).unwrap();
161-
snapbox::assert_eq(expected, actual);
163+
assert_data_eq!(actual, expected);
162164
}

clap_complete_fig/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ clap = { path = "../", version = "4.0.0", default-features = false, features = [
3535
clap_complete = { path = "../clap_complete", version = "4.0.0" }
3636

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

4141
[lints]

0 commit comments

Comments
 (0)