From a1735c7aff8c5ce29e980c2c2fe2129b00dfcf39 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 19 Mar 2018 23:13:04 +0300 Subject: [PATCH] Regression tests for #5201 Better safe than sorry! --- Cargo.toml | 2 +- tests/testsuite/cargo_command.rs | 44 +++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 68d29b14893..ab89abfa6fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/tests/testsuite/cargo_command.rs b/tests/testsuite/cargo_command.rs index d0574a6d8aa..7b180ec7a09 100644 --- a/tests/testsuite/cargo_command.rs +++ b/tests/testsuite/cargo_command.rs @@ -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}; @@ -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 -Did you mean 'build'? +error: no such subcommand: `biuld` + +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