Remove hamcrest existing_dir()

This commit is contained in:
Dale Wijnand 2018-08-29 07:53:01 +02:00
parent a5de2c0ce7
commit 6fd1b54c65
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
9 changed files with 72 additions and 104 deletions

View File

@ -3,7 +3,7 @@ use std::fs::{self, File};
use std::io::prelude::*;
use cargo::util::paths::dylib_path_envvar;
use support::hamcrest::{assert_that, existing_dir, existing_file, is_not};
use support::hamcrest::{assert_that, existing_file, is_not};
use support::paths::{root, CargoPathExt};
use support::registry::Package;
use support::ProjectBuilder;
@ -4164,8 +4164,8 @@ fn uplift_dsym_of_bin_on_mac() {
.build();
p.cargo("build --bins --examples --tests").run();
assert_that(&p.bin("foo.dSYM"), existing_dir());
assert_that(&p.bin("b.dSYM"), existing_dir());
assert!(p.bin("foo.dSYM").is_dir());
assert!(p.bin("b.dSYM").is_dir());
assert!(
p.bin("b.dSYM")
.symlink_metadata()
@ -4173,8 +4173,8 @@ fn uplift_dsym_of_bin_on_mac() {
.file_type()
.is_symlink()
);
assert_that(&p.bin("c.dSYM"), is_not(existing_dir()));
assert_that(&p.bin("d.dSYM"), is_not(existing_dir()));
assert!(!p.bin("c.dSYM").is_dir());
assert!(!p.bin("d.dSYM").is_dir());
}
#[test]

View File

@ -6,7 +6,7 @@ use std::thread;
use std::time::Duration;
use cargo::util::paths::remove_dir_all;
use support::hamcrest::{assert_that, existing_dir, existing_file};
use support::hamcrest::{assert_that, existing_file};
use support::paths::CargoPathExt;
use support::registry::Package;
use support::{basic_manifest, cross_compile, project};
@ -1721,7 +1721,7 @@ fn cfg_doc() {
).file("bar/src/lib.rs", "#[cfg(bar)] pub fn bar() {}")
.build();
p.cargo("doc").run();
assert_that(&p.root().join("target/doc"), existing_dir());
assert!(p.root().join("target/doc").is_dir());
assert_that(
&p.root().join("target/doc/foo/fn.foo.html"),
existing_file(),
@ -1840,7 +1840,7 @@ fn cfg_override_doc() {
.file("bar/src/lib.rs", "#[cfg(bar)] pub fn bar() {}")
.build();
p.cargo("doc").run();
assert_that(&p.root().join("target/doc"), existing_dir());
assert!(p.root().join("target/doc").is_dir());
assert_that(
&p.root().join("target/doc/foo/fn.foo.html"),
existing_file(),

View File

@ -1,6 +1,6 @@
use std::env;
use support::hamcrest::{assert_that, existing_dir, existing_file, is_not};
use support::hamcrest::{assert_that, existing_file, is_not};
use support::registry::Package;
use support::{basic_bin_manifest, basic_manifest, git, main_file, project};
@ -12,10 +12,10 @@ fn cargo_clean_simple() {
.build();
p.cargo("build").run();
assert_that(&p.build_dir(), existing_dir());
assert!(p.build_dir().is_dir());
p.cargo("clean").run();
assert_that(&p.build_dir(), is_not(existing_dir()));
assert!(!p.build_dir().is_dir());
}
#[test]
@ -27,13 +27,13 @@ fn different_dir() {
.build();
p.cargo("build").run();
assert_that(&p.build_dir(), existing_dir());
assert!(p.build_dir().is_dir());
p.cargo("clean")
.cwd(&p.root().join("src"))
.with_stdout("")
.run();
assert_that(&p.build_dir(), is_not(existing_dir()));
assert!(!p.build_dir().is_dir());
}
#[test]
@ -143,12 +143,12 @@ fn clean_doc() {
let doc_path = &p.build_dir().join("doc");
assert_that(doc_path, existing_dir());
assert!(doc_path.is_dir());
p.cargo("clean --doc").run();
assert_that(doc_path, is_not(existing_dir()));
assert_that(p.build_dir(), existing_dir());
assert!(!doc_path.is_dir());
assert!(p.build_dir().is_dir());
}
#[test]

View File

@ -4,7 +4,7 @@ use std::str;
use support;
use glob::glob;
use support::hamcrest::{assert_that, existing_dir, existing_file, is_not};
use support::hamcrest::{assert_that, existing_file, is_not};
use support::paths::CargoPathExt;
use support::registry::Package;
use support::{basic_lib_manifest, basic_manifest, git, path2url, project};
@ -35,7 +35,7 @@ fn simple() {
",
dir = path2url(p.root())
)).run();
assert_that(&p.root().join("target/doc"), existing_dir());
assert!(p.root().join("target/doc").is_dir());
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
}
@ -106,7 +106,7 @@ fn doc_deps() {
dir = path2url(p.root())
)).run();
assert_that(&p.root().join("target/doc"), existing_dir());
assert!(p.root().join("target/doc").is_dir());
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
assert_that(&p.root().join("target/doc/bar/index.html"), existing_file());
@ -133,7 +133,7 @@ fn doc_deps() {
.with_stdout("")
.run();
assert_that(&p.root().join("target/doc"), existing_dir());
assert!(p.root().join("target/doc").is_dir());
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
assert_that(&p.root().join("target/doc/bar/index.html"), existing_file());
}
@ -167,7 +167,7 @@ fn doc_no_deps() {
dir = path2url(p.root())
)).run();
assert_that(&p.root().join("target/doc"), existing_dir());
assert!(p.root().join("target/doc").is_dir());
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
assert_that(
&p.root().join("target/doc/bar/index.html"),
@ -196,7 +196,7 @@ fn doc_only_bin() {
p.cargo("doc -v").run();
assert_that(&p.root().join("target/doc"), existing_dir());
assert!(p.root().join("target/doc").is_dir());
assert_that(&p.root().join("target/doc/bar/index.html"), existing_file());
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
}
@ -279,7 +279,7 @@ fn doc_multiple_targets_same_name() {
.with_stderr_contains(&format!("[DOCUMENTING] bar v0.1.0 ({}/bar)", root))
.with_stderr_contains("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]")
.run();
assert_that(&p.root().join("target/doc"), existing_dir());
assert!(p.root().join("target/doc").is_dir());
let doc_file = p.root().join("target/doc/foo_lib/index.html");
assert_that(&doc_file, existing_file());
}
@ -386,7 +386,7 @@ fn doc_lib_bin_same_name_documents_lib() {
",
dir = path2url(p.root())
)).run();
assert_that(&p.root().join("target/doc"), existing_dir());
assert!(p.root().join("target/doc").is_dir());
let doc_file = p.root().join("target/doc/foo/index.html");
assert_that(&doc_file, existing_file());
let mut doc_html = String::new();
@ -426,7 +426,7 @@ fn doc_lib_bin_same_name_documents_lib_when_requested() {
",
dir = path2url(p.root())
)).run();
assert_that(&p.root().join("target/doc"), existing_dir());
assert!(p.root().join("target/doc").is_dir());
let doc_file = p.root().join("target/doc/foo/index.html");
assert_that(&doc_file, existing_file());
let mut doc_html = String::new();
@ -467,7 +467,7 @@ fn doc_lib_bin_same_name_documents_named_bin_when_requested() {
",
dir = path2url(p.root())
)).run();
assert_that(&p.root().join("target/doc"), existing_dir());
assert!(p.root().join("target/doc").is_dir());
let doc_file = p.root().join("target/doc/foo/index.html");
assert_that(&doc_file, existing_file());
let mut doc_html = String::new();
@ -508,7 +508,7 @@ fn doc_lib_bin_same_name_documents_bins_when_requested() {
",
dir = path2url(p.root())
)).run();
assert_that(&p.root().join("target/doc"), existing_dir());
assert!(p.root().join("target/doc").is_dir());
let doc_file = p.root().join("target/doc/foo/index.html");
assert_that(&doc_file, existing_file());
let mut doc_html = String::new();
@ -592,10 +592,7 @@ fn doc_target() {
).build();
p.cargo("doc --verbose --target").arg(TARGET).run();
assert_that(
&p.root().join(&format!("target/{}/doc", TARGET)),
existing_dir(),
);
assert!(p.root().join(&format!("target/{}/doc", TARGET)).is_dir());
assert_that(
&p.root()
.join(&format!("target/{}/doc/foo/index.html", TARGET)),
@ -767,7 +764,7 @@ fn doc_multiple_deps() {
p.cargo("doc -p bar -p baz -v").run();
assert_that(&p.root().join("target/doc"), existing_dir());
assert!(p.root().join("target/doc").is_dir());
assert_that(&p.root().join("target/doc/bar/index.html"), existing_file());
assert_that(&p.root().join("target/doc/baz/index.html"), existing_file());
}
@ -813,7 +810,7 @@ fn features() {
r#"#[cfg(feature = "bar")] pub fn bar() {}"#,
).build();
p.cargo("doc --features foo").run();
assert_that(&p.root().join("target/doc"), existing_dir());
assert!(p.root().join("target/doc").is_dir());
assert_that(
&p.root().join("target/doc/foo/fn.foo.html"),
existing_file(),
@ -1221,7 +1218,7 @@ fn doc_private_items() {
.build();
foo.cargo("doc --document-private-items").run();
assert_that(&foo.root().join("target/doc"), existing_dir());
assert!(foo.root().join("target/doc").is_dir());
assert_that(
&foo.root().join("target/doc/foo/private/index.html"),
existing_file(),

View File

@ -3,7 +3,7 @@ use std::fs::{self, File};
use std::io::prelude::*;
use support;
use support::hamcrest::{assert_that, existing_dir, existing_file, is_not};
use support::hamcrest::{assert_that, existing_file, is_not};
use support::{paths, Execs};
fn cargo_process(s: &str) -> Execs {
@ -250,7 +250,7 @@ fn simple_git() {
assert_that(&paths::root().join("Cargo.toml"), existing_file());
assert_that(&paths::root().join("src/lib.rs"), existing_file());
assert_that(&paths::root().join(".git"), existing_dir());
assert!(paths::root().join(".git").is_dir());
assert_that(&paths::root().join(".gitignore"), existing_file());
}
@ -260,7 +260,7 @@ fn auto_git() {
assert_that(&paths::root().join("Cargo.toml"), existing_file());
assert_that(&paths::root().join("src/lib.rs"), existing_file());
assert_that(&paths::root().join(".git"), existing_dir());
assert!(paths::root().join(".git").is_dir());
assert_that(&paths::root().join(".gitignore"), existing_file());
}
@ -308,7 +308,7 @@ fn git_autodetect() {
assert_that(&paths::root().join("Cargo.toml"), existing_file());
assert_that(&paths::root().join("src/lib.rs"), existing_file());
assert_that(&paths::root().join(".git"), existing_dir());
assert!(paths::root().join(".git").is_dir());
assert_that(&paths::root().join(".gitignore"), existing_file());
}
@ -320,7 +320,7 @@ fn mercurial_autodetect() {
assert_that(&paths::root().join("Cargo.toml"), existing_file());
assert_that(&paths::root().join("src/lib.rs"), existing_file());
assert_that(&paths::root().join(".git"), is_not(existing_dir()));
assert!(!paths::root().join(".git").is_dir());
assert_that(&paths::root().join(".hgignore"), existing_file());
}
@ -337,7 +337,7 @@ fn gitignore_appended_not_replaced() {
assert_that(&paths::root().join("Cargo.toml"), existing_file());
assert_that(&paths::root().join("src/lib.rs"), existing_file());
assert_that(&paths::root().join(".git"), existing_dir());
assert!(paths::root().join(".git").is_dir());
assert_that(&paths::root().join(".gitignore"), existing_file());
let mut contents = String::new();

View File

@ -5,7 +5,7 @@ use support;
use git2;
use support::cross_compile;
use support::git;
use support::hamcrest::{assert_that, existing_dir, is_not};
use support::hamcrest::{assert_that, is_not};
use support::install::{cargo_home, has_installed_exe};
use support::paths;
use support::registry::Package;
@ -1107,16 +1107,13 @@ fn custom_target_dir_for_git_source() {
cargo_process("install --git")
.arg(p.url().to_string())
.run();
assert_that(
&paths::root().join("target/release"),
is_not(existing_dir()),
);
assert!(!paths::root().join("target/release").is_dir());
cargo_process("install --force --git")
.arg(p.url().to_string())
.env("CARGO_TARGET_DIR", "target")
.run();
assert_that(&paths::root().join("target/release"), existing_dir());
assert!(paths::root().join("target/release").is_dir());
}
#[test]

View File

@ -2,7 +2,7 @@ use std::env;
use std::fs::{self, File};
use std::io::prelude::*;
use support::hamcrest::{assert_that, existing_dir, existing_file, is_not};
use support::hamcrest::{assert_that, existing_file, is_not};
use support::paths;
use support::{cargo_process, git_process};
@ -20,7 +20,7 @@ fn simple_lib() {
.with_stderr("[CREATED] library `foo` project")
.run();
assert_that(&paths::root().join("foo"), existing_dir());
assert!(paths::root().join("foo").is_dir());
assert_that(&paths::root().join("foo/Cargo.toml"), existing_file());
assert_that(&paths::root().join("foo/src/lib.rs"), existing_file());
assert_that(
@ -56,7 +56,7 @@ fn simple_bin() {
.with_stderr("[CREATED] binary (application) `foo` project")
.run();
assert_that(&paths::root().join("foo"), existing_dir());
assert!(paths::root().join("foo").is_dir());
assert_that(&paths::root().join("foo/Cargo.toml"), existing_file());
assert_that(&paths::root().join("foo/src/main.rs"), existing_file());
@ -80,10 +80,10 @@ fn both_lib_and_bin() {
fn simple_git() {
cargo_process("new --lib foo").env("USER", "foo").run();
assert_that(&paths::root(), existing_dir());
assert!(paths::root().is_dir());
assert_that(&paths::root().join("foo/Cargo.toml"), existing_file());
assert_that(&paths::root().join("foo/src/lib.rs"), existing_file());
assert_that(&paths::root().join("foo/.git"), existing_dir());
assert!(paths::root().join("foo/.git").is_dir());
assert_that(&paths::root().join("foo/.gitignore"), existing_file());
cargo_process("build").cwd(&paths::root().join("foo")).run();
@ -364,7 +364,7 @@ fn git_prefers_command_line() {
fn subpackage_no_git() {
cargo_process("new foo").env("USER", "foo").run();
assert_that(&paths::root().join("foo/.git"), existing_dir());
assert!(paths::root().join("foo/.git").is_dir());
assert_that(&paths::root().join("foo/.gitignore"), existing_file());
let subpackage = paths::root().join("foo").join("components");
@ -387,7 +387,7 @@ fn subpackage_no_git() {
fn subpackage_git_with_gitignore() {
cargo_process("new foo").env("USER", "foo").run();
assert_that(&paths::root().join("foo/.git"), existing_dir());
assert!(paths::root().join("foo/.git").is_dir());
assert_that(&paths::root().join("foo/.gitignore"), existing_file());
let gitignore = paths::root().join("foo/.gitignore");
@ -399,10 +399,7 @@ fn subpackage_git_with_gitignore() {
.env("USER", "foo")
.run();
assert_that(
&paths::root().join("foo/components/subcomponent/.git"),
existing_dir(),
);
assert!(paths::root().join("foo/components/subcomponent/.git").is_dir());
assert_that(
&paths::root().join("foo/components/subcomponent/.gitignore"),
existing_file(),
@ -419,10 +416,7 @@ fn subpackage_git_with_vcs_arg() {
.env("USER", "foo")
.run();
assert_that(
&paths::root().join("foo/components/subcomponent/.git"),
existing_dir(),
);
assert!(paths::root().join("foo/components/subcomponent/.git").is_dir());
assert_that(
&paths::root().join("foo/components/subcomponent/.gitignore"),
existing_file(),

View File

@ -34,26 +34,6 @@ where
}
}
pub fn existing_dir() -> ExistingDir {
ExistingDir
}
#[derive(Debug)]
pub struct ExistingDir;
impl<P> Matcher<P> for ExistingDir
where
P: AsRef<Path>,
{
fn matches(&self, actual: P) -> Result<(), String> {
if actual.as_ref().is_dir() {
Ok(())
} else {
Err(format!("{} was not a dir", actual.as_ref().display()))
}
}
}
pub fn is_not<T, M: Matcher<T>>(matcher: M) -> IsNot<T, M> {
IsNot {
matcher,

View File

@ -2,7 +2,7 @@ use std::env;
use std::fs::{self, File};
use std::io::{Read, Write};
use support::hamcrest::{assert_that, existing_dir, existing_file, is_not};
use support::hamcrest::{assert_that, existing_file, is_not};
use support::registry::Package;
use support::sleep_ms;
use support::{basic_lib_manifest, basic_manifest, git, project};
@ -882,10 +882,10 @@ fn members_include_path_deps() {
p.cargo("build").cwd(p.root().join("p3")).run();
p.cargo("build").run();
assert_that(&p.root().join("target"), existing_dir());
assert_that(&p.root().join("p1/target"), is_not(existing_dir()));
assert_that(&p.root().join("p2/target"), is_not(existing_dir()));
assert_that(&p.root().join("p3/target"), is_not(existing_dir()));
assert!(p.root().join("target").is_dir());
assert!(!p.root().join("p1/target").is_dir());
assert!(!p.root().join("p2/target").is_dir());
assert!(!p.root().join("p3/target").is_dir());
}
#[test]
@ -1306,17 +1306,17 @@ fn test_in_and_out_of_workspace() {
p.cargo("build").cwd(p.root().join("ws")).run();
assert_that(&p.root().join("ws/Cargo.lock"), existing_file());
assert_that(&p.root().join("ws/target"), existing_dir());
assert!(p.root().join("ws/target").is_dir());
assert_that(&p.root().join("foo/Cargo.lock"), is_not(existing_file()));
assert_that(&p.root().join("foo/target"), is_not(existing_dir()));
assert!(!p.root().join("foo/target").is_dir());
assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file()));
assert_that(&p.root().join("bar/target"), is_not(existing_dir()));
assert!(!p.root().join("bar/target").is_dir());
p.cargo("build").cwd(p.root().join("foo")).run();
assert_that(&p.root().join("foo/Cargo.lock"), existing_file());
assert_that(&p.root().join("foo/target"), existing_dir());
assert!(p.root().join("foo/target").is_dir());
assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file()));
assert_that(&p.root().join("bar/target"), is_not(existing_dir()));
assert!(!p.root().join("bar/target").is_dir());
}
#[test]
@ -1363,7 +1363,7 @@ fn test_path_dependency_under_member() {
&p.root().join("foo/bar/Cargo.lock"),
is_not(existing_file()),
);
assert_that(&p.root().join("foo/bar/target"), is_not(existing_dir()));
assert!(!p.root().join("foo/bar/target").is_dir());
p.cargo("build").cwd(p.root().join("foo/bar")).run();
@ -1371,7 +1371,7 @@ fn test_path_dependency_under_member() {
&p.root().join("foo/bar/Cargo.lock"),
is_not(existing_file()),
);
assert_that(&p.root().join("foo/bar/target"), is_not(existing_dir()));
assert!(!p.root().join("foo/bar/target").is_dir());
}
#[test]
@ -1394,9 +1394,9 @@ fn excluded_simple() {
let p = p.build();
p.cargo("build").run();
assert_that(&p.root().join("target"), existing_dir());
assert!(p.root().join("target").is_dir());
p.cargo("build").cwd(p.root().join("foo")).run();
assert_that(&p.root().join("foo/target"), existing_dir());
assert!(p.root().join("foo/target").is_dir());
}
#[test]
@ -1422,11 +1422,11 @@ fn exclude_members_preferred() {
let p = p.build();
p.cargo("build").run();
assert_that(&p.root().join("target"), existing_dir());
assert!(p.root().join("target").is_dir());
p.cargo("build").cwd(p.root().join("foo")).run();
assert_that(&p.root().join("foo/target"), existing_dir());
assert!(p.root().join("foo/target").is_dir());
p.cargo("build").cwd(p.root().join("foo/bar")).run();
assert_that(&p.root().join("foo/bar/target"), is_not(existing_dir()));
assert!(!p.root().join("foo/bar/target").is_dir());
}
#[test]
@ -1454,11 +1454,11 @@ fn exclude_but_also_depend() {
let p = p.build();
p.cargo("build").run();
assert_that(&p.root().join("target"), existing_dir());
assert!(p.root().join("target").is_dir());
p.cargo("build").cwd(p.root().join("foo")).run();
assert_that(&p.root().join("foo/target"), existing_dir());
assert!(p.root().join("foo/target").is_dir());
p.cargo("build").cwd(p.root().join("foo/bar")).run();
assert_that(&p.root().join("foo/bar/target"), existing_dir());
assert!(p.root().join("foo/bar/target").is_dir());
}
#[test]
@ -1789,10 +1789,10 @@ fn include_and_exclude() {
p.build();
p.cargo("build").cwd(p.root().join("foo")).run();
assert_that(&p.root().join("target"), existing_dir());
assert_that(&p.root().join("foo/target"), is_not(existing_dir()));
assert!(p.root().join("target").is_dir());
assert!(!p.root().join("foo/target").is_dir());
p.cargo("build").cwd(p.root().join("foo/bar")).run();
assert_that(&p.root().join("foo/bar/target"), existing_dir());
assert!(p.root().join("foo/bar/target").is_dir());
}
*/