diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index e7e902425fe..01a18e0422a 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -1,4 +1,3 @@ -use support::hamcrest::{assert_that, existing_file}; use support::is_nightly; use support::paths::CargoPathExt; use support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, project}; @@ -33,7 +32,7 @@ fn cargo_bench_simple() { ).build(); p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).with_stdout("hello\n").run(); @@ -302,7 +301,7 @@ fn cargo_bench_failing_test() { ).build(); p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).with_stdout("hello\n").run(); diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 9e59239cd6c..0453946b94d 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -3,7 +3,6 @@ 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::paths::{root, CargoPathExt}; use support::registry::Package; use support::ProjectBuilder; @@ -20,7 +19,7 @@ fn cargo_compile_simple() { .build(); p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).with_stdout("i am foo\n").run(); } @@ -144,7 +143,7 @@ fn cargo_compile_manifest_path() { p.cargo("build --manifest-path foo/Cargo.toml") .cwd(p.root().parent().unwrap()) .run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); } #[test] @@ -445,7 +444,7 @@ fn cargo_compile_with_invalid_code() { To learn more, run the command again with --verbose.\n", ).run(); - assert_that(&p.root().join("Cargo.lock"), existing_file()); + assert!(p.root().join("Cargo.lock").is_file()); } #[test] @@ -527,7 +526,7 @@ fn cargo_compile_with_warnings_in_a_dep_package() { .with_stderr_contains("[..]function is never used: `dead`[..]") .run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).with_stdout("test passed\n").run(); } @@ -584,9 +583,9 @@ fn cargo_compile_with_nested_deps_inferred() { p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("libbar.rlib"), is_not(existing_file())); - assert_that(&p.bin("libbaz.rlib"), is_not(existing_file())); + assert!(p.bin("foo").is_file()); + assert!(!p.bin("libbar.rlib").is_file()); + assert!(!p.bin("libbaz.rlib").is_file()); p.process(&p.bin("foo")).with_stdout("test passed\n").run(); } @@ -643,9 +642,9 @@ fn cargo_compile_with_nested_deps_correct_bin() { p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("libbar.rlib"), is_not(existing_file())); - assert_that(&p.bin("libbaz.rlib"), is_not(existing_file())); + assert!(p.bin("foo").is_file()); + assert!(!p.bin("libbar.rlib").is_file()); + assert!(!p.bin("libbaz.rlib").is_file()); p.process(&p.bin("foo")).with_stdout("test passed\n").run(); } @@ -703,9 +702,9 @@ fn cargo_compile_with_nested_deps_shorthand() { p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("libbar.rlib"), is_not(existing_file())); - assert_that(&p.bin("libbaz.rlib"), is_not(existing_file())); + assert!(p.bin("foo").is_file()); + assert!(!p.bin("libbar.rlib").is_file()); + assert!(!p.bin("libbaz.rlib").is_file()); p.process(&p.bin("foo")).with_stdout("test passed\n").run(); } @@ -769,9 +768,9 @@ fn cargo_compile_with_nested_deps_longhand() { p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("libbar.rlib"), is_not(existing_file())); - assert_that(&p.bin("libbaz.rlib"), is_not(existing_file())); + assert!(p.bin("foo").is_file()); + assert!(!p.bin("libbar.rlib").is_file()); + assert!(!p.bin("libbaz.rlib").is_file()); p.process(&p.bin("foo")).with_stdout("test passed\n").run(); } @@ -1503,9 +1502,9 @@ fn many_crate_types_old_style_lib_location() { please rename the file to `src/lib.rs` or set lib.path in Cargo.toml", ).run(); - assert_that(&p.root().join("target/debug/libfoo.rlib"), existing_file()); + assert!(p.root().join("target/debug/libfoo.rlib").is_file()); let fname = format!("{}foo{}", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX); - assert_that(&p.root().join("target/debug").join(&fname), existing_file()); + assert!(p.root().join("target/debug").join(&fname).is_file()); } #[test] @@ -1529,9 +1528,9 @@ fn many_crate_types_correct() { .build(); p.cargo("build").run(); - assert_that(&p.root().join("target/debug/libfoo.rlib"), existing_file()); + assert!(p.root().join("target/debug/libfoo.rlib").is_file()); let fname = format!("{}foo{}", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX); - assert_that(&p.root().join("target/debug").join(&fname), existing_file()); + assert!(p.root().join("target/debug").join(&fname).is_file()); } #[test] @@ -1579,7 +1578,7 @@ fn ignore_broken_symlinks() { .build(); p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).with_stdout("i am foo\n").run(); } @@ -2356,7 +2355,7 @@ fn cargo_platform_specific_dependency() { p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.cargo("test").run(); } @@ -2409,7 +2408,7 @@ fn cargo_platform_specific_dependency_wrong_platform() { p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).run(); let loc = p.root().join("Cargo.lock"); @@ -2441,7 +2440,7 @@ fn example_as_lib() { .build(); p.cargo("build --example=ex").run(); - assert_that(&p.example_lib("ex", "lib"), existing_file()); + assert!(p.example_lib("ex", "lib").is_file()); } #[test] @@ -2464,7 +2463,7 @@ fn example_as_rlib() { .build(); p.cargo("build --example=ex").run(); - assert_that(&p.example_lib("ex", "rlib"), existing_file()); + assert!(p.example_lib("ex", "rlib").is_file()); } #[test] @@ -2487,7 +2486,7 @@ fn example_as_dylib() { .build(); p.cargo("build --example=ex").run(); - assert_that(&p.example_lib("ex", "dylib"), existing_file()); + assert!(p.example_lib("ex", "dylib").is_file()); } #[test] @@ -2514,7 +2513,7 @@ fn example_as_proc_macro() { .build(); p.cargo("build --example=ex").run(); - assert_that(&p.example_lib("ex", "proc-macro"), existing_file()); + assert!(p.example_lib("ex", "proc-macro").is_file()); } #[test] @@ -2526,15 +2525,15 @@ fn example_bin_same_name() { p.cargo("test --no-run -v").run(); - assert_that(&p.bin("foo"), is_not(existing_file())); + assert!(!p.bin("foo").is_file()); // We expect a file of the form bin/foo-{metadata_hash} - assert_that(&p.bin("examples/foo"), existing_file()); + assert!(p.bin("examples/foo").is_file()); p.cargo("test --no-run -v").run(); - assert_that(&p.bin("foo"), is_not(existing_file())); + assert!(!p.bin("foo").is_file()); // We expect a file of the form bin/foo-{metadata_hash} - assert_that(&p.bin("examples/foo"), existing_file()); + assert!(p.bin("examples/foo").is_file()); } #[test] @@ -2542,7 +2541,7 @@ fn compile_then_delete() { let p = project().file("src/main.rs", "fn main() {}").build(); p.cargo("run -v").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); if cfg!(windows) { // On windows unlinking immediately after running often fails, so sleep sleep_ms(100); @@ -2645,12 +2644,9 @@ fn predictable_filenames() { .build(); p.cargo("build -v").run(); - assert_that(&p.root().join("target/debug/libfoo.rlib"), existing_file()); + assert!(p.root().join("target/debug/libfoo.rlib").is_file()); let dylib_name = format!("{}foo{}", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX); - assert_that( - &p.root().join("target/debug").join(dylib_name), - existing_file(), - ); + assert!(p.root().join("target/debug").join(dylib_name).is_file()); } #[test] @@ -2662,7 +2658,7 @@ fn dashes_to_underscores() { .build(); p.cargo("build -v").run(); - assert_that(&p.bin("foo-bar"), existing_file()); + assert!(p.bin("foo-bar").is_file()); } #[test] @@ -2701,7 +2697,7 @@ Caused by: [..] ", ).run(); - assert_that(&p.bin("a"), is_not(existing_file())); + assert!(!p.bin("a").is_file()); } #[test] @@ -2715,13 +2711,13 @@ fn filtering() { .build(); p.cargo("build --lib").run(); - assert_that(&p.bin("a"), is_not(existing_file())); + assert!(!p.bin("a").is_file()); p.cargo("build --bin=a --example=a").run(); - assert_that(&p.bin("a"), existing_file()); - assert_that(&p.bin("b"), is_not(existing_file())); - assert_that(&p.bin("examples/a"), existing_file()); - assert_that(&p.bin("examples/b"), is_not(existing_file())); + assert!(p.bin("a").is_file()); + assert!(!p.bin("b").is_file()); + assert!(p.bin("examples/a").is_file()); + assert!(!p.bin("examples/b").is_file()); } #[test] @@ -2735,10 +2731,10 @@ fn filtering_implicit_bins() { .build(); p.cargo("build --bins").run(); - assert_that(&p.bin("a"), existing_file()); - assert_that(&p.bin("b"), existing_file()); - assert_that(&p.bin("examples/a"), is_not(existing_file())); - assert_that(&p.bin("examples/b"), is_not(existing_file())); + assert!(p.bin("a").is_file()); + assert!(p.bin("b").is_file()); + assert!(!p.bin("examples/a").is_file()); + assert!(!p.bin("examples/b").is_file()); } #[test] @@ -2752,10 +2748,10 @@ fn filtering_implicit_examples() { .build(); p.cargo("build --examples").run(); - assert_that(&p.bin("a"), is_not(existing_file())); - assert_that(&p.bin("b"), is_not(existing_file())); - assert_that(&p.bin("examples/a"), existing_file()); - assert_that(&p.bin("examples/b"), existing_file()); + assert!(!p.bin("a").is_file()); + assert!(!p.bin("b").is_file()); + assert!(p.bin("examples/a").is_file()); + assert!(p.bin("examples/b").is_file()); } #[test] @@ -2794,24 +2790,12 @@ fn custom_target_dir_env() { let exe_name = format!("foo{}", env::consts::EXE_SUFFIX); p.cargo("build").env("CARGO_TARGET_DIR", "foo/target").run(); - assert_that( - &p.root().join("foo/target/debug").join(&exe_name), - existing_file(), - ); - assert_that( - &p.root().join("target/debug").join(&exe_name), - is_not(existing_file()), - ); + assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); + assert!(!p.root().join("target/debug").join(&exe_name).is_file()); p.cargo("build").run(); - assert_that( - &p.root().join("foo/target/debug").join(&exe_name), - existing_file(), - ); - assert_that( - &p.root().join("target/debug").join(&exe_name), - existing_file(), - ); + assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); + assert!(p.root().join("target/debug").join(&exe_name).is_file()); fs::create_dir(p.root().join(".cargo")).unwrap(); File::create(p.root().join(".cargo/config")) @@ -2823,18 +2807,9 @@ fn custom_target_dir_env() { "#, ).unwrap(); p.cargo("build").env("CARGO_TARGET_DIR", "bar/target").run(); - assert_that( - &p.root().join("bar/target/debug").join(&exe_name), - existing_file(), - ); - assert_that( - &p.root().join("foo/target/debug").join(&exe_name), - existing_file(), - ); - assert_that( - &p.root().join("target/debug").join(&exe_name), - existing_file(), - ); + assert!(p.root().join("bar/target/debug").join(&exe_name).is_file()); + assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); + assert!(p.root().join("target/debug").join(&exe_name).is_file()); } #[test] @@ -2844,24 +2819,12 @@ fn custom_target_dir_line_parameter() { let exe_name = format!("foo{}", env::consts::EXE_SUFFIX); p.cargo("build --target-dir foo/target").run(); - assert_that( - &p.root().join("foo/target/debug").join(&exe_name), - existing_file(), - ); - assert_that( - &p.root().join("target/debug").join(&exe_name), - is_not(existing_file()), - ); + assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); + assert!(!p.root().join("target/debug").join(&exe_name).is_file()); p.cargo("build").run(); - assert_that( - &p.root().join("foo/target/debug").join(&exe_name), - existing_file(), - ); - assert_that( - &p.root().join("target/debug").join(&exe_name), - existing_file(), - ); + assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); + assert!(p.root().join("target/debug").join(&exe_name).is_file()); fs::create_dir(p.root().join(".cargo")).unwrap(); File::create(p.root().join(".cargo/config")) @@ -2873,38 +2836,22 @@ fn custom_target_dir_line_parameter() { "#, ).unwrap(); p.cargo("build --target-dir bar/target").run(); - assert_that( - &p.root().join("bar/target/debug").join(&exe_name), - existing_file(), - ); - assert_that( - &p.root().join("foo/target/debug").join(&exe_name), - existing_file(), - ); - assert_that( - &p.root().join("target/debug").join(&exe_name), - existing_file(), - ); + assert!(p.root().join("bar/target/debug").join(&exe_name).is_file()); + assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); + assert!(p.root().join("target/debug").join(&exe_name).is_file()); p.cargo("build --target-dir foobar/target") .env("CARGO_TARGET_DIR", "bar/target") .run(); - assert_that( - &p.root().join("foobar/target/debug").join(&exe_name), - existing_file(), - ); - assert_that( - &p.root().join("bar/target/debug").join(&exe_name), - existing_file(), - ); - assert_that( - &p.root().join("foo/target/debug").join(&exe_name), - existing_file(), - ); - assert_that( - &p.root().join("target/debug").join(&exe_name), - existing_file(), + assert!( + p.root() + .join("foobar/target/debug") + .join(&exe_name) + .is_file() ); + assert!(p.root().join("bar/target/debug").join(&exe_name).is_file()); + assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); + assert!(p.root().join("target/debug").join(&exe_name).is_file()); } #[test] @@ -2947,7 +2894,7 @@ fn build_multiple_packages() { p.cargo("build -p d1 -p d2 -p foo").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).with_stdout("i am foo\n").run(); let d1_path = &p @@ -2959,10 +2906,10 @@ fn build_multiple_packages() { .join("debug") .join(format!("d2{}", env::consts::EXE_SUFFIX)); - assert_that(d1_path, existing_file()); + assert!(d1_path.is_file()); p.process(d1_path).with_stdout("d1").run(); - assert_that(d2_path, existing_file()); + assert!(d2_path.is_file()); p.process(d2_path).with_stdout("d2").run(); } @@ -3468,14 +3415,14 @@ fn build_all_workspace_implicit_examples() { [..] Compiling foo v0.1.0 ([..])\n\ [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n", ).run(); - assert_that(&p.bin("a"), is_not(existing_file())); - assert_that(&p.bin("b"), is_not(existing_file())); - assert_that(&p.bin("examples/c"), existing_file()); - assert_that(&p.bin("examples/d"), existing_file()); - assert_that(&p.bin("e"), is_not(existing_file())); - assert_that(&p.bin("f"), is_not(existing_file())); - assert_that(&p.bin("examples/g"), existing_file()); - assert_that(&p.bin("examples/h"), existing_file()); + assert!(!p.bin("a").is_file()); + assert!(!p.bin("b").is_file()); + assert!(p.bin("examples/c").is_file()); + assert!(p.bin("examples/d").is_file()); + assert!(!p.bin("e").is_file()); + assert!(!p.bin("f").is_file()); + assert!(p.bin("examples/g").is_file()); + assert!(p.bin("examples/h").is_file()); } #[test] @@ -3586,14 +3533,14 @@ fn build_all_virtual_manifest_implicit_examples() { [..] Compiling [..] v0.1.0 ([..])\n\ [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n", ).run(); - assert_that(&p.bin("a"), is_not(existing_file())); - assert_that(&p.bin("b"), is_not(existing_file())); - assert_that(&p.bin("examples/c"), existing_file()); - assert_that(&p.bin("examples/d"), existing_file()); - assert_that(&p.bin("e"), is_not(existing_file())); - assert_that(&p.bin("f"), is_not(existing_file())); - assert_that(&p.bin("examples/g"), existing_file()); - assert_that(&p.bin("examples/h"), existing_file()); + assert!(!p.bin("a").is_file()); + assert!(!p.bin("b").is_file()); + assert!(p.bin("examples/c").is_file()); + assert!(p.bin("examples/d").is_file()); + assert!(!p.bin("e").is_file()); + assert!(!p.bin("f").is_file()); + assert!(p.bin("examples/g").is_file()); + assert!(p.bin("examples/h").is_file()); } #[test] @@ -3773,10 +3720,7 @@ fn cdylib_not_lifted() { for file in files { println!("checking: {}", file); - assert_that( - &p.root().join("target/debug/deps").join(&file), - existing_file(), - ); + assert!(p.root().join("target/debug/deps").join(&file).is_file()); } } @@ -3809,7 +3753,7 @@ fn cdylib_final_outputs() { for file in files { println!("checking: {}", file); - assert_that(&p.root().join("target/debug").join(&file), existing_file()); + assert!(p.root().join("target/debug").join(&file).is_file()); } } @@ -3915,9 +3859,9 @@ fn inferred_bins() { .build(); p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("bar"), existing_file()); - assert_that(&p.bin("baz"), existing_file()); + assert!(p.bin("foo").is_file()); + assert!(p.bin("bar").is_file()); + assert!(p.bin("baz").is_file()); } #[test] @@ -3954,7 +3898,7 @@ fn inferred_bin_path() { .build(); p.cargo("build").run(); - assert_that(&p.bin("bar"), existing_file()); + assert!(p.bin("bar").is_file()); } #[test] @@ -3966,8 +3910,8 @@ fn inferred_examples() { .build(); p.cargo("test").run(); - assert_that(&p.bin("examples/bar"), existing_file()); - assert_that(&p.bin("examples/baz"), existing_file()); + assert!(p.bin("examples/bar").is_file()); + assert!(p.bin("examples/baz").is_file()); } #[test] @@ -4164,8 +4108,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 +4117,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] @@ -4190,10 +4134,10 @@ fn uplift_pdb_of_bin_on_windows() { .build(); p.cargo("build --bins --examples --tests").run(); - assert_that(&p.target_debug_dir().join("foo.pdb"), existing_file()); - assert_that(&p.target_debug_dir().join("b.pdb"), existing_file()); - assert_that(&p.target_debug_dir().join("c.pdb"), is_not(existing_file())); - assert_that(&p.target_debug_dir().join("d.pdb"), is_not(existing_file())); + assert!(p.target_debug_dir().join("foo.pdb").is_file()); + assert!(p.target_debug_dir().join("b.pdb").is_file()); + assert!(!p.target_debug_dir().join("c.pdb").is_file()); + assert!(!p.target_debug_dir().join("d.pdb").is_file()); } // Make sure that `cargo build` chooses the correct profile for building diff --git a/tests/testsuite/build_plan.rs b/tests/testsuite/build_plan.rs index 951f58239ab..40a13c4d25b 100644 --- a/tests/testsuite/build_plan.rs +++ b/tests/testsuite/build_plan.rs @@ -1,4 +1,3 @@ -use support::hamcrest::{assert_that, existing_file, is_not}; use support::{basic_bin_manifest, basic_manifest, main_file, project}; #[test] @@ -34,7 +33,7 @@ fn cargo_build_plan_simple() { } "#, ).run(); - assert_that(&p.bin("foo"), is_not(existing_file())); + assert!(!p.bin("foo").is_file()); } #[test] diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index 9dd132dfd19..d6c76307dd8 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -6,7 +6,6 @@ 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::paths::CargoPathExt; use support::registry::Package; use support::{basic_manifest, cross_compile, project}; @@ -1721,15 +1720,9 @@ 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_that( - &p.root().join("target/doc/foo/fn.foo.html"), - existing_file(), - ); - assert_that( - &p.root().join("target/doc/bar/fn.bar.html"), - existing_file(), - ); + assert!(p.root().join("target/doc").is_dir()); + assert!(p.root().join("target/doc/foo/fn.foo.html").is_file()); + assert!(p.root().join("target/doc/bar/fn.bar.html").is_file()); } #[test] @@ -1840,15 +1833,9 @@ 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_that( - &p.root().join("target/doc/foo/fn.foo.html"), - existing_file(), - ); - assert_that( - &p.root().join("target/doc/bar/fn.bar.html"), - existing_file(), - ); + assert!(p.root().join("target/doc").is_dir()); + assert!(p.root().join("target/doc/foo/fn.foo.html").is_file()); + assert!(p.root().join("target/doc/bar/fn.bar.html").is_file()); } #[test] diff --git a/tests/testsuite/cargo_command.rs b/tests/testsuite/cargo_command.rs index ee35dbbb886..4f8a023510b 100644 --- a/tests/testsuite/cargo_command.rs +++ b/tests/testsuite/cargo_command.rs @@ -6,7 +6,6 @@ use std::str; use cargo; use support::cargo_process; -use support::hamcrest::{assert_that, existing_file}; use support::paths::{self, CargoPathExt}; use support::registry::Package; use support::{basic_bin_manifest, basic_manifest, cargo_exe, project, Project}; @@ -227,7 +226,7 @@ fn cargo_subcommand_env() { let target_dir = p.target_debug_dir(); p.cargo("build").run(); - assert_that(&p.bin("cargo-envtest"), existing_file()); + assert!(p.bin("cargo-envtest").is_file()); let cargo = cargo_exe().canonicalize().unwrap(); let mut path = path(); @@ -257,7 +256,7 @@ fn cargo_subcommand_args() { p.cargo("build").run(); let cargo_foo_bin = p.bin("cargo-foo"); - assert_that(&cargo_foo_bin, existing_file()); + assert!(cargo_foo_bin.is_file()); let mut path = path(); path.push(p.target_debug_dir()); diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index bb9fd5edb64..0468f6a830c 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -1,5 +1,4 @@ use glob::glob; -use support::hamcrest::{assert_that, existing_file, is_not}; use support::install::exe; use support::is_nightly; use support::paths::CargoPathExt; @@ -573,27 +572,15 @@ fn check_artifacts() { .file("benches/b1.rs", "") .build(); p.cargo("check").run(); - assert_that(&p.root().join("target/debug/libfoo.rmeta"), existing_file()); - assert_that( - &p.root().join("target/debug/libfoo.rlib"), - is_not(existing_file()), - ); - assert_that( - &p.root().join("target/debug").join(exe("foo")), - is_not(existing_file()), - ); + assert!(p.root().join("target/debug/libfoo.rmeta").is_file()); + assert!(!p.root().join("target/debug/libfoo.rlib").is_file()); + assert!(!p.root().join("target/debug").join(exe("foo")).is_file()); p.root().join("target").rm_rf(); p.cargo("check --lib").run(); - assert_that(&p.root().join("target/debug/libfoo.rmeta"), existing_file()); - assert_that( - &p.root().join("target/debug/libfoo.rlib"), - is_not(existing_file()), - ); - assert_that( - &p.root().join("target/debug").join(exe("foo")), - is_not(existing_file()), - ); + assert!(p.root().join("target/debug/libfoo.rmeta").is_file()); + assert!(!p.root().join("target/debug/libfoo.rlib").is_file()); + assert!(!p.root().join("target/debug").join(exe("foo")).is_file()); p.root().join("target").rm_rf(); p.cargo("check --bin foo").run(); @@ -601,31 +588,16 @@ fn check_artifacts() { // The nightly check can be removed once 1.27 is stable. // Bins now generate `rmeta` files. // See: https://github.com/rust-lang/rust/pull/49289 - assert_that(&p.root().join("target/debug/libfoo.rmeta"), existing_file()); + assert!(p.root().join("target/debug/libfoo.rmeta").is_file()); } - assert_that( - &p.root().join("target/debug/libfoo.rlib"), - is_not(existing_file()), - ); - assert_that( - &p.root().join("target/debug").join(exe("foo")), - is_not(existing_file()), - ); + assert!(!p.root().join("target/debug/libfoo.rlib").is_file()); + assert!(!p.root().join("target/debug").join(exe("foo")).is_file()); p.root().join("target").rm_rf(); p.cargo("check --test t1").run(); - assert_that( - &p.root().join("target/debug/libfoo.rmeta"), - is_not(existing_file()), - ); - assert_that( - &p.root().join("target/debug/libfoo.rlib"), - is_not(existing_file()), - ); - assert_that( - &p.root().join("target/debug").join(exe("foo")), - is_not(existing_file()), - ); + assert!(!p.root().join("target/debug/libfoo.rmeta").is_file()); + assert!(!p.root().join("target/debug/libfoo.rlib").is_file()); + assert!(!p.root().join("target/debug").join(exe("foo")).is_file()); assert_eq!( glob(&p.root().join("target/debug/t1-*").to_str().unwrap()) .unwrap() @@ -635,33 +607,20 @@ fn check_artifacts() { p.root().join("target").rm_rf(); p.cargo("check --example ex1").run(); - assert_that( - &p.root().join("target/debug/libfoo.rmeta"), - is_not(existing_file()), - ); - assert_that( - &p.root().join("target/debug/libfoo.rlib"), - is_not(existing_file()), - ); - assert_that( - &p.root().join("target/debug/examples").join(exe("ex1")), - is_not(existing_file()), + assert!(!p.root().join("target/debug/libfoo.rmeta").is_file()); + assert!(!p.root().join("target/debug/libfoo.rlib").is_file()); + assert!( + !p.root() + .join("target/debug/examples") + .join(exe("ex1")) + .is_file() ); p.root().join("target").rm_rf(); p.cargo("check --bench b1").run(); - assert_that( - &p.root().join("target/debug/libfoo.rmeta"), - is_not(existing_file()), - ); - assert_that( - &p.root().join("target/debug/libfoo.rlib"), - is_not(existing_file()), - ); - assert_that( - &p.root().join("target/debug").join(exe("foo")), - is_not(existing_file()), - ); + assert!(!p.root().join("target/debug/libfoo.rmeta").is_file()); + assert!(!p.root().join("target/debug/libfoo.rlib").is_file()); + assert!(!p.root().join("target/debug").join(exe("foo")).is_file()); assert_eq!( glob(&p.root().join("target/debug/b1-*").to_str().unwrap()) .unwrap() diff --git a/tests/testsuite/clean.rs b/tests/testsuite/clean.rs index 88bc88fe489..ea62d062b8a 100644 --- a/tests/testsuite/clean.rs +++ b/tests/testsuite/clean.rs @@ -1,6 +1,5 @@ use std::env; -use support::hamcrest::{assert_that, existing_dir, existing_file, is_not}; use support::registry::Package; use support::{basic_bin_manifest, basic_manifest, git, main_file, project}; @@ -12,10 +11,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 +26,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] @@ -73,17 +72,17 @@ fn clean_multiple_packages() { .join("debug") .join(format!("d2{}", env::consts::EXE_SUFFIX)); - assert_that(&p.bin("foo"), existing_file()); - assert_that(d1_path, existing_file()); - assert_that(d2_path, existing_file()); + assert!(p.bin("foo").is_file()); + assert!(d1_path.is_file()); + assert!(d2_path.is_file()); p.cargo("clean -p d1 -p d2") .cwd(&p.root().join("src")) .with_stdout("") .run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(d1_path, is_not(existing_file())); - assert_that(d2_path, is_not(existing_file())); + assert!(p.bin("foo").is_file()); + assert!(!d1_path.is_file()); + assert!(!d2_path.is_file()); } #[test] @@ -143,12 +142,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] diff --git a/tests/testsuite/concurrent.rs b/tests/testsuite/concurrent.rs index abdf5d23b6f..a999467f9d6 100644 --- a/tests/testsuite/concurrent.rs +++ b/tests/testsuite/concurrent.rs @@ -10,8 +10,7 @@ use std::{env, str}; use git2; use support::cargo_process; use support::git; -use support::hamcrest::{assert_that, existing_file}; -use support::install::{cargo_home, has_installed_exe}; +use support::install::{cargo_home, assert_has_installed_exe}; use support::registry::Package; use support::{basic_manifest, execs, project}; @@ -46,8 +45,8 @@ fn multiple_installs() { execs().run_output(&a); execs().run_output(&b); - assert_that(cargo_home(), has_installed_exe("foo")); - assert_that(cargo_home(), has_installed_exe("bar")); + assert_has_installed_exe(cargo_home(), "foo"); + assert_has_installed_exe(cargo_home(), "bar"); } #[test] @@ -75,8 +74,8 @@ fn concurrent_installs() { execs().run_output(&a); execs().run_output(&b); - assert_that(cargo_home(), has_installed_exe("foo")); - assert_that(cargo_home(), has_installed_exe("bar")); + assert_has_installed_exe(cargo_home(), "foo"); + assert_has_installed_exe(cargo_home(), "bar"); } #[test] @@ -115,7 +114,7 @@ fn one_install_should_be_bad() { .with_stderr_contains("warning: be sure to add `[..]` to your PATH [..]") .run_output(&good); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); } #[test] @@ -172,17 +171,17 @@ fn multiple_registry_fetches() { execs().run_output(&b); let suffix = env::consts::EXE_SUFFIX; - assert_that( - &p.root() + assert!( + p.root() .join("a/target/debug") - .join(format!("foo{}", suffix)), - existing_file(), + .join(format!("foo{}", suffix)) + .is_file() ); - assert_that( - &p.root() + assert!( + p.root() .join("b/target/debug") - .join(format!("bar{}", suffix)), - existing_file(), + .join(format!("bar{}", suffix)) + .is_file() ); } diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs index 350b3c725d7..08769df5948 100644 --- a/tests/testsuite/cross_compile.rs +++ b/tests/testsuite/cross_compile.rs @@ -1,4 +1,3 @@ -use support::hamcrest::{assert_that, existing_file}; use support::{basic_bin_manifest, basic_manifest, cross_compile, project}; use support::{is_nightly, rustc_host}; @@ -43,7 +42,7 @@ fn simple_cross() { let target = cross_compile::alternate(); p.cargo("build -v --target").arg(&target).run(); - assert_that(&p.target_bin(&target, "foo"), existing_file()); + assert!(p.target_bin(&target, "foo").is_file()); p.process(&p.target_bin(&target, "foo")).run(); } @@ -98,7 +97,7 @@ fn simple_cross_config() { let target = cross_compile::alternate(); p.cargo("build -v").run(); - assert_that(&p.target_bin(&target, "foo"), existing_file()); + assert!(p.target_bin(&target, "foo").is_file()); p.process(&p.target_bin(&target, "foo")).run(); } @@ -131,7 +130,7 @@ fn simple_deps() { let target = cross_compile::alternate(); p.cargo("build --target").arg(&target).run(); - assert_that(&p.target_bin(&target, "foo"), existing_file()); + assert!(p.target_bin(&target, "foo").is_file()); p.process(&p.target_bin(&target, "foo")).run(); } @@ -219,7 +218,7 @@ fn plugin_deps() { let target = cross_compile::alternate(); foo.cargo("build --target").arg(&target).run(); - assert_that(&foo.target_bin(&target, "foo"), existing_file()); + assert!(foo.target_bin(&target, "foo").is_file()); foo.process(&foo.target_bin(&target, "foo")).run(); } @@ -316,7 +315,7 @@ fn plugin_to_the_max() { foo.cargo("build -v --target").arg(&target).run(); println!("second"); foo.cargo("build -v --target").arg(&target).run(); - assert_that(&foo.target_bin(&target, "foo"), existing_file()); + assert!(foo.target_bin(&target, "foo").is_file()); foo.process(&foo.target_bin(&target, "foo")).run(); } diff --git a/tests/testsuite/cross_publish.rs b/tests/testsuite/cross_publish.rs index a4b58904274..6a37489895b 100644 --- a/tests/testsuite/cross_publish.rs +++ b/tests/testsuite/cross_publish.rs @@ -3,7 +3,6 @@ use std::io::prelude::*; use std::path::PathBuf; use flate2::read::GzDecoder; -use support::hamcrest::{assert_that, contains}; use support::{cross_compile, project, publish}; use tar::Archive; @@ -61,18 +60,9 @@ fn simple_cross_package() { let entry_paths = entries .map(|entry| entry.unwrap().path().unwrap().into_owned()) .collect::>(); - assert_that( - &entry_paths, - contains(vec![PathBuf::from("foo-0.0.0/Cargo.toml")]), - ); - assert_that( - &entry_paths, - contains(vec![PathBuf::from("foo-0.0.0/Cargo.toml.orig")]), - ); - assert_that( - &entry_paths, - contains(vec![PathBuf::from("foo-0.0.0/src/main.rs")]), - ); + assert!(entry_paths.contains(&PathBuf::from("foo-0.0.0/Cargo.toml"))); + assert!(entry_paths.contains(&PathBuf::from("foo-0.0.0/Cargo.toml.orig"))); + assert!(entry_paths.contains(&PathBuf::from("foo-0.0.0/src/main.rs"))); } #[test] diff --git a/tests/testsuite/dep_info.rs b/tests/testsuite/dep_info.rs index 5e2fc2df335..4fdb2209616 100644 --- a/tests/testsuite/dep_info.rs +++ b/tests/testsuite/dep_info.rs @@ -1,5 +1,4 @@ use filetime::FileTime; -use support::hamcrest::{assert_that, existing_file}; use support::{basic_bin_manifest, main_file, project}; #[test] @@ -13,7 +12,7 @@ fn build_dep_info() { let depinfo_bin_path = &p.bin("foo").with_extension("d"); - assert_that(depinfo_bin_path, existing_file()); + assert!(depinfo_bin_path.is_file()); } #[test] @@ -37,10 +36,7 @@ fn build_dep_info_lib() { .build(); p.cargo("build --example=ex").run(); - assert_that( - &p.example_lib("ex", "lib").with_extension("d"), - existing_file(), - ); + assert!(p.example_lib("ex", "lib").with_extension("d").is_file()); } #[test] @@ -63,10 +59,7 @@ fn build_dep_info_rlib() { .build(); p.cargo("build --example=ex").run(); - assert_that( - &p.example_lib("ex", "rlib").with_extension("d"), - existing_file(), - ); + assert!(p.example_lib("ex", "rlib").with_extension("d").is_file()); } #[test] @@ -89,10 +82,7 @@ fn build_dep_info_dylib() { .build(); p.cargo("build --example=ex").run(); - assert_that( - &p.example_lib("ex", "dylib").with_extension("d"), - existing_file(), - ); + assert!(p.example_lib("ex", "dylib").with_extension("d").is_file()); } #[test] diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index 55c398c7f5d..bdfef237660 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -4,7 +4,6 @@ use std::str; use support; use glob::glob; -use support::hamcrest::{assert_that, existing_dir, existing_file, is_not}; use support::paths::CargoPathExt; use support::registry::Package; use support::{basic_lib_manifest, basic_manifest, git, path2url, project}; @@ -35,8 +34,8 @@ fn simple() { ", dir = path2url(p.root()) )).run(); - assert_that(&p.root().join("target/doc"), existing_dir()); - assert_that(&p.root().join("target/doc/foo/index.html"), existing_file()); + assert!(p.root().join("target/doc").is_dir()); + assert!(p.root().join("target/doc/foo/index.html").is_file()); } #[test] @@ -106,9 +105,9 @@ fn doc_deps() { dir = path2url(p.root()) )).run(); - assert_that(&p.root().join("target/doc"), existing_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()); + assert!(p.root().join("target/doc").is_dir()); + assert!(p.root().join("target/doc/foo/index.html").is_file()); + assert!(p.root().join("target/doc/bar/index.html").is_file()); // Verify that it only emits rmeta for the dependency. assert_eq!( @@ -133,9 +132,9 @@ fn doc_deps() { .with_stdout("") .run(); - assert_that(&p.root().join("target/doc"), existing_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()); + assert!(p.root().join("target/doc").is_dir()); + assert!(p.root().join("target/doc/foo/index.html").is_file()); + assert!(p.root().join("target/doc/bar/index.html").is_file()); } #[test] @@ -167,12 +166,9 @@ fn doc_no_deps() { dir = path2url(p.root()) )).run(); - assert_that(&p.root().join("target/doc"), existing_dir()); - assert_that(&p.root().join("target/doc/foo/index.html"), existing_file()); - assert_that( - &p.root().join("target/doc/bar/index.html"), - is_not(existing_file()), - ); + assert!(p.root().join("target/doc").is_dir()); + assert!(p.root().join("target/doc/foo/index.html").is_file()); + assert!(!p.root().join("target/doc/bar/index.html").is_file()); } #[test] @@ -196,9 +192,9 @@ fn doc_only_bin() { p.cargo("doc -v").run(); - assert_that(&p.root().join("target/doc"), existing_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()); + assert!(p.root().join("target/doc").is_dir()); + assert!(p.root().join("target/doc/bar/index.html").is_file()); + assert!(p.root().join("target/doc/foo/index.html").is_file()); } #[test] @@ -279,9 +275,9 @@ 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()); + assert!(doc_file.is_file()); } #[test] @@ -386,9 +382,9 @@ 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()); + assert!(doc_file.is_file()); let mut doc_html = String::new(); File::open(&doc_file) .unwrap() @@ -426,9 +422,9 @@ 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()); + assert!(doc_file.is_file()); let mut doc_html = String::new(); File::open(&doc_file) .unwrap() @@ -467,9 +463,9 @@ 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()); + assert!(doc_file.is_file()); let mut doc_html = String::new(); File::open(&doc_file) .unwrap() @@ -508,9 +504,9 @@ 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()); + assert!(doc_file.is_file()); let mut doc_html = String::new(); File::open(&doc_file) .unwrap() @@ -592,14 +588,11 @@ fn doc_target() { ).build(); p.cargo("doc --verbose --target").arg(TARGET).run(); - assert_that( - &p.root().join(&format!("target/{}/doc", TARGET)), - existing_dir(), - ); - assert_that( - &p.root() - .join(&format!("target/{}/doc/foo/index.html", TARGET)), - existing_file(), + assert!(p.root().join(&format!("target/{}/doc", TARGET)).is_dir()); + assert!( + p.root() + .join(&format!("target/{}/doc/foo/index.html", TARGET)) + .is_file() ); } @@ -767,9 +760,9 @@ fn doc_multiple_deps() { p.cargo("doc -p bar -p baz -v").run(); - assert_that(&p.root().join("target/doc"), existing_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()); + assert!(p.root().join("target/doc").is_dir()); + assert!(p.root().join("target/doc/bar/index.html").is_file()); + assert!(p.root().join("target/doc/baz/index.html").is_file()); } #[test] @@ -813,15 +806,9 @@ 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_that( - &p.root().join("target/doc/foo/fn.foo.html"), - existing_file(), - ); - assert_that( - &p.root().join("target/doc/bar/fn.bar.html"), - existing_file(), - ); + assert!(p.root().join("target/doc").is_dir()); + assert!(p.root().join("target/doc/foo/fn.foo.html").is_file()); + assert!(p.root().join("target/doc/bar/fn.bar.html").is_file()); } #[test] @@ -836,12 +823,12 @@ fn rerun_when_dir_removed() { ).build(); p.cargo("doc").run(); - assert_that(&p.root().join("target/doc/foo/index.html"), existing_file()); + assert!(p.root().join("target/doc/foo/index.html").is_file()); fs::remove_dir_all(p.root().join("target/doc/foo")).unwrap(); p.cargo("doc").run(); - assert_that(&p.root().join("target/doc/foo/index.html"), existing_file()); + assert!(p.root().join("target/doc/foo/index.html").is_file()); } #[test] @@ -864,7 +851,7 @@ fn document_only_lib() { "#, ).build(); p.cargo("doc --lib").run(); - assert_that(&p.root().join("target/doc/foo/index.html"), existing_file()); + assert!(p.root().join("target/doc/foo/index.html").is_file()); } #[test] @@ -1221,10 +1208,11 @@ fn doc_private_items() { .build(); foo.cargo("doc --document-private-items").run(); - assert_that(&foo.root().join("target/doc"), existing_dir()); - assert_that( - &foo.root().join("target/doc/foo/private/index.html"), - existing_file(), + assert!(foo.root().join("target/doc").is_dir()); + assert!( + foo.root() + .join("target/doc/foo/private/index.html") + .is_file() ); } diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index 570833a174e..e1b103daafe 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -1,7 +1,6 @@ use std::fs::{self, File}; use std::io::prelude::*; -use support::hamcrest::{assert_that, existing_file}; use support::paths::CargoPathExt; use support::registry::Package; use support::sleep_ms; @@ -65,7 +64,7 @@ fn modify_only_some_files() { p.cargo("test").run(); sleep_ms(1000); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); let lib = p.root().join("src/lib.rs"); let bin = p.root().join("src/b.rs"); @@ -89,7 +88,7 @@ fn modify_only_some_files() { ", dir = path2url(p.root()) )).run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); } #[test] diff --git a/tests/testsuite/generate_lockfile.rs b/tests/testsuite/generate_lockfile.rs index 4438fa8acbd..eea6b1fb2fc 100644 --- a/tests/testsuite/generate_lockfile.rs +++ b/tests/testsuite/generate_lockfile.rs @@ -1,7 +1,6 @@ use std::fs::{self, File}; use std::io::prelude::*; -use support::hamcrest::{assert_that, existing_file, is_not}; use support::registry::Package; use support::{basic_manifest, paths, project, ProjectBuilder}; @@ -137,7 +136,7 @@ fn preserve_line_endings_issue_2076() { let lockfile = p.root().join("Cargo.lock"); p.cargo("generate-lockfile").run(); - assert_that(&lockfile, existing_file()); + assert!(lockfile.is_file()); p.cargo("generate-lockfile").run(); let lock0 = p.read_lockfile(); @@ -165,15 +164,15 @@ fn cargo_update_generate_lockfile() { let p = project().file("src/main.rs", "fn main() {}").build(); let lockfile = p.root().join("Cargo.lock"); - assert_that(&lockfile, is_not(existing_file())); + assert!(!lockfile.is_file()); p.cargo("update").with_stdout("").run(); - assert_that(&lockfile, existing_file()); + assert!(lockfile.is_file()); fs::remove_file(p.root().join("Cargo.lock")).unwrap(); - assert_that(&lockfile, is_not(existing_file())); + assert!(!lockfile.is_file()); p.cargo("update").with_stdout("").run(); - assert_that(&lockfile, existing_file()); + assert!(lockfile.is_file()); } #[test] diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index 4c8c8765eed..3e94c8e0349 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -7,7 +7,6 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::thread; -use support::hamcrest::{assert_that, existing_file}; use support::paths::{self, CargoPathExt}; use support::sleep_ms; use support::{basic_lib_manifest, basic_manifest, git, main_file, path2url, project}; @@ -65,7 +64,7 @@ fn cargo_compile_simple_git_dep() { path2url(root) )).run(); - assert_that(&project.bin("foo"), existing_file()); + assert!(project.bin("foo").is_file()); project .process(&project.bin("foo")) @@ -202,7 +201,7 @@ fn cargo_compile_offline_with_cached_git_dep() { path2url(root) )).run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")) .with_stdout("hello from cached git repo rev2\n") @@ -293,7 +292,7 @@ fn cargo_compile_git_dep_branch() { path2url(root) )).run(); - assert_that(&project.bin("foo"), existing_file()); + assert!(project.bin("foo").is_file()); project .process(&project.bin("foo")) @@ -366,7 +365,7 @@ fn cargo_compile_git_dep_tag() { path2url(root) )).run(); - assert_that(&project.bin("foo"), existing_file()); + assert!(project.bin("foo").is_file()); project .process(&project.bin("foo")) @@ -447,7 +446,7 @@ fn cargo_compile_with_nested_paths() { p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).with_stdout("hello world\n").run(); } @@ -496,7 +495,7 @@ fn cargo_compile_with_malformed_nested_paths() { p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).with_stdout("hello world\n").run(); } @@ -562,7 +561,7 @@ fn cargo_compile_with_meta_package() { p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")) .with_stdout("this is dep1 this is dep2\n") @@ -692,7 +691,7 @@ fn two_revs_same_deps() { ).build(); foo.cargo("build -v").run(); - assert_that(&foo.bin("foo"), existing_file()); + assert!(foo.bin("foo").is_file()); foo.process(&foo.bin("foo")).run(); } diff --git a/tests/testsuite/init.rs b/tests/testsuite/init.rs index d48b8995ddf..2f1e228f6fd 100644 --- a/tests/testsuite/init.rs +++ b/tests/testsuite/init.rs @@ -3,7 +3,6 @@ use std::fs::{self, File}; use std::io::prelude::*; use support; -use support::hamcrest::{assert_that, existing_dir, existing_file, is_not}; use support::{paths, Execs}; fn cargo_process(s: &str) -> Execs { @@ -19,9 +18,9 @@ fn simple_lib() { .with_stderr("[CREATED] library project") .run(); - assert_that(&paths::root().join("Cargo.toml"), existing_file()); - assert_that(&paths::root().join("src/lib.rs"), existing_file()); - assert_that(&paths::root().join(".gitignore"), is_not(existing_file())); + assert!(paths::root().join("Cargo.toml").is_file()); + assert!(paths::root().join("src/lib.rs").is_file()); + assert!(!paths::root().join(".gitignore").is_file()); cargo_process("build").run(); } @@ -36,13 +35,14 @@ fn simple_bin() { .with_stderr("[CREATED] binary (application) project") .run(); - assert_that(&paths::root().join("foo/Cargo.toml"), existing_file()); - assert_that(&paths::root().join("foo/src/main.rs"), existing_file()); + assert!(paths::root().join("foo/Cargo.toml").is_file()); + assert!(paths::root().join("foo/src/main.rs").is_file()); cargo_process("build").cwd(&path).run(); - assert_that( - &paths::root().join(&format!("foo/target/debug/foo{}", env::consts::EXE_SUFFIX)), - existing_file(), + assert!( + paths::root() + .join(&format!("foo/target/debug/foo{}", env::consts::EXE_SUFFIX)) + .is_file() ); } @@ -84,11 +84,8 @@ fn bin_already_exists(explicit: bool, rellocation: &str) { .run(); } - assert_that(&paths::root().join("foo/Cargo.toml"), existing_file()); - assert_that( - &paths::root().join("foo/src/lib.rs"), - is_not(existing_file()), - ); + assert!(paths::root().join("foo/Cargo.toml").is_file()); + assert!(!paths::root().join("foo/src/lib.rs").is_file()); // Check that our file is not overwritten let mut new_content = Vec::new(); @@ -153,10 +150,7 @@ fn confused_by_multiple_lib_files() { ) .run(); - assert_that( - &paths::root().join("foo/Cargo.toml"), - is_not(existing_file()), - ); + assert!(!paths::root().join("foo/Cargo.toml").is_file()); } #[test] @@ -191,10 +185,7 @@ cannot automatically generate Cargo.toml as the main target would be ambiguous ", ).run(); - assert_that( - &paths::root().join("foo/Cargo.toml"), - is_not(existing_file()), - ); + assert!(!paths::root().join("foo/Cargo.toml").is_file()); } fn lib_already_exists(rellocation: &str) { @@ -217,11 +208,8 @@ fn lib_already_exists(rellocation: &str) { .cwd(&path) .run(); - assert_that(&paths::root().join("foo/Cargo.toml"), existing_file()); - assert_that( - &paths::root().join("foo/src/main.rs"), - is_not(existing_file()), - ); + assert!(paths::root().join("foo/Cargo.toml").is_file()); + assert!(!paths::root().join("foo/src/main.rs").is_file()); // Check that our file is not overwritten let mut new_content = Vec::new(); @@ -248,20 +236,20 @@ fn simple_git() { .env("USER", "foo") .run(); - 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_that(&paths::root().join(".gitignore"), existing_file()); + assert!(paths::root().join("Cargo.toml").is_file()); + assert!(paths::root().join("src/lib.rs").is_file()); + assert!(paths::root().join(".git").is_dir()); + assert!(paths::root().join(".gitignore").is_file()); } #[test] fn auto_git() { cargo_process("init --lib").env("USER", "foo").run(); - 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_that(&paths::root().join(".gitignore"), existing_file()); + assert!(paths::root().join("Cargo.toml").is_file()); + assert!(paths::root().join("src/lib.rs").is_file()); + assert!(paths::root().join(".git").is_dir()); + assert!(paths::root().join(".gitignore").is_file()); } #[test] @@ -279,7 +267,7 @@ use --name to override crate name ", ).run(); - assert_that(&foo.join("Cargo.toml"), is_not(existing_file())); + assert!(!foo.join("Cargo.toml").is_file()); } #[test] @@ -297,7 +285,7 @@ use --name to override crate name ", ).run(); - assert_that(&test.join("Cargo.toml"), is_not(existing_file())); + assert!(!test.join("Cargo.toml").is_file()); } #[test] @@ -306,10 +294,10 @@ fn git_autodetect() { cargo_process("init --lib").env("USER", "foo").run(); - 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_that(&paths::root().join(".gitignore"), existing_file()); + assert!(paths::root().join("Cargo.toml").is_file()); + assert!(paths::root().join("src/lib.rs").is_file()); + assert!(paths::root().join(".git").is_dir()); + assert!(paths::root().join(".gitignore").is_file()); } #[test] @@ -318,10 +306,10 @@ fn mercurial_autodetect() { cargo_process("init --lib").env("USER", "foo").run(); - 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_that(&paths::root().join(".hgignore"), existing_file()); + assert!(paths::root().join("Cargo.toml").is_file()); + assert!(paths::root().join("src/lib.rs").is_file()); + assert!(!paths::root().join(".git").is_dir()); + assert!(paths::root().join(".hgignore").is_file()); } #[test] @@ -335,10 +323,10 @@ fn gitignore_appended_not_replaced() { cargo_process("init --lib").env("USER", "foo").run(); - 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_that(&paths::root().join(".gitignore"), existing_file()); + assert!(paths::root().join("Cargo.toml").is_file()); + assert!(paths::root().join("src/lib.rs").is_file()); + assert!(paths::root().join(".git").is_dir()); + assert!(paths::root().join(".gitignore").is_file()); let mut contents = String::new(); File::open(&paths::root().join(".gitignore")) @@ -359,7 +347,7 @@ fn gitignore_added_newline_in_existing() { cargo_process("init --lib").env("USER", "foo").run(); - assert_that(&paths::root().join(".gitignore"), existing_file()); + assert!(paths::root().join(".gitignore").is_file()); let mut contents = String::new(); File::open(&paths::root().join(".gitignore")) @@ -375,7 +363,7 @@ fn gitignore_no_newline_in_new() { cargo_process("init --lib").env("USER", "foo").run(); - assert_that(&paths::root().join(".gitignore"), existing_file()); + assert!(paths::root().join(".gitignore").is_file()); let mut contents = String::new(); File::open(&paths::root().join(".gitignore")) @@ -396,7 +384,7 @@ fn mercurial_added_newline_in_existing() { cargo_process("init --lib").env("USER", "foo").run(); - assert_that(&paths::root().join(".hgignore"), existing_file()); + assert!(paths::root().join(".hgignore").is_file()); let mut contents = String::new(); File::open(&paths::root().join(".hgignore")) @@ -412,7 +400,7 @@ fn mercurial_no_newline_in_new() { cargo_process("init --lib").env("USER", "foo").run(); - assert_that(&paths::root().join(".hgignore"), existing_file()); + assert!(paths::root().join(".hgignore").is_file()); let mut contents = String::new(); File::open(&paths::root().join(".hgignore")) @@ -430,7 +418,7 @@ fn cargo_lock_gitignored_if_lib1() { .env("USER", "foo") .run(); - assert_that(&paths::root().join(".gitignore"), existing_file()); + assert!(paths::root().join(".gitignore").is_file()); let mut contents = String::new(); File::open(&paths::root().join(".gitignore")) @@ -451,7 +439,7 @@ fn cargo_lock_gitignored_if_lib2() { cargo_process("init --vcs git").env("USER", "foo").run(); - assert_that(&paths::root().join(".gitignore"), existing_file()); + assert!(paths::root().join(".gitignore").is_file()); let mut contents = String::new(); File::open(&paths::root().join(".gitignore")) @@ -469,7 +457,7 @@ fn cargo_lock_not_gitignored_if_bin1() { .env("USER", "foo") .run(); - assert_that(&paths::root().join(".gitignore"), existing_file()); + assert!(paths::root().join(".gitignore").is_file()); let mut contents = String::new(); File::open(&paths::root().join(".gitignore")) @@ -490,7 +478,7 @@ fn cargo_lock_not_gitignored_if_bin2() { cargo_process("init --vcs git").env("USER", "foo").run(); - assert_that(&paths::root().join(".gitignore"), existing_file()); + assert!(paths::root().join(".gitignore").is_file()); let mut contents = String::new(); File::open(&paths::root().join(".gitignore")) @@ -505,7 +493,7 @@ fn with_argument() { cargo_process("init foo --vcs none") .env("USER", "foo") .run(); - assert_that(&paths::root().join("foo/Cargo.toml"), existing_file()); + assert!(paths::root().join("foo/Cargo.toml").is_file()); } #[test] diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index 3ce4724b151..e045dc34253 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -5,8 +5,7 @@ use support; use git2; use support::cross_compile; use support::git; -use support::hamcrest::{assert_that, existing_dir, is_not}; -use support::install::{cargo_home, has_installed_exe}; +use support::install::{assert_has_installed_exe, assert_has_not_installed_exe, cargo_home}; use support::paths; use support::registry::Package; use support::{basic_manifest, cargo_process, project}; @@ -37,14 +36,14 @@ warning: be sure to add `[..]` to your PATH to be able to run the installed bina ", home = cargo_home().display() )).run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); cargo_process("uninstall foo") .with_stderr(&format!( "[REMOVING] {home}[..]bin[..]foo[..]", home = cargo_home().display() )).run(); - assert_that(cargo_home(), is_not(has_installed_exe("foo"))); + assert_has_not_installed_exe(cargo_home(), "foo"); } #[test] @@ -74,8 +73,8 @@ error: some crates failed to install ", home = cargo_home().display() )).run(); - assert_that(cargo_home(), has_installed_exe("foo")); - assert_that(cargo_home(), has_installed_exe("bar")); + assert_has_installed_exe(cargo_home(), "foo"); + assert_has_installed_exe(cargo_home(), "bar"); cargo_process("uninstall foo bar") .with_stderr(&format!( @@ -87,8 +86,8 @@ error: some crates failed to install home = cargo_home().display() )).run(); - assert_that(cargo_home(), is_not(has_installed_exe("foo"))); - assert_that(cargo_home(), is_not(has_installed_exe("bar"))); + assert_has_not_installed_exe(cargo_home(), "foo"); + assert_has_not_installed_exe(cargo_home(), "bar"); } #[test] @@ -112,7 +111,7 @@ warning: be sure to add `[..]` to your PATH to be able to run the installed bina ", home = cargo_home().display() )).run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); } #[test] @@ -126,7 +125,7 @@ fn installs_beta_version_by_explicit_name_from_git() { .arg(p.url().to_string()) .arg("foo") .run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); } #[test] @@ -201,29 +200,29 @@ fn install_location_precedence() { .arg(&t1) .env("CARGO_INSTALL_ROOT", &t2) .run(); - assert_that(&t1, has_installed_exe("foo")); - assert_that(&t2, is_not(has_installed_exe("foo"))); + assert_has_installed_exe(&t1, "foo"); + assert_has_not_installed_exe(&t2, "foo"); println!("install CARGO_INSTALL_ROOT"); cargo_process("install foo") .env("CARGO_INSTALL_ROOT", &t2) .run(); - assert_that(&t2, has_installed_exe("foo")); - assert_that(&t3, is_not(has_installed_exe("foo"))); + assert_has_installed_exe(&t2, "foo"); + assert_has_not_installed_exe(&t3, "foo"); println!("install install.root"); cargo_process("install foo").run(); - assert_that(&t3, has_installed_exe("foo")); - assert_that(&t4, is_not(has_installed_exe("foo"))); + assert_has_installed_exe(&t3, "foo"); + assert_has_not_installed_exe(&t4, "foo"); fs::remove_file(root.join(".cargo/config")).unwrap(); println!("install cargo home"); cargo_process("install foo").run(); - assert_that(&t4, has_installed_exe("foo")); + assert_has_installed_exe(&t4, "foo"); } #[test] @@ -231,7 +230,7 @@ fn install_path() { let p = project().file("src/main.rs", "fn main() {}").build(); cargo_process("install --path").arg(p.root()).run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); cargo_process("install --path .") .cwd(p.root()) .with_status(101) @@ -277,14 +276,14 @@ fn multiple_crates_select() { .arg(p.url().to_string()) .arg("foo") .run(); - assert_that(cargo_home(), has_installed_exe("foo")); - assert_that(cargo_home(), is_not(has_installed_exe("bar"))); + assert_has_installed_exe(cargo_home(), "foo"); + assert_has_not_installed_exe(cargo_home(), "bar"); cargo_process("install --git") .arg(p.url().to_string()) .arg("bar") .run(); - assert_that(cargo_home(), has_installed_exe("bar")); + assert_has_installed_exe(cargo_home(), "bar"); } #[test] @@ -307,7 +306,7 @@ fn multiple_crates_auto_binaries() { .build(); cargo_process("install --path").arg(p.root()).run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); } #[test] @@ -340,7 +339,7 @@ fn multiple_crates_auto_examples() { .arg(p.root()) .arg("--example=foo") .run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); } #[test] @@ -399,7 +398,7 @@ fn examples() { .arg(p.root()) .arg("--example=foo") .run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); } #[test] @@ -580,8 +579,8 @@ warning: be sure to add `[..]` to your PATH to be able to run the installed bina ", home = cargo_home().display() )).run(); - assert_that(cargo_home(), has_installed_exe("foo")); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); + assert_has_installed_exe(cargo_home(), "foo"); } #[test] @@ -666,20 +665,20 @@ fn uninstall_piecemeal() { .build(); cargo_process("install --path").arg(p.root()).run(); - assert_that(cargo_home(), has_installed_exe("foo")); - assert_that(cargo_home(), has_installed_exe("bar")); + assert_has_installed_exe(cargo_home(), "foo"); + assert_has_installed_exe(cargo_home(), "bar"); cargo_process("uninstall foo --bin=bar") .with_stderr("[REMOVING] [..]bar[..]") .run(); - assert_that(cargo_home(), has_installed_exe("foo")); - assert_that(cargo_home(), is_not(has_installed_exe("bar"))); + assert_has_installed_exe(cargo_home(), "foo"); + assert_has_not_installed_exe(cargo_home(), "bar"); cargo_process("uninstall foo --bin=foo") .with_stderr("[REMOVING] [..]foo[..]") .run(); - assert_that(cargo_home(), is_not(has_installed_exe("foo"))); + assert_has_not_installed_exe(cargo_home(), "foo"); cargo_process("uninstall foo") .with_status(101) @@ -711,7 +710,7 @@ fn installs_from_cwd_by_default() { use `cargo install --path .` instead. \ Use `cargo build` if you want to simply build the package.", ).run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); } #[test] @@ -746,7 +745,7 @@ fn installs_from_cwd_with_2018_warnings() { use `cargo install --path .` instead. \ Use `cargo build` if you want to simply build the package.", ).run(); - assert_that(cargo_home(), is_not(has_installed_exe("foo"))); + assert_has_not_installed_exe(cargo_home(), "foo"); } #[test] @@ -763,7 +762,7 @@ warning: be sure to add `{home}/bin` to your PATH to be able to run the installe home = cargo_home().display(), url = p.url(), )).run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); p.cargo("uninstall") .with_stdout("") @@ -772,7 +771,7 @@ warning: be sure to add `{home}/bin` to your PATH to be able to run the installe [REMOVING] {home}/bin/foo[EXE]", home = cargo_home().display() )).run(); - assert_that(cargo_home(), is_not(has_installed_exe("foo"))); + assert_has_not_installed_exe(cargo_home(), "foo"); } #[test] @@ -826,7 +825,7 @@ warning: be sure to add `[..]` to your PATH to be able to run the installed bina assert!(p.build_dir().exists()); assert!(p.release_bin("foo").exists()); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); } #[test] @@ -902,7 +901,7 @@ fn readonly_dir() { fs::set_permissions(dir, perms).unwrap(); cargo_process("install foo").cwd(dir).run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); } #[test] @@ -998,7 +997,7 @@ fn install_target_native() { cargo_process("install foo --target") .arg(support::rustc_host()) .run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); } #[test] @@ -1012,7 +1011,7 @@ fn install_target_foreign() { cargo_process("install foo --target") .arg(cross_compile::alternate()) .run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); } #[test] @@ -1093,8 +1092,8 @@ error: some packages failed to uninstall home = cargo_home().display() )).run(); - assert_that(cargo_home(), is_not(has_installed_exe("foo"))); - assert_that(cargo_home(), is_not(has_installed_exe("bar"))); + assert_has_not_installed_exe(cargo_home(), "foo"); + assert_has_not_installed_exe(cargo_home(), "bar"); } #[test] @@ -1107,16 +1106,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] diff --git a/tests/testsuite/login.rs b/tests/testsuite/login.rs index 8ef4626b715..6fc84d7915a 100644 --- a/tests/testsuite/login.rs +++ b/tests/testsuite/login.rs @@ -4,7 +4,6 @@ use std::io::prelude::*; use cargo::core::Shell; use cargo::util::config::Config; use support::cargo_process; -use support::hamcrest::{assert_that, existing_file, is_not}; use support::install::cargo_home; use support::registry::registry; use toml; @@ -34,7 +33,7 @@ fn setup_new_credentials() { fn check_token(expected_token: &str, registry: Option<&str>) -> bool { let credentials = cargo_home().join("credentials"); - assert_that(&credentials, existing_file()); + assert!(credentials.is_file()); let mut contents = String::new(); File::open(&credentials) @@ -81,7 +80,7 @@ fn login_with_old_credentials() { .run(); let config = cargo_home().join("config"); - assert_that(&config, existing_file()); + assert!(config.is_file()); let mut contents = String::new(); File::open(&config) @@ -104,7 +103,7 @@ fn login_with_new_credentials() { .run(); let config = cargo_home().join("config"); - assert_that(&config, is_not(existing_file())); + assert!(!config.is_file()); // Ensure that we get the new token for the registry assert!(check_token(TOKEN, None)); @@ -124,7 +123,7 @@ fn login_without_credentials() { .run(); let config = cargo_home().join("config"); - assert_that(&config, is_not(existing_file())); + assert!(!config.is_file()); // Ensure that we get the new token for the registry assert!(check_token(TOKEN, None)); diff --git a/tests/testsuite/new.rs b/tests/testsuite/new.rs index d6638e996fe..76056a90435 100644 --- a/tests/testsuite/new.rs +++ b/tests/testsuite/new.rs @@ -2,7 +2,6 @@ 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::paths; use support::{cargo_process, git_process}; @@ -20,13 +19,10 @@ fn simple_lib() { .with_stderr("[CREATED] library `foo` project") .run(); - assert_that(&paths::root().join("foo"), existing_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/.gitignore"), - is_not(existing_file()), - ); + assert!(paths::root().join("foo").is_dir()); + assert!(paths::root().join("foo/Cargo.toml").is_file()); + assert!(paths::root().join("foo/src/lib.rs").is_file()); + assert!(!paths::root().join("foo/.gitignore").is_file()); let lib = paths::root().join("foo/src/lib.rs"); let mut contents = String::new(); @@ -56,14 +52,15 @@ fn simple_bin() { .with_stderr("[CREATED] binary (application) `foo` project") .run(); - assert_that(&paths::root().join("foo"), existing_dir()); - assert_that(&paths::root().join("foo/Cargo.toml"), existing_file()); - assert_that(&paths::root().join("foo/src/main.rs"), existing_file()); + assert!(paths::root().join("foo").is_dir()); + assert!(paths::root().join("foo/Cargo.toml").is_file()); + assert!(paths::root().join("foo/src/main.rs").is_file()); cargo_process("build").cwd(&paths::root().join("foo")).run(); - assert_that( - &paths::root().join(&format!("foo/target/debug/foo{}", env::consts::EXE_SUFFIX)), - existing_file(), + assert!( + paths::root() + .join(&format!("foo/target/debug/foo{}", env::consts::EXE_SUFFIX)) + .is_file() ); } @@ -80,11 +77,11 @@ fn both_lib_and_bin() { fn simple_git() { cargo_process("new --lib foo").env("USER", "foo").run(); - assert_that(&paths::root(), existing_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_that(&paths::root().join("foo/.gitignore"), existing_file()); + assert!(paths::root().is_dir()); + assert!(paths::root().join("foo/Cargo.toml").is_file()); + assert!(paths::root().join("foo/src/lib.rs").is_file()); + assert!(paths::root().join("foo/.git").is_dir()); + assert!(paths::root().join("foo/.gitignore").is_file()); cargo_process("build").cwd(&paths::root().join("foo")).run(); } @@ -364,8 +361,8 @@ 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_that(&paths::root().join("foo/.gitignore"), existing_file()); + assert!(paths::root().join("foo/.git").is_dir()); + assert!(paths::root().join("foo/.gitignore").is_file()); let subpackage = paths::root().join("foo").join("components"); fs::create_dir(&subpackage).unwrap(); @@ -373,13 +370,15 @@ fn subpackage_no_git() { .env("USER", "foo") .run(); - assert_that( - &paths::root().join("foo/components/subcomponent/.git"), - is_not(existing_file()), + assert!( + !paths::root() + .join("foo/components/subcomponent/.git") + .is_file() ); - assert_that( - &paths::root().join("foo/components/subcomponent/.gitignore"), - is_not(existing_file()), + assert!( + !paths::root() + .join("foo/components/subcomponent/.gitignore") + .is_file() ); } @@ -387,8 +386,8 @@ 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_that(&paths::root().join("foo/.gitignore"), existing_file()); + assert!(paths::root().join("foo/.git").is_dir()); + assert!(paths::root().join("foo/.gitignore").is_file()); let gitignore = paths::root().join("foo/.gitignore"); fs::write(gitignore, b"components").unwrap(); @@ -399,13 +398,15 @@ 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(), + assert!( + paths::root() + .join("foo/components/subcomponent/.gitignore") + .is_file() ); } @@ -419,13 +420,15 @@ 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(), + assert!( + paths::root() + .join("foo/components/subcomponent/.gitignore") + .is_file() ); } diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index cd22b14533e..48c74893b81 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -5,7 +5,6 @@ use std::path::{Path, PathBuf}; use flate2::read::GzDecoder; use git2; -use support::hamcrest::{assert_that, contains, existing_file}; use support::registry::Package; use support::{basic_manifest, git, is_nightly, path2url, paths, project, registry}; use support::{cargo_process, sleep_ms}; @@ -39,10 +38,7 @@ See [..] ", dir = p.url() )).run(); - assert_that( - &p.root().join("target/package/foo-0.0.1.crate"), - existing_file(), - ); + assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") .with_stdout( "\ @@ -398,10 +394,7 @@ See [..] ", ).run(); - assert_that( - &p.root().join("target/package/foo-0.0.1.crate"), - existing_file(), - ); + assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") .with_stdout( @@ -564,10 +557,7 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. ", dir = p.url() )).run(); - assert_that( - &p.root().join("target/package/foo-0.0.1.crate"), - existing_file(), - ); + assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") .with_stdout( "\ @@ -665,10 +655,7 @@ See [..] let entry_paths = entries .map(|entry| entry.unwrap().path().unwrap().into_owned()) .collect::>(); - assert_that( - &entry_paths, - contains(vec![PathBuf::from("foo-0.0.1/src/foo.rs")]), - ); + assert!(entry_paths.contains(&PathBuf::from("foo-0.0.1/src/foo.rs"))); } #[test] @@ -1131,10 +1118,7 @@ See [..] ", dir = p.url() )).run(); - assert_that( - &p.root().join("target/package/foo-0.0.1.crate"), - existing_file(), - ); + assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") .masquerade_as_nightly_cargo() .with_stdout( diff --git a/tests/testsuite/path.rs b/tests/testsuite/path.rs index a24e35dec92..6e0739b165a 100644 --- a/tests/testsuite/path.rs +++ b/tests/testsuite/path.rs @@ -1,7 +1,6 @@ use std::fs::{self, File}; use std::io::prelude::*; -use support::hamcrest::{assert_that, existing_file, is_not}; use support::paths::{self, CargoPathExt}; use support::registry::Package; use support::sleep_ms; @@ -76,7 +75,7 @@ fn cargo_compile_with_nested_deps_shorthand() { p.url() )).run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).with_stdout("test passed\n").run(); @@ -238,7 +237,7 @@ fn cargo_compile_with_transitive_dev_deps() { p.url() )).run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).with_stdout("zoidberg\n").run(); } @@ -429,9 +428,9 @@ fn no_rebuild_two_deps() { p.url(), p.url() )).run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.cargo("build").with_stdout("").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); } #[test] @@ -695,7 +694,7 @@ fn path_dep_build_cmd() { p.url() )).run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).with_stdout("0\n").run(); @@ -977,11 +976,8 @@ fn workspace_produces_rlib() { p.cargo("build").run(); - assert_that(&p.root().join("target/debug/libtop.rlib"), existing_file()); - assert_that( - &p.root().join("target/debug/libfoo.rlib"), - is_not(existing_file()), - ); + assert!(p.root().join("target/debug/libtop.rlib").is_file()); + assert!(!p.root().join("target/debug/libfoo.rlib").is_file()); } #[test] diff --git a/tests/testsuite/required_features.rs b/tests/testsuite/required_features.rs index 400a59ba256..730ef0479bd 100644 --- a/tests/testsuite/required_features.rs +++ b/tests/testsuite/required_features.rs @@ -1,5 +1,4 @@ -use support::hamcrest::{assert_that, existing_file, is_not}; -use support::install::{cargo_home, has_installed_exe}; +use support::install::{cargo_home, assert_has_installed_exe, assert_has_not_installed_exe}; use support::is_nightly; use support::project; @@ -38,12 +37,12 @@ fn build_bin_default_features() { .build(); p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.cargo("build --no-default-features").run(); p.cargo("build --bin=foo").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.cargo("build --bin=foo --no-default-features") .with_status(101) @@ -77,7 +76,7 @@ fn build_bin_arg_features() { .build(); p.cargo("build --features a").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); } #[test] @@ -113,13 +112,13 @@ fn build_bin_multiple_required_features() { p.cargo("build").run(); - assert_that(&p.bin("foo_1"), is_not(existing_file())); - assert_that(&p.bin("foo_2"), existing_file()); + assert!(!p.bin("foo_1").is_file()); + assert!(p.bin("foo_2").is_file()); p.cargo("build --features c").run(); - assert_that(&p.bin("foo_1"), existing_file()); - assert_that(&p.bin("foo_2"), existing_file()); + assert!(p.bin("foo_1").is_file()); + assert!(p.bin("foo_2").is_file()); p.cargo("build --no-default-features").run(); } @@ -147,7 +146,7 @@ fn build_example_default_features() { .build(); p.cargo("build --example=foo").run(); - assert_that(&p.bin("examples/foo"), existing_file()); + assert!(p.bin("examples/foo").is_file()); p.cargo("build --example=foo --no-default-features") .with_status(101) @@ -181,7 +180,7 @@ fn build_example_arg_features() { .build(); p.cargo("build --example=foo --features a").run(); - assert_that(&p.bin("examples/foo"), existing_file()); + assert!(p.bin("examples/foo").is_file()); } #[test] @@ -223,14 +222,14 @@ Consider enabling them by passing e.g. `--features=\"b c\"` ).run(); p.cargo("build --example=foo_2").run(); - assert_that(&p.bin("examples/foo_1"), is_not(existing_file())); - assert_that(&p.bin("examples/foo_2"), existing_file()); + assert!(!p.bin("examples/foo_1").is_file()); + assert!(p.bin("examples/foo_2").is_file()); p.cargo("build --example=foo_1 --features c").run(); p.cargo("build --example=foo_2 --features c").run(); - assert_that(&p.bin("examples/foo_1"), existing_file()); - assert_that(&p.bin("examples/foo_2"), existing_file()); + assert!(p.bin("examples/foo_1").is_file()); + assert!(p.bin("examples/foo_2").is_file()); p.cargo("build --example=foo_1 --no-default-features") .with_status(101) @@ -608,7 +607,7 @@ fn install_default_features() { .build(); p.cargo("install --path .").run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); p.cargo("uninstall foo").run(); p.cargo("install --path . --no-default-features") @@ -620,10 +619,10 @@ fn install_default_features() { [ERROR] no binaries are available for install using the selected features ", ).run(); - assert_that(cargo_home(), is_not(has_installed_exe("foo"))); + assert_has_not_installed_exe(cargo_home(), "foo"); p.cargo("install --path . --bin=foo").run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); p.cargo("uninstall foo").run(); p.cargo("install --path . --bin=foo --no-default-features") @@ -639,10 +638,10 @@ Caused by: Consider enabling them by passing e.g. `--features=\"a\"` ", ).run(); - assert_that(cargo_home(), is_not(has_installed_exe("foo"))); + assert_has_not_installed_exe(cargo_home(), "foo"); p.cargo("install --path . --example=foo").run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); p.cargo("uninstall foo").run(); p.cargo("install --path . --example=foo --no-default-features") @@ -658,7 +657,7 @@ Caused by: Consider enabling them by passing e.g. `--features=\"a\"` ", ).run(); - assert_that(cargo_home(), is_not(has_installed_exe("foo"))); + assert_has_not_installed_exe(cargo_home(), "foo"); } #[test] @@ -683,7 +682,7 @@ fn install_arg_features() { .build(); p.cargo("install --features a").run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); p.cargo("uninstall foo").run(); } @@ -719,13 +718,13 @@ fn install_multiple_required_features() { .build(); p.cargo("install --path .").run(); - assert_that(cargo_home(), is_not(has_installed_exe("foo_1"))); - assert_that(cargo_home(), has_installed_exe("foo_2")); + assert_has_not_installed_exe(cargo_home(), "foo_1"); + assert_has_installed_exe(cargo_home(), "foo_2"); p.cargo("uninstall foo").run(); p.cargo("install --path . --features c").run(); - assert_that(cargo_home(), has_installed_exe("foo_1")); - assert_that(cargo_home(), has_installed_exe("foo_2")); + assert_has_installed_exe(cargo_home(), "foo_1"); + assert_has_installed_exe(cargo_home(), "foo_2"); p.cargo("uninstall foo").run(); p.cargo("install --path . --no-default-features") @@ -737,8 +736,8 @@ fn install_multiple_required_features() { [ERROR] no binaries are available for install using the selected features ", ).run(); - assert_that(cargo_home(), is_not(has_installed_exe("foo_1"))); - assert_that(cargo_home(), is_not(has_installed_exe("foo_2"))); + assert_has_not_installed_exe(cargo_home(), "foo_1"); + assert_has_not_installed_exe(cargo_home(), "foo_2"); } #[test] @@ -801,11 +800,11 @@ fn dep_feature_in_toml() { // bin p.cargo("build --bin=foo").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); // example p.cargo("build --example=foo").run(); - assert_that(&p.bin("examples/foo"), existing_file()); + assert!(p.bin("examples/foo").is_file()); // test p.cargo("test --test=foo") @@ -834,7 +833,7 @@ fn dep_feature_in_toml() { // install p.cargo("install").run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); p.cargo("uninstall foo").run(); } @@ -907,7 +906,7 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` ).run(); p.cargo("build --bin=foo --features bar/a").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); // example p.cargo("build --example=foo") @@ -920,7 +919,7 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` ).run(); p.cargo("build --example=foo --features bar/a").run(); - assert_that(&p.bin("examples/foo"), existing_file()); + assert!(p.bin("examples/foo").is_file()); // test p.cargo("test") @@ -967,10 +966,10 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` [ERROR] no binaries are available for install using the selected features ", ).run(); - assert_that(cargo_home(), is_not(has_installed_exe("foo"))); + assert_has_not_installed_exe(cargo_home(), "foo"); p.cargo("install --features bar/a").run(); - assert_that(cargo_home(), has_installed_exe("foo")); + assert_has_installed_exe(cargo_home(), "foo"); p.cargo("uninstall foo").run(); } diff --git a/tests/testsuite/resolve.rs b/tests/testsuite/resolve.rs index 5d2c2ef1bfc..b71f9c07571 100644 --- a/tests/testsuite/resolve.rs +++ b/tests/testsuite/resolve.rs @@ -1,7 +1,6 @@ +use std::cmp::PartialEq; use std::collections::{BTreeMap, HashSet}; -use support::hamcrest::{assert_that, contains, is_not}; - use cargo::core::dependency::Kind::{self, Development}; use cargo::core::resolver::{self, Method}; use cargo::core::source::{GitReference, SourceId}; @@ -215,13 +214,18 @@ fn test_resolving_empty_dependency_list() { assert_eq!(res, names(&["root"])); } -fn assert_same(a: &[PackageId], b: &[PackageId]) { - assert_eq!(a.len(), b.len()); - for item in a { - assert!(b.contains(item)); +/// Assert `xs` contains `elems` +fn assert_contains(xs: &[A], elems: &[A]) { + for elem in elems { + assert!(xs.contains(elem)); } } +fn assert_same(a: &[A], b: &[A]) { + assert_eq!(a.len(), b.len()); + assert_contains(b, a); +} + #[test] fn test_resolving_only_package() { let reg = registry(vec![pkg("foo")]); @@ -248,7 +252,7 @@ fn test_resolving_transitive_deps() { let reg = registry(vec![pkg!("foo"), pkg!("bar" => ["foo"])]); let res = resolve(&pkg_id("root"), vec![dep("bar")], ®).unwrap(); - assert_that(&res, contains(names(&["root", "foo", "bar"]))); + assert_contains(&res, &names(&["root", "foo", "bar"])); } #[test] @@ -256,7 +260,7 @@ fn test_resolving_common_transitive_deps() { let reg = registry(vec![pkg!("foo" => ["bar"]), pkg!("bar")]); let res = resolve(&pkg_id("root"), vec![dep("foo"), dep("bar")], ®).unwrap(); - assert_that(&res, contains(names(&["root", "foo", "bar"]))); + assert_contains(&res, &names(&["root", "foo", "bar"])); } #[test] @@ -300,7 +304,7 @@ fn test_resolving_with_dev_deps() { ®, ).unwrap(); - assert_that(&res, contains(names(&["root", "foo", "bar", "baz"]))); + assert_contains(&res, &names(&["root", "foo", "bar", "baz"])); } #[test] @@ -309,10 +313,7 @@ fn resolving_with_many_versions() { let res = resolve(&pkg_id("root"), vec![dep("foo")], ®).unwrap(); - assert_that( - &res, - contains(names(&[("root", "1.0.0"), ("foo", "1.0.2")])), - ); + assert_contains(&res, &names(&[("root", "1.0.0"), ("foo", "1.0.2")])); } #[test] @@ -321,10 +322,7 @@ fn resolving_with_specific_version() { let res = resolve(&pkg_id("root"), vec![dep_req("foo", "=1.0.1")], ®).unwrap(); - assert_that( - &res, - contains(names(&[("root", "1.0.0"), ("foo", "1.0.1")])), - ); + assert_contains(&res, &names(&[("root", "1.0.0"), ("foo", "1.0.1")])); } #[test] @@ -343,17 +341,17 @@ fn test_resolving_maximum_version_with_transitive_deps() { ®, ).unwrap(); - assert_that( + assert_contains( &res, - contains(names(&[ + &names(&[ ("root", "1.0.0"), ("foo", "1.0.0"), ("bar", "1.0.0"), ("util", "1.2.2"), - ])), + ]), ); - assert_that(&res, is_not(contains(names(&[("util", "1.0.1")])))); - assert_that(&res, is_not(contains(names(&[("util", "1.1.1")])))); + assert!(!res.contains(&("util", "1.0.1").to_pkgid())); + assert!(!res.contains(&("util", "1.1.1").to_pkgid())); } #[test] @@ -390,17 +388,17 @@ fn test_resolving_minimum_version_with_transitive_deps() { Some(&config), ).unwrap(); - assert_that( + assert_contains( &res, - contains(names(&[ + &names(&[ ("root", "1.0.0"), ("foo", "1.0.0"), ("bar", "1.0.0"), ("util", "1.1.1"), - ])), + ]), ); - assert_that(&res, is_not(contains(names(&[("util", "1.2.2")])))); - assert_that(&res, is_not(contains(names(&[("util", "1.0.0")])))); + assert!(!res.contains(&("util", "1.2.2").to_pkgid())); + assert!(!res.contains(&("util", "1.0.0").to_pkgid())); } // Ensure that the "-Z minimal-versions" CLI option works and the minimal @@ -484,13 +482,9 @@ fn resolving_backtrack() { let res = resolve(&pkg_id("root"), vec![dep_req("foo", "^1")], ®).unwrap(); - assert_that( + assert_contains( &res, - contains(names(&[ - ("root", "1.0.0"), - ("foo", "1.0.1"), - ("baz", "1.0.0"), - ])), + &names(&[("root", "1.0.0"), ("foo", "1.0.1"), ("baz", "1.0.0")]), ); } @@ -508,13 +502,9 @@ fn resolving_backtrack_features() { let res = resolve(&pkg_id("root"), vec![dep_req("foo", "^1")], ®).unwrap(); - assert_that( + assert_contains( &res, - contains(names(&[ - ("root", "1.0.0"), - ("foo", "1.0.1"), - ("bar", "1.0.0"), - ])), + &names(&[("root", "1.0.0"), ("foo", "1.0.1"), ("bar", "1.0.0")]), ); } @@ -534,9 +524,9 @@ fn resolving_allows_multiple_compatible_versions() { let res = resolve(&pkg_id("root"), vec![dep("bar")], ®).unwrap(); - assert_that( + assert_contains( &res, - contains(names(&[ + &names(&[ ("root", "1.0.0"), ("foo", "1.0.0"), ("foo", "2.0.0"), @@ -547,7 +537,7 @@ fn resolving_allows_multiple_compatible_versions() { ("d3", "1.0.0"), ("d4", "1.0.0"), ("bar", "1.0.0"), - ])), + ]), ); } @@ -567,14 +557,14 @@ fn resolving_with_deep_backtracking() { let res = resolve(&pkg_id("root"), vec![dep_req("foo", "1")], ®).unwrap(); - assert_that( + assert_contains( &res, - contains(names(&[ + &names(&[ ("root", "1.0.0"), ("foo", "1.0.0"), ("bar", "2.0.0"), ("baz", "1.0.1"), - ])), + ]), ); } @@ -598,16 +588,16 @@ fn resolving_with_sys_crates() { ®, ).unwrap(); - assert_that( + assert_contains( &res, - contains(names(&[ + &names(&[ ("root", "1.0.0"), ("d", "1.0.0"), ("r", "1.0.0"), ("l-sys", "0.9.1"), ("l", "0.9.1"), ("l", "0.10.0"), - ])), + ]), ); } @@ -647,14 +637,14 @@ fn resolving_with_constrained_sibling_backtrack_parent() { let res = resolve(&pkg_id("root"), vec![dep_req("foo", "1")], ®).unwrap(); - assert_that( + assert_contains( &res, - contains(names(&[ + &names(&[ ("root", "1.0.0"), ("foo", "1.0.0"), ("bar", "1.0.0"), ("constrained", "1.0.0"), - ])), + ]), ); } @@ -692,10 +682,7 @@ fn resolving_with_many_equivalent_backtracking() { let res = resolve(&pkg_id("root"), vec![dep_req("level0", "*")], ®).unwrap(); - assert_that( - &res, - contains(names(&[("root", "1.0.0"), ("level0", "1.0.0")])), - ); + assert_contains(&res, &names(&[("root", "1.0.0"), ("level0", "1.0.0")])); // Make sure we have not special case no candidates. reglist.push(pkg!(("constrained", "1.1.0"))); @@ -712,13 +699,13 @@ fn resolving_with_many_equivalent_backtracking() { ®, ).unwrap(); - assert_that( + assert_contains( &res, - contains(names(&[ + &names(&[ ("root", "1.0.0"), ("level0", "1.0.0"), ("constrained", "1.1.0"), - ])), + ]), ); let reg = registry(reglist.clone()); @@ -729,13 +716,13 @@ fn resolving_with_many_equivalent_backtracking() { ®, ).unwrap(); - assert_that( + assert_contains( &res, - contains(names(&[ + &names(&[ ("root", "1.0.0"), (format!("level{}", DEPTH).as_str(), "1.0.0"), ("constrained", "1.0.0"), - ])), + ]), ); let reg = registry(reglist.clone()); @@ -879,9 +866,9 @@ fn resolving_with_constrained_cousins_backtrack() { ®, ).unwrap(); - assert_that( + assert_contains( &res, - contains(names(&[("constrained", "2.0.0"), ("cloaking", "1.0.0")])), + &names(&[("constrained", "2.0.0"), ("cloaking", "1.0.0")]), ); } @@ -919,14 +906,14 @@ fn resolving_with_constrained_sibling_backtrack_activation() { let res = resolve(&pkg_id("root"), vec![dep_req("foo", "1")], ®).unwrap(); - assert_that( + assert_contains( &res, - contains(names(&[ + &names(&[ ("root", "1.0.0"), ("foo", "1.0.0"), ("bar", "1.0.0"), ("constrained", "1.0.60"), - ])), + ]), ); } @@ -965,14 +952,14 @@ fn resolving_with_constrained_sibling_transitive_dep_effects() { let res = resolve(&pkg_id("root"), vec![dep_req("A", "1")], ®).unwrap(); - assert_that( + assert_contains( &res, - contains(names(&[ + &names(&[ ("A", "1.0.0"), ("B", "1.0.0"), ("C", "1.0.0"), ("D", "1.0.105"), - ])), + ]), ); } @@ -1014,12 +1001,8 @@ fn hard_equality() { ®, ).unwrap(); - assert_that( + assert_contains( &res, - contains(names(&[ - ("root", "1.0.0"), - ("foo", "1.0.0"), - ("bar", "1.0.0"), - ])), + &names(&[("root", "1.0.0"), ("foo", "1.0.0"), ("bar", "1.0.0")]), ); } diff --git a/tests/testsuite/run.rs b/tests/testsuite/run.rs index 6866c3c6efd..7f7004f2a04 100644 --- a/tests/testsuite/run.rs +++ b/tests/testsuite/run.rs @@ -1,6 +1,5 @@ use cargo::util::paths::dylib_path_envvar; use support; -use support::hamcrest::{assert_that, existing_file}; use support::{basic_bin_manifest, basic_lib_manifest, path2url, project, Project}; #[test] @@ -18,7 +17,7 @@ fn simple() { dir = path2url(p.root()) )).with_stdout("hello") .run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); } #[test] @@ -726,7 +725,7 @@ fn release_works() { ", dir = path2url(p.root()), )).run(); - assert_that(&p.release_bin("foo"), existing_file()); + assert!(p.release_bin("foo").is_file()); } #[test] diff --git a/tests/testsuite/support/hamcrest.rs b/tests/testsuite/support/hamcrest.rs deleted file mode 100644 index 53d8642f959..00000000000 --- a/tests/testsuite/support/hamcrest.rs +++ /dev/null @@ -1,101 +0,0 @@ -use std::fmt; -use std::marker; -use std::path::Path; - -pub type MatchResult = Result<(), String>; - -pub trait Matcher: fmt::Debug { - fn matches(&self, actual: T) -> Result<(), String>; -} - -pub fn assert_that>(actual: T, matcher: U) { - if let Err(e) = matcher.matches(actual) { - panic!("\nExpected: {:?}\n but: {}", matcher, e) - } -} - -pub fn existing_file() -> ExistingFile { - ExistingFile -} - -#[derive(Debug)] -pub struct ExistingFile; - -impl

