Skip to content

Commit b48c90f

Browse files
authored
Merge pull request #5351 from epage/snap
chore: Update snapbox/trycmd
2 parents f45a32e + 5f9cecb commit b48c90f

35 files changed

+418
-377
lines changed

Cargo.lock

+20-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ clap_derive = { path = "./clap_derive", version = "=4.5.0", optional = true }
109109
trybuild = "1.0.89"
110110
rustversion = "1.0.14"
111111
# Cutting out `filesystem` feature
112-
trycmd = { version = "0.14.20", default-features = false, features = ["color-auto", "diff", "examples"] }
112+
trycmd = { version = "0.15.0", default-features = false, features = ["color-auto", "diff", "examples"] }
113113
humantime = "2.1.0"
114-
snapbox = "0.4.16"
114+
snapbox = "0.5.0"
115115
shlex = "1.3.0"
116116

117117
[[example]]

clap_complete/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ shlex = { version = "1.1.0", optional = true }
4242
unicode-xid = { version = "0.2.2", optional = true }
4343

4444
[dev-dependencies]
45-
snapbox = { version = "0.4.16", features = ["diff", "path", "examples"] }
45+
snapbox = { version = "0.5.0", features = ["diff", "path", "examples"] }
4646
# Cutting out `filesystem` feature
47-
trycmd = { version = "0.14.20", default-features = false, features = ["color-auto", "diff", "examples"] }
47+
trycmd = { version = "0.15.0", default-features = false, features = ["color-auto", "diff", "examples"] }
4848
completest = "0.4.0"
4949
completest-pty = "0.5.0"
5050
clap = { path = "../", version = "4.0.0", default-features = false, features = ["std", "derive", "help"] }

clap_complete/tests/testsuite/bash.rs

