Skip to content

Commit

Permalink
Regression tests for #5201
Browse files Browse the repository at this point in the history
Better safe than sorry!
  • Loading branch information
matklad committed Mar 19, 2018
1 parent bdc6fc2 commit a1735c7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ tempdir = "0.3"
termcolor = "0.3"
toml = "0.4"
url = "1.1"
clap = "2.27.0"
clap = "2.31.2"

# Not actually needed right now but required to make sure that rls/cargo build
# with the same set of features in rust-lang/rust
Expand Down
44 changes: 37 additions & 7 deletions tests/testsuite/cargo_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::str;
use cargo;
use cargotest::cargo_process;
use cargotest::support::paths::{self, CargoPathExt};
use cargotest::support::registry::Package;
use cargotest::support::{basic_bin_manifest, execs, project, Project};
use hamcrest::{assert_that, existing_file};

Expand Down Expand Up @@ -115,18 +116,47 @@ fn list_command_resolves_symlinks() {

#[test]
fn find_closest_biuld_to_build() {
let mut pr = cargo_process();
pr.arg("biuld");

assert_that(
pr,
execs().with_status(1).with_stderr_contains(
cargo_process().arg("biuld"),
execs().with_status(101).with_stderr_contains(
"\
error: The subcommand 'biuld' wasn't recognized
<tab>Did you mean 'build'?
error: no such subcommand: `biuld`
<tab>Did you mean `build`?
",
),
);

// But, if we actually have `biuld`, it must work!
// https://github.com/rust-lang/cargo/issues/5201
Package::new("cargo-biuld", "1.0.0")
.file(
"src/main.rs",
r#"
fn main() {
println!("Similar, but not identical to, build");
}
"#,
)
.publish();

assert_that(
cargo_process().arg("install").arg("cargo-biuld"),
execs().with_status(0),
);
assert_that(
cargo_process().arg("biuld"),
execs()
.with_status(0)
.with_stdout("Similar, but not identical to, build\n"),
);
assert_that(
cargo_process().arg("--list"),
execs()
.with_status(0)
.with_stdout_contains(" build\n")
.with_stdout_contains(" biuld\n"),
);
}

// if a subcommand is more than 3 edit distance away, we don't make a suggestion
Expand Down

0 comments on commit a1735c7

Please sign in to comment.