Matcher

for ExistingFile -where - P: AsRef, -{ - fn matches(&self, actual: P) -> Result<(), String> { - if actual.as_ref().is_file() { - Ok(()) - } else { - Err(format!("{} was not a file", actual.as_ref().display())) - } - } -} - -pub fn existing_dir() -> ExistingDir { - ExistingDir -} - -#[derive(Debug)] -pub struct ExistingDir; - -impl

Matcher

for ExistingDir -where - P: AsRef, -{ - 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>(matcher: M) -> IsNot { - IsNot { - matcher, - _marker: marker::PhantomData, - } -} - -#[derive(Debug)] -pub struct IsNot { - matcher: M, - _marker: marker::PhantomData, -} - -impl> Matcher for IsNot -where - T: fmt::Debug, -{ - fn matches(&self, actual: T) -> Result<(), String> { - match self.matcher.matches(actual) { - Ok(_) => Err("matched".to_string()), - Err(_) => Ok(()), - } - } -} - -pub fn contains(item: Vec) -> Contains { - Contains(item) -} - -#[derive(Debug)] -pub struct Contains(Vec); - -impl<'a, T> Matcher<&'a Vec> for Contains -where - T: fmt::Debug + PartialEq, -{ - fn matches(&self, actual: &'a Vec) -> Result<(), String> { - for item in self.0.iter() { - if !actual.contains(item) { - return Err(format!("failed to find {:?}", item)); - } - } - Ok(()) - } -} diff --git a/tests/testsuite/support/install.rs b/tests/testsuite/support/install.rs index d768db47d40..9267b57e4f4 100644 --- a/tests/testsuite/support/install.rs +++ b/tests/testsuite/support/install.rs @@ -1,22 +1,27 @@ -use std::fmt; use std::path::{Path, PathBuf}; -use support::hamcrest::{existing_file, MatchResult, Matcher}; - use support::paths; -pub use self::InstalledExe as has_installed_exe; +/// Used by `cargo install` tests to assert an executable binary +/// has been installed. Example usage: +/// +/// assert_has_installed_exe(cargo_home(), "foo"); +pub fn assert_has_installed_exe>(path: P, name: &'static str) { + assert!(check_has_installed_exe(path, name)); +} + +pub fn assert_has_not_installed_exe>(path: P, name: &'static str) { + assert!(!check_has_installed_exe(path, name)); +} + +fn check_has_installed_exe>(path: P, name: &'static str) -> bool { + path.as_ref().join("bin").join(exe(name)).is_file() +} pub fn cargo_home() -> PathBuf { paths::home().join(".cargo") } -/// A `Matcher` used by `cargo install` tests to check if an executable binary -/// has been installed. Example usage: -/// -/// assert_that(cargo_home(), has_installed_exe("foo")); -pub struct InstalledExe(pub &'static str); - pub fn exe(name: &str) -> String { if cfg!(windows) { format!("{}.exe", name) @@ -24,16 +29,3 @@ pub fn exe(name: &str) -> String { name.to_string() } } - -impl> Matcher

for InstalledExe { - fn matches(&self, path: P) -> MatchResult { - let path = path.as_ref().join("bin").join(exe(self.0)); - existing_file().matches(&path) - } -} - -impl fmt::Debug for InstalledExe { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "installed exe `{}`", self.0) - } -} diff --git a/tests/testsuite/support/mod.rs b/tests/testsuite/support/mod.rs index 7eb7eb1fc76..cd7680947e6 100644 --- a/tests/testsuite/support/mod.rs +++ b/tests/testsuite/support/mod.rs @@ -18,8 +18,7 @@ let p = project() If you do not specify a `Cargo.toml` manifest using `file()`, one is automatically created with a project name of `foo` using `basic_manifest()`. -To run cargo, call the `cargo` method and use the `hamcrest` matchers to check -the output. +To run cargo, call the `cargo` method and make assertions on the execution: ``` p.cargo("run --bin foo") @@ -42,10 +41,6 @@ as a home directory instead of your normal home directory. See `support::lines_match` for an explanation of the string pattern matching. -See the `hamcrest` module for other matchers like -`is_not(existing_file(path))`. This is not the actual hamcrest library, but -instead a lightweight subset of matchers that are used in cargo tests. - Browse the `pub` functions in the `support` module for a variety of other helpful utilities. @@ -126,7 +121,6 @@ use cargo::util::{CargoResult, ProcessBuilder, ProcessError, Rustc}; use serde_json::{self, Value}; use url::Url; -use self::hamcrest as ham; use self::paths::CargoPathExt; macro_rules! t { @@ -140,7 +134,6 @@ macro_rules! t { pub mod cross_compile; pub mod git; -pub mod hamcrest; pub mod paths; pub mod publish; pub mod registry; @@ -368,12 +361,12 @@ impl Project { FileBuilder::new(self.root().join(path), body).mk() } - /// Create a `ProcessBuilder` to run a program in the project. + /// Create a `ProcessBuilder` to run a program in the project + /// and wrap it in an Execs to assert on the execution. /// Example: - /// assert_that( - /// p.process(&p.bin("foo")), - /// execs().with_stdout("bar\n"), - /// ); + /// p.process(&p.bin("foo")) + /// .with_stdout("bar\n") + /// .run(); pub fn process>(&self, program: T) -> Execs { let mut p = ::support::process(program); p.cwd(self.root()); @@ -522,6 +515,8 @@ pub fn cargo_exe() -> PathBuf { * */ +pub type MatchResult = Result<(), String>; + #[must_use] #[derive(Clone)] pub struct Execs { @@ -744,7 +739,7 @@ impl Execs { } } - fn match_process(&self, process: &ProcessBuilder) -> ham::MatchResult { + fn match_process(&self, process: &ProcessBuilder) -> MatchResult { println!("running {}", process); let res = if self.stream_output { if env::var("CI").is_ok() { @@ -779,13 +774,13 @@ impl Execs { } } - fn match_output(&self, actual: &Output) -> ham::MatchResult { + fn match_output(&self, actual: &Output) -> MatchResult { self.match_status(actual) .and(self.match_stdout(actual)) .and(self.match_stderr(actual)) } - fn match_status(&self, actual: &Output) -> ham::MatchResult { + fn match_status(&self, actual: &Output) -> MatchResult { match self.expect_exit_code { None => Ok(()), Some(code) if actual.status.code() == Some(code) => Ok(()), @@ -798,7 +793,7 @@ impl Execs { } } - fn match_stdout(&self, actual: &Output) -> ham::MatchResult { + fn match_stdout(&self, actual: &Output) -> MatchResult { self.match_std( self.expect_stdout.as_ref(), &actual.stdout, @@ -926,7 +921,7 @@ impl Execs { Ok(()) } - fn match_stderr(&self, actual: &Output) -> ham::MatchResult { + fn match_stderr(&self, actual: &Output) -> MatchResult { self.match_std( self.expect_stderr.as_ref(), &actual.stderr, @@ -943,7 +938,7 @@ impl Execs { description: &str, extra: &[u8], kind: MatchKind, - ) -> ham::MatchResult { + ) -> MatchResult { let out = match expected { Some(out) => out, None => return Ok(()), @@ -1078,7 +1073,7 @@ impl Execs { } } - fn match_json(&self, expected: &Value, line: &str) -> ham::MatchResult { + fn match_json(&self, expected: &Value, line: &str) -> MatchResult { let actual = match line.parse() { Err(e) => return Err(format!("invalid json, {}:\n`{}`", e, line)), Ok(actual) => actual, diff --git a/tests/testsuite/support/registry.rs b/tests/testsuite/support/registry.rs index 6cbd57430a8..9ae7212d4b7 100644 --- a/tests/testsuite/support/registry.rs +++ b/tests/testsuite/support/registry.rs @@ -109,9 +109,7 @@ pub fn alt_api_url() -> Url { /// "#) /// .build(); /// -/// assert_that( -/// p.cargo("run"), -/// execs().with_stdout("24")); +/// p.cargo("run").with_stdout("24").run(); /// ``` pub struct Package { name: String, diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 908167fbe56..121e1c69427 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -2,7 +2,6 @@ use std::fs::File; use std::io::prelude::*; use cargo; -use support::hamcrest::{assert_that, existing_file, is_not}; use support::paths::CargoPathExt; use support::registry::Package; use support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, cargo_exe, project}; @@ -30,7 +29,7 @@ fn cargo_test_simple() { ).build(); p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).with_stdout("hello\n").run(); @@ -133,7 +132,7 @@ fn cargo_test_overflow_checks() { ).build(); p.cargo("build --release").run(); - assert_that(&p.release_bin("foo"), existing_file()); + assert!(p.release_bin("foo").is_file()); p.process(&p.release_bin("foo")).with_stdout("").run(); } @@ -215,7 +214,7 @@ fn cargo_test_failing_test_in_bin() { ).build(); p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).with_stdout("hello\n").run(); @@ -260,7 +259,7 @@ fn cargo_test_failing_test_in_test() { ).build(); p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); p.process(&p.bin("foo")).with_stdout("hello\n").run(); @@ -1697,8 +1696,8 @@ fn example_bin_same_name() { dir = p.url() )).run(); - assert_that(&p.bin("foo"), is_not(existing_file())); - assert_that(&p.bin("examples/foo"), existing_file()); + assert!(!p.bin("foo").is_file()); + assert!(p.bin("examples/foo").is_file()); p.process(&p.bin("examples/foo")) .with_stdout("example\n") @@ -1712,7 +1711,7 @@ fn example_bin_same_name() { [RUNNING] [..]", ).with_stdout("bin") .run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); } #[test] @@ -1724,10 +1723,10 @@ fn test_with_example_twice() { println!("first"); p.cargo("test -v").run(); - assert_that(&p.bin("examples/foo"), existing_file()); + assert!(p.bin("examples/foo").is_file()); println!("second"); p.cargo("test -v").run(); - assert_that(&p.bin("examples/foo"), existing_file()); + assert!(p.bin("examples/foo").is_file()); } #[test] @@ -1778,11 +1777,11 @@ fn bin_is_preserved() { .build(); p.cargo("build -v").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); println!("testing"); p.cargo("test -v").run(); - assert_that(&p.bin("foo"), existing_file()); + assert!(p.bin("foo").is_file()); } #[test] diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index 1fc0c112fd7..2ae838d047e 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -2,7 +2,6 @@ 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::registry::Package; use support::sleep_ms; use support::{basic_lib_manifest, basic_manifest, git, project}; @@ -35,15 +34,15 @@ fn simple_explicit() { let p = p.build(); p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("bar"), is_not(existing_file())); + assert!(p.bin("foo").is_file()); + assert!(!p.bin("bar").is_file()); p.cargo("build").cwd(p.root().join("bar")).run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("bar"), existing_file()); + assert!(p.bin("foo").is_file()); + assert!(p.bin("bar").is_file()); - assert_that(&p.root().join("Cargo.lock"), existing_file()); - assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file())); + assert!(p.root().join("Cargo.lock").is_file()); + assert!(!p.root().join("bar/Cargo.lock").is_file()); } #[test] @@ -75,8 +74,8 @@ fn simple_explicit_default_members() { let p = p.build(); p.cargo("build").run(); - assert_that(&p.bin("bar"), existing_file()); - assert_that(&p.bin("foo"), is_not(existing_file())); + assert!(p.bin("bar").is_file()); + assert!(!p.bin("foo").is_file()); } #[test] @@ -99,15 +98,15 @@ fn inferred_root() { let p = p.build(); p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("bar"), is_not(existing_file())); + assert!(p.bin("foo").is_file()); + assert!(!p.bin("bar").is_file()); p.cargo("build").cwd(p.root().join("bar")).run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("bar"), existing_file()); + assert!(p.bin("foo").is_file()); + assert!(p.bin("bar").is_file()); - assert_that(&p.root().join("Cargo.lock"), existing_file()); - assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file())); + assert!(p.root().join("Cargo.lock").is_file()); + assert!(!p.root().join("bar/Cargo.lock").is_file()); } #[test] @@ -133,15 +132,15 @@ fn inferred_path_dep() { let p = p.build(); p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("bar"), is_not(existing_file())); + assert!(p.bin("foo").is_file()); + assert!(!p.bin("bar").is_file()); p.cargo("build").cwd(p.root().join("bar")).run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("bar"), existing_file()); + assert!(p.bin("foo").is_file()); + assert!(p.bin("bar").is_file()); - assert_that(&p.root().join("Cargo.lock"), existing_file()); - assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file())); + assert!(p.root().join("Cargo.lock").is_file()); + assert!(!p.root().join("bar/Cargo.lock").is_file()); } #[test] @@ -180,23 +179,23 @@ fn transitive_path_dep() { let p = p.build(); p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("bar"), is_not(existing_file())); - assert_that(&p.bin("baz"), is_not(existing_file())); + assert!(p.bin("foo").is_file()); + assert!(!p.bin("bar").is_file()); + assert!(!p.bin("baz").is_file()); p.cargo("build").cwd(p.root().join("bar")).run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("bar"), existing_file()); - assert_that(&p.bin("baz"), is_not(existing_file())); + assert!(p.bin("foo").is_file()); + assert!(p.bin("bar").is_file()); + assert!(!p.bin("baz").is_file()); p.cargo("build").cwd(p.root().join("baz")).run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("bar"), existing_file()); - assert_that(&p.bin("baz"), existing_file()); + assert!(p.bin("foo").is_file()); + assert!(p.bin("bar").is_file()); + assert!(p.bin("baz").is_file()); - assert_that(&p.root().join("Cargo.lock"), existing_file()); - assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file())); - assert_that(&p.root().join("baz/Cargo.lock"), is_not(existing_file())); + assert!(p.root().join("Cargo.lock").is_file()); + assert!(!p.root().join("bar/Cargo.lock").is_file()); + assert!(!p.root().join("baz/Cargo.lock").is_file()); } #[test] @@ -231,8 +230,8 @@ fn parent_pointer_works() { p.cargo("build").cwd(p.root().join("foo")).run(); p.cargo("build").cwd(p.root().join("bar")).run(); - assert_that(&p.root().join("foo/Cargo.lock"), existing_file()); - assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file())); + assert!(p.root().join("foo/Cargo.lock").is_file()); + assert!(!p.root().join("bar/Cargo.lock").is_file()); } #[test] @@ -683,9 +682,9 @@ fn virtual_works() { .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build").cwd(p.root().join("bar")).run(); - assert_that(&p.root().join("Cargo.lock"), existing_file()); - assert_that(&p.bin("bar"), existing_file()); - assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file())); + assert!(p.root().join("Cargo.lock").is_file()); + assert!(p.bin("bar").is_file()); + assert!(!p.root().join("bar/Cargo.lock").is_file()); } #[test] @@ -701,9 +700,9 @@ fn explicit_package_argument_works_with_virtual_manifest() { .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build --package bar").cwd(p.root()).run(); - assert_that(&p.root().join("Cargo.lock"), existing_file()); - assert_that(&p.bin("bar"), existing_file()); - assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file())); + assert!(p.root().join("Cargo.lock").is_file()); + assert!(p.bin("bar").is_file()); + assert!(!p.root().join("bar/Cargo.lock").is_file()); } #[test] @@ -763,8 +762,8 @@ fn virtual_default_members() { .file("baz/src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build").run(); - assert_that(&p.bin("bar"), existing_file()); - assert_that(&p.bin("baz"), is_not(existing_file())); + assert!(p.bin("bar").is_file()); + assert!(!p.bin("baz").is_file()); } #[test] @@ -882,10 +881,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] @@ -1305,18 +1304,18 @@ 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_that(&p.root().join("foo/Cargo.lock"), is_not(existing_file())); - assert_that(&p.root().join("foo/target"), is_not(existing_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("ws/Cargo.lock").is_file()); + assert!(p.root().join("ws/target").is_dir()); + assert!(!p.root().join("foo/Cargo.lock").is_file()); + assert!(!p.root().join("foo/target").is_dir()); + assert!(!p.root().join("bar/Cargo.lock").is_file()); + 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_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("foo/Cargo.lock").is_file()); + assert!(p.root().join("foo/target").is_dir()); + assert!(!p.root().join("bar/Cargo.lock").is_file()); + assert!(!p.root().join("bar/target").is_dir()); } #[test] @@ -1359,19 +1358,13 @@ fn test_path_dependency_under_member() { p.cargo("build").cwd(p.root().join("ws")).run(); - assert_that( - &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/Cargo.lock").is_file()); + assert!(!p.root().join("foo/bar/target").is_dir()); p.cargo("build").cwd(p.root().join("foo/bar")).run(); - assert_that( - &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/Cargo.lock").is_file()); + assert!(!p.root().join("foo/bar/target").is_dir()); } #[test] @@ -1394,9 +1387,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 +1415,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 +1447,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] @@ -1501,31 +1494,25 @@ fn glob_syntax() { let p = p.build(); p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("bar"), is_not(existing_file())); - assert_that(&p.bin("baz"), is_not(existing_file())); + assert!(p.bin("foo").is_file()); + assert!(!p.bin("bar").is_file()); + assert!(!p.bin("baz").is_file()); p.cargo("build").cwd(p.root().join("crates/bar")).run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("bar"), existing_file()); + assert!(p.bin("foo").is_file()); + assert!(p.bin("bar").is_file()); p.cargo("build").cwd(p.root().join("crates/baz")).run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("baz"), existing_file()); + assert!(p.bin("foo").is_file()); + assert!(p.bin("baz").is_file()); p.cargo("build").cwd(p.root().join("crates/qux")).run(); - assert_that(&p.bin("qux"), is_not(existing_file())); + assert!(!p.bin("qux").is_file()); - assert_that(&p.root().join("Cargo.lock"), existing_file()); - assert_that( - &p.root().join("crates/bar/Cargo.lock"), - is_not(existing_file()), - ); - assert_that( - &p.root().join("crates/baz/Cargo.lock"), - is_not(existing_file()), - ); - assert_that(&p.root().join("crates/qux/Cargo.lock"), existing_file()); + assert!(p.root().join("Cargo.lock").is_file()); + assert!(!p.root().join("crates/bar/Cargo.lock").is_file()); + assert!(!p.root().join("crates/baz/Cargo.lock").is_file()); + assert!(p.root().join("crates/qux/Cargo.lock").is_file()); } /*FIXME: This fails because of how workspace.exclude and workspace.members are working. @@ -1569,25 +1556,25 @@ fn glob_syntax_2() { p.build(); p.cargo("build").run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("bar"), is_not(existing_file())); - assert_that(&p.bin("baz"), is_not(existing_file())); + assert!(p.bin("foo").is_file()); + assert!(!p.bin("bar").is_file()); + assert!(!p.bin("baz").is_file()); p.cargo("build").cwd(p.root().join("crates/bar")).run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("bar"), existing_file()); + assert!(p.bin("foo").is_file()); + assert!(p.bin("bar").is_file()); p.cargo("build").cwd(p.root().join("crates/baz")).run(); - assert_that(&p.bin("foo"), existing_file()); - assert_that(&p.bin("baz"), existing_file()); + assert!(p.bin("foo").is_file()); + assert!(p.bin("baz").is_file()); p.cargo("build").cwd(p.root().join("crates/qux")).run(); - assert_that(&p.bin("qux"), is_not(existing_file())); + assert!(!p.bin("qux").is_file()); - assert_that(&p.root().join("Cargo.lock"), existing_file()); - assert_that(&p.root().join("crates/bar/Cargo.lock"), is_not(existing_file())); - assert_that(&p.root().join("crates/baz/Cargo.lock"), is_not(existing_file())); - assert_that(&p.root().join("crates/qux/Cargo.lock"), existing_file()); + assert!(p.root().join("Cargo.lock").is_file()); + assert!(!p.root().join("crates/bar/Cargo.lock").is_file()); + assert!(!p.root().join("crates/baz/Cargo.lock").is_file()); + assert!(p.root().join("crates/qux/Cargo.lock").is_file()); } */ @@ -1687,8 +1674,8 @@ fn dep_used_with_separate_features() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", ).run(); - assert_that(&p.bin("caller1"), existing_file()); - assert_that(&p.bin("caller2"), existing_file()); + assert!(p.bin("caller1").is_file()); + assert!(p.bin("caller2").is_file()); // Build caller1. should build the dep library. Because the features // are different than the full workspace, it rebuilds. @@ -1789,10 +1776,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()); } */