Skip to content

Commit 2aba2d9

Browse files
committed
Auto merge of #5207 - matklad:clap-test, r=matklad
Regression tests for #5201 Better safe than sorry!
2 parents bdc6fc2 + a1735c7 commit 2aba2d9

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ tempdir = "0.3"
5353
termcolor = "0.3"
5454
toml = "0.4"
5555
url = "1.1"
56-
clap = "2.27.0"
56+
clap = "2.31.2"
5757

5858
# Not actually needed right now but required to make sure that rls/cargo build
5959
# with the same set of features in rust-lang/rust

tests/testsuite/cargo_command.rs

+37-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::str;
77
use cargo;
88
use cargotest::cargo_process;
99
use cargotest::support::paths::{self, CargoPathExt};
10+
use cargotest::support::registry::Package;
1011
use cargotest::support::{basic_bin_manifest, execs, project, Project};
1112
use hamcrest::{assert_that, existing_file};
1213

@@ -115,18 +116,47 @@ fn list_command_resolves_symlinks() {
115116

116117
#[test]
117118
fn find_closest_biuld_to_build() {
118-
let mut pr = cargo_process();
119-
pr.arg("biuld");
120-
121119
assert_that(
122-
pr,
123-
execs().with_status(1).with_stderr_contains(
120+
cargo_process().arg("biuld"),
121+
execs().with_status(101).with_stderr_contains(
124122
"\
125-
error: The subcommand 'biuld' wasn't recognized
126-
<tab>Did you mean 'build'?
123+
error: no such subcommand: `biuld`
124+
125+
<tab>Did you mean `build`?
127126
",
128127
),
129128
);
129+
130+
// But, if we actually have `biuld`, it must work!
131+
// https://github.com/rust-lang/cargo/issues/5201
132+
Package::new("cargo-biuld", "1.0.0")
133+
.file(
134+
"src/main.rs",
135+
r#"
136+
fn main() {
137+
println!("Similar, but not identical to, build");
138+
}
139+
"#,
140+
)
141+
.publish();
142+
143+
assert_that(
144+
cargo_process().arg("install").arg("cargo-biuld"),
145+
execs().with_status(0),
146+
);
147+
assert_that(
148+
cargo_process().arg("biuld"),
149+
execs()
150+
.with_status(0)
151+
.with_stdout("Similar, but not identical to, build\n"),
152+
);
153+
assert_that(
154+
cargo_process().arg("--list"),
155+
execs()
156+
.with_status(0)
157+
.with_stdout_contains(" build\n")
158+
.with_stdout_contains(" biuld\n"),
159+
);
130160
}
131161

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

0 commit comments

Comments
 (0)