Skip to content

Commit

Permalink
chore: Update snapbox/trycmd
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Feb 14, 2024
1 parent f45a32e commit 60b07d7
Show file tree
Hide file tree
Showing 34 changed files with 428 additions and 358 deletions.
80 changes: 68 additions & 12 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 @@ -109,9 +109,9 @@ clap_derive = { path = "./clap_derive", version = "=4.5.0", optional = true }
trybuild = "1.0.89"
rustversion = "1.0.14"
# Cutting out `filesystem` feature
trycmd = { version = "0.14.20", default-features = false, features = ["color-auto", "diff", "examples"] }
trycmd = { version = "0.15.0", default-features = false, features = ["color-auto", "diff", "examples"] }
humantime = "2.1.0"
snapbox = "0.4.16"
snapbox = "0.5.0"
shlex = "1.3.0"

[[example]]
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.4.16", features = ["diff", "path", "examples"] }
snapbox = { version = "0.5.0", features = ["diff", "path", "examples"] }
# Cutting out `filesystem` feature
trycmd = { version = "0.14.20", default-features = false, features = ["color-auto", "diff", "examples"] }
completest = "0.4.0"
Expand Down
46 changes: 23 additions & 23 deletions clap_complete/tests/testsuite/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::common;
fn basic() {
let name = "my-app";
let cmd = common::basic_command(name);
common::assert_matches_path(
"tests/snapshots/basic.bash",
common::assert_matches(
snapbox::file!["../snapshots/basic.bash"],
clap_complete::shells::Bash,
cmd,
name,
Expand All @@ -16,8 +16,8 @@ fn basic() {
fn feature_sample() {
let name = "my-app";
let cmd = common::feature_sample_command(name);
common::assert_matches_path(
"tests/snapshots/feature_sample.bash",
common::assert_matches(
snapbox::file!["../snapshots/feature_sample.bash"],
clap_complete::shells::Bash,
cmd,
name,
Expand All @@ -28,8 +28,8 @@ fn feature_sample() {
fn special_commands() {
let name = "my-app";
let cmd = common::special_commands_command(name);
common::assert_matches_path(
"tests/snapshots/special_commands.bash",
common::assert_matches(
snapbox::file!["../snapshots/special_commands.bash"],
clap_complete::shells::Bash,
cmd,
name,
Expand All @@ -40,8 +40,8 @@ fn special_commands() {
fn quoting() {
let name = "my-app";
let cmd = common::quoting_command(name);
common::assert_matches_path(
"tests/snapshots/quoting.bash",
common::assert_matches(
snapbox::file!["../snapshots/quoting.bash"],
clap_complete::shells::Bash,
cmd,
name,
Expand All @@ -52,8 +52,8 @@ fn quoting() {
fn aliases() {
let name = "my-app";
let cmd = common::aliases_command(name);
common::assert_matches_path(
"tests/snapshots/aliases.bash",
common::assert_matches(
snapbox::file!["../snapshots/aliases.bash"],
clap_complete::shells::Bash,
cmd,
name,
Expand All @@ -64,8 +64,8 @@ fn aliases() {
fn sub_subcommands() {
let name = "my-app";
let cmd = common::sub_subcommands_command(name);
common::assert_matches_path(
"tests/snapshots/sub_subcommands.bash",
common::assert_matches(
snapbox::file!["../snapshots/sub_subcommands.bash"],
clap_complete::shells::Bash,
cmd,
name,
Expand All @@ -77,8 +77,8 @@ fn custom_bin_name() {
let name = "my-app";
let bin_name = "bin-name";
let cmd = common::basic_command(name);
common::assert_matches_path(
"tests/snapshots/custom_bin_name.bash",
common::assert_matches(
snapbox::file!["../snapshots/custom_bin_name.bash"],
clap_complete::shells::Bash,
cmd,
bin_name,
Expand All @@ -89,8 +89,8 @@ fn custom_bin_name() {
fn value_hint() {
let name = "my-app";
let cmd = common::value_hint_command(name);
common::assert_matches_path(
"tests/snapshots/value_hint.bash",
common::assert_matches(
snapbox::file!["../snapshots/value_hint.bash"],
clap_complete::shells::Bash,
cmd,
name,
Expand All @@ -101,8 +101,8 @@ fn value_hint() {
fn value_terminator() {
let name = "my-app";
let cmd = common::value_terminator_command(name);
common::assert_matches_path(
"tests/snapshots/value_terminator.bash",
common::assert_matches(
snapbox::file!["../snapshots/value_terminator.bash"],
clap_complete::shells::Bash,
cmd,
name,
Expand All @@ -124,15 +124,15 @@ fn register_minimal() {
.unwrap();
snapbox::Assert::new()
.action_env("SNAPSHOTS")
.matches_path("tests/snapshots/register_minimal.bash", buf);
.matches_path(snapbox::file!["../snapshots/register_minimal.bash"], buf);
}

#[test]
fn two_multi_valued_arguments() {
let name = "my-app";
let cmd = common::two_multi_valued_arguments_command(name);
common::assert_matches_path(
"tests/snapshots/two_multi_valued_arguments.bash",
common::assert_matches(
snapbox::file!["../snapshots/two_multi_valued_arguments.bash"],
clap_complete::shells::Bash,
cmd,
name,
Expand All @@ -143,8 +143,8 @@ fn two_multi_valued_arguments() {
fn subcommand_last() {
let name = "my-app";
let cmd = common::subcommand_last(name);
common::assert_matches_path(
"tests/snapshots/subcommand_last.bash",
common::assert_matches(
snapbox::file!["../snapshots/subcommand_last.bash"],
clap_complete::shells::Bash,
cmd,
name,
Expand Down
8 changes: 4 additions & 4 deletions clap_complete/tests/testsuite/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ pub fn subcommand_last(name: &'static str) -> clap::Command {
.subcommands([clap::Command::new("foo"), clap::Command::new("bar")])
}

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

snapbox::Assert::new()
.action_env("SNAPSHOTS")
.action_env(snapbox::DEFAULT_ACTION_ENV)
.normalize_paths(false)
.matches_path(expected_path, buf);
.matches(expected, buf);
}

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

0 comments on commit 60b07d7

Please sign in to comment.