+24-24
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use crate::common;
44
fn basic() {
55
let name = "my-app";
66
let cmd = common::basic_command(name);
7-
common::assert_matches_path(
8-
"tests/snapshots/basic.bash",
7+
common::assert_matches(
8+
snapbox::file!["../snapshots/basic.bash"],
99
clap_complete::shells::Bash,
1010
cmd,
1111
name,
@@ -16,8 +16,8 @@ fn basic() {
1616
fn feature_sample() {
1717
let name = "my-app";
1818
let cmd = common::feature_sample_command(name);
19-
common::assert_matches_path(
20-
"tests/snapshots/feature_sample.bash",
19+
common::assert_matches(
20+
snapbox::file!["../snapshots/feature_sample.bash"],
2121
clap_complete::shells::Bash,
2222
cmd,
2323
name,
@@ -28,8 +28,8 @@ fn feature_sample() {
2828
fn special_commands() {
2929
let name = "my-app";
3030
let cmd = common::special_commands_command(name);
31-
common::assert_matches_path(
32-
"tests/snapshots/special_commands.bash",
31+
common::assert_matches(
32+
snapbox::file!["../snapshots/special_commands.bash"],
3333
clap_complete::shells::Bash,
3434
cmd,
3535
name,
@@ -40,8 +40,8 @@ fn special_commands() {
4040
fn quoting() {
4141
let name = "my-app";
4242
let cmd = common::quoting_command(name);
43-
common::assert_matches_path(
44-
"tests/snapshots/quoting.bash",
43+
common::assert_matches(
44+
snapbox::file!["../snapshots/quoting.bash"],
4545
clap_complete::shells::Bash,
4646
cmd,
4747
name,
@@ -52,8 +52,8 @@ fn quoting() {
5252
fn aliases() {
5353
let name = "my-app";
5454
let cmd = common::aliases_command(name);
55-
common::assert_matches_path(
56-
"tests/snapshots/aliases.bash",
55+
common::assert_matches(
56+
snapbox::file!["../snapshots/aliases.bash"],
5757
clap_complete::shells::Bash,
5858
cmd,
5959
name,
@@ -64,8 +64,8 @@ fn aliases() {
6464
fn sub_subcommands() {
6565
let name = "my-app";
6666
let cmd = common::sub_subcommands_command(name);
67-
common::assert_matches_path(
68-
"tests/snapshots/sub_subcommands.bash",
67+
common::assert_matches(
68+
snapbox::file!["../snapshots/sub_subcommands.bash"],
6969
clap_complete::shells::Bash,
7070
cmd,
7171
name,
@@ -77,8 +77,8 @@ fn custom_bin_name() {
7777
let name = "my-app";
7878
let bin_name = "bin-name";
7979
let cmd = common::basic_command(name);
80-
common::assert_matches_path(
81-
"tests/snapshots/custom_bin_name.bash",
80+
common::assert_matches(
81+
snapbox::file!["../snapshots/custom_bin_name.bash"],
8282
clap_complete::shells::Bash,
8383
cmd,
8484
bin_name,
@@ -89,8 +89,8 @@ fn custom_bin_name() {
8989
fn value_hint() {
9090
let name = "my-app";
9191
let cmd = common::value_hint_command(name);
92-
common::assert_matches_path(
93-
"tests/snapshots/value_hint.bash",
92+
common::assert_matches(
93+
snapbox::file!["../snapshots/value_hint.bash"],
9494
clap_complete::shells::Bash,
9595
cmd,
9696
name,
@@ -101,8 +101,8 @@ fn value_hint() {
101101
fn value_terminator() {
102102
let name = "my-app";
103103
let cmd = common::value_terminator_command(name);
104-
common::assert_matches_path(
105-
"tests/snapshots/value_terminator.bash",
104+
common::assert_matches(
105+
snapbox::file!["../snapshots/value_terminator.bash"],
106106
clap_complete::shells::Bash,
107107
cmd,
108108
name,
@@ -124,15 +124,15 @@ fn register_minimal() {
124124
.unwrap();
125125
snapbox::Assert::new()
126126
.action_env("SNAPSHOTS")
127-
.matches_path("tests/snapshots/register_minimal.bash", buf);
127+
.matches(snapbox::file!["../snapshots/register_minimal.bash"], buf);
128128
}
129129

130130
#[test]
131131
fn two_multi_valued_arguments() {
132132
let name = "my-app";
133133
let cmd = common::two_multi_valued_arguments_command(name);
134-
common::assert_matches_path(
135-
"tests/snapshots/two_multi_valued_arguments.bash",
134+
common::assert_matches(
135+
snapbox::file!["../snapshots/two_multi_valued_arguments.bash"],
136136
clap_complete::shells::Bash,
137137
cmd,
138138
name,
@@ -143,8 +143,8 @@ fn two_multi_valued_arguments() {
143143
fn subcommand_last() {
144144
let name = "my-app";
145145
let cmd = common::subcommand_last(name);
146-
common::assert_matches_path(
147-
"tests/snapshots/subcommand_last.bash",
146+
common::assert_matches(
147+
snapbox::file!["../snapshots/subcommand_last.bash"],
148148
clap_complete::shells::Bash,
149149
cmd,
150150
name,
@@ -241,7 +241,7 @@ fn complete() {
241241
}
242242

243243
let input = "exhaustive hint --other \t";
244-
let expected = "exhaustive hint --other % exhaustive hint --other ";
244+
let expected = snapbox::str!["exhaustive hint --other % exhaustive hint --other "];
245245
let actual = runtime.complete(input, &term).unwrap();
246246
snapbox::assert_eq(expected, actual);
247247
}

clap_complete/tests/testsuite/common.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ pub fn subcommand_last(name: &'static str) -> clap::Command {
281281
.subcommands([clap::Command::new("foo"), clap::Command::new("bar")])
282282
}
283283

284-
pub fn assert_matches_path(
285-
expected_path: impl AsRef<std::path::Path>,
284+
pub fn assert_matches(
285+
expected: impl Into<snapbox::Data>,
286286
gen: impl clap_complete::Generator,
287287
mut cmd: clap::Command,
288288
name: &'static str,
@@ -291,9 +291,9 @@ pub fn assert_matches_path(
291291
clap_complete::generate(gen, &mut cmd, name, &mut buf);
292292

293293
snapbox::Assert::new()
294-
.action_env("SNAPSHOTS")
294+
.action_env(snapbox::DEFAULT_ACTION_ENV)
295295
.normalize_paths(false)
296-
.matches_path(expected_path, buf);
296+
.matches(expected, buf);
297297
}
298298

299299
pub fn register_example<R: completest::RuntimeBuilder>(context: &str, name: &str) {

clap_complete/tests/testsuite/dynamic.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ fn suggest_subcommand_subset() {
2323
.subcommand(Command::new("goodbye-world"));
2424

2525
snapbox::assert_eq(
26-
"hello-moon
26+
snapbox::str![
27+
"hello-moon
2728
hello-world
28-
help\tPrint this message or the help of the given subcommand(s)",
29+
help\tPrint this message or the help of the given subcommand(s)"
30+
],
2931
complete!(cmd, "he"),
3032
);
3133
}
@@ -50,9 +52,11 @@ fn suggest_long_flag_subset() {
5052
);
5153

5254
snapbox::assert_eq(
53-
"--hello-world
55+
snapbox::str![
56+
"--hello-world
5457
--hello-moon
55-
--help\tPrint help",
58+
--help\tPrint help"
59+
],
5660
complete!(cmd, "--he"),
5761
);
5862
}
@@ -67,8 +71,10 @@ fn suggest_possible_value_subset() {
6771
]));
6872

6973
snapbox::assert_eq(
70-
"hello-world\tSay hello to the world
71-
hello-moon",
74+
snapbox::str![
75+
"hello-world\tSay hello to the world
76+
hello-moon"
77+
],
7278
complete!(cmd, "hello"),
7379
);
7480
}
@@ -93,10 +99,12 @@ fn suggest_additional_short_flags() {
9399
);
94100

95101
snapbox::assert_eq(
96-
"-aa
102+
snapbox::str![
103+
"-aa
97104
-ab
98105
-ac
99-
-ah\tPrint help",
106+
-ah\tPrint help"
107+
],
100108
complete!(cmd, "-a"),
101109
);
102110
}
@@ -112,11 +120,13 @@ fn suggest_subcommand_positional() {
112120
));
113121

114122
snapbox::assert_eq(
115-
"--help\tPrint help (see more with '--help')
123+
snapbox::str![
124+
"--help\tPrint help (see more with '--help')
116125
-h\tPrint help (see more with '--help')
117126
hello-world\tSay hello to the world
118127
hello-moon
119-
goodbye-world",
128+
goodbye-world"
129+
],
120130
complete!(cmd, "hello-world [TAB]"),
121131
);
122132
}

0 commit comments

Comments
 (0)