Skip to content

Commit

Permalink
Auto merge of #5929 - dwijnand:remove-hamcrest, r=alexcrichton
Browse files Browse the repository at this point in the history
Replace lots of hamcrest's assert_that with a builder style

Refs #5742

I've been thinking of possible solutions to close out #5742, so I'm submitting this for early feedback.

@alexcrichton what do you think? If you like the look of this I'll apply it across the suite.

r? @alexcrichton
  • Loading branch information
bors committed Aug 28, 2018
2 parents dd3b70d + 85984a8 commit 9ddf75a
Show file tree
Hide file tree
Showing 83 changed files with 8,605 additions and 12,771 deletions.
244 changes: 97 additions & 147 deletions tests/testsuite/alt_registry.rs

Large diffs are not rendered by default.

483 changes: 194 additions & 289 deletions tests/testsuite/bad_config.rs

Large diffs are not rendered by default.

77 changes: 35 additions & 42 deletions tests/testsuite/bad_manifest_path.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
use support::{basic_bin_manifest, execs, main_file, project};
use support::hamcrest::assert_that;
use support::{basic_bin_manifest, main_file, project};

fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) {
let p = project()
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
.build();

assert_that(
p.cargo(command)
.arg("--manifest-path")
.arg(manifest_path_argument)
.cwd(p.root().parent().unwrap()),
execs().with_status(101).with_stderr(
p.cargo(command)
.arg("--manifest-path")
.arg(manifest_path_argument)
.cwd(p.root().parent().unwrap())
.with_status(101)
.with_stderr(
"[ERROR] the manifest-path must be a path \
to a Cargo.toml file",
),
);
).run();
}

fn assert_cargo_toml_doesnt_exist(command: &str, manifest_path_argument: &str) {
Expand All @@ -26,16 +24,15 @@ fn assert_cargo_toml_doesnt_exist(command: &str, manifest_path_argument: &str) {
.collect::<Vec<_>>()
.join("[..]");

assert_that(
p.cargo(command)
.arg("--manifest-path")
.arg(manifest_path_argument)
.cwd(p.root().parent().unwrap()),
execs().with_status(101).with_stderr(format!(
p.cargo(command)
.arg("--manifest-path")
.arg(manifest_path_argument)
.cwd(p.root().parent().unwrap())
.with_status(101)
.with_stderr(format!(
"[ERROR] manifest path `{}` does not exist",
expected_path
)),
);
)).run();
}

#[test]
Expand Down Expand Up @@ -325,14 +322,13 @@ fn verify_project_dir_containing_cargo_toml() {
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
.build();

assert_that(
p.cargo("verify-project --manifest-path foo")
.cwd(p.root().parent().unwrap()),
execs().with_status(1).with_stdout(
p.cargo("verify-project --manifest-path foo")
.cwd(p.root().parent().unwrap())
.with_status(1)
.with_stdout(
"{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\
",
),
);
).run();
}

#[test]
Expand All @@ -342,14 +338,13 @@ fn verify_project_dir_plus_file() {
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
.build();

assert_that(
p.cargo("verify-project --manifest-path foo/bar")
.cwd(p.root().parent().unwrap()),
execs().with_status(1).with_stdout(
p.cargo("verify-project --manifest-path foo/bar")
.cwd(p.root().parent().unwrap())
.with_status(1)
.with_stdout(
"{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\
",
),
);
).run();
}

#[test]
Expand All @@ -359,25 +354,23 @@ fn verify_project_dir_plus_path() {
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
.build();

assert_that(
p.cargo("verify-project --manifest-path foo/bar/baz")
.cwd(p.root().parent().unwrap()),
execs().with_status(1).with_stdout(
p.cargo("verify-project --manifest-path foo/bar/baz")
.cwd(p.root().parent().unwrap())
.with_status(1)
.with_stdout(
"{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\
",
),
);
).run();
}

#[test]
fn verify_project_dir_to_nonexistent_cargo_toml() {
let p = project().build();
assert_that(
p.cargo("verify-project --manifest-path foo/bar/baz/Cargo.toml")
.cwd(p.root().parent().unwrap()),
execs().with_status(1).with_stdout(
p.cargo("verify-project --manifest-path foo/bar/baz/Cargo.toml")
.cwd(p.root().parent().unwrap())
.with_status(1)
.with_stdout(
"{\"invalid\":\"manifest path `foo[..]bar[..]baz[..]Cargo.toml` does not exist\"}\
",
),
);
).run();
}
Loading

0 comments on commit 9ddf75a

Please sign in to comment.