From af4f1392f789c6062a96d681c582b65027ca13d0 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Sat, 18 Aug 2018 15:05:45 +0100 Subject: [PATCH 1/4] Collapse ProcessBuilder::arg calls in tests .. with mutliple calls of: fastmod --accept-all '\.cargo\("([^"]+)"\)\.arg\("([^"]+)"\)' '.cargo("${1} ${2}")' tests/testsuite/ until no changes are left. --- tests/testsuite/bad_config.rs | 32 +++--- tests/testsuite/bench.rs | 30 ++--- tests/testsuite/build.rs | 158 +++++++++++++------------- tests/testsuite/build_auth.rs | 6 +- tests/testsuite/build_lib.rs | 4 +- tests/testsuite/build_script.rs | 136 +++++++++++----------- tests/testsuite/cargo_alias_config.rs | 8 +- tests/testsuite/cargo_features.rs | 2 +- tests/testsuite/cfg.rs | 6 +- tests/testsuite/check.rs | 30 ++--- tests/testsuite/clean.rs | 22 ++-- tests/testsuite/concurrent.rs | 2 +- tests/testsuite/cross_compile.rs | 42 +++---- tests/testsuite/cross_publish.rs | 2 +- tests/testsuite/dep_info.rs | 6 +- tests/testsuite/doc.rs | 40 +++---- tests/testsuite/features.rs | 32 +++--- tests/testsuite/fetch.rs | 4 +- tests/testsuite/freshness.rs | 26 ++--- tests/testsuite/git.rs | 34 +++--- tests/testsuite/local_registry.rs | 2 +- tests/testsuite/lockfile_compat.rs | 4 +- tests/testsuite/metadata.rs | 12 +- tests/testsuite/net_config.rs | 4 +- tests/testsuite/overrides.rs | 6 +- tests/testsuite/package.rs | 28 ++--- tests/testsuite/path.rs | 12 +- tests/testsuite/plugins.rs | 6 +- tests/testsuite/profiles.rs | 10 +- tests/testsuite/rename_deps.rs | 2 +- tests/testsuite/required_features.rs | 80 ++++++------- tests/testsuite/run.rs | 34 +++--- tests/testsuite/rustc.rs | 8 +- tests/testsuite/rustdoc.rs | 8 +- tests/testsuite/rustdocflags.rs | 2 +- tests/testsuite/rustflags.rs | 64 +++++------ tests/testsuite/test.rs | 100 ++++++++-------- tests/testsuite/tool_paths.rs | 4 +- tests/testsuite/update.rs | 4 +- tests/testsuite/workspaces.rs | 6 +- 40 files changed, 509 insertions(+), 509 deletions(-) diff --git a/tests/testsuite/bad_config.rs b/tests/testsuite/bad_config.rs index 749eaf4e8..5df0464bd 100644 --- a/tests/testsuite/bad_config.rs +++ b/tests/testsuite/bad_config.rs @@ -40,7 +40,7 @@ fn bad2() { ) .build(); assert_that( - p.cargo("publish").arg("-v"), + p.cargo("publish -v"), execs().with_status(101).with_stderr( "\ [ERROR] could not load Cargo configuration @@ -76,7 +76,7 @@ fn bad3() { Package::new("foo", "1.0.0").publish(); assert_that( - p.cargo("publish").arg("-v"), + p.cargo("publish -v"), execs().with_status(101).with_stderr( "\ error: failed to update registry [..] @@ -100,7 +100,7 @@ fn bad4() { ) .build(); assert_that( - p.cargo("new").arg("-v").arg("foo"), + p.cargo("new -v foo"), execs().with_status(101).with_stderr( "\ [ERROR] Failed to create project `foo` at `[..]` @@ -127,7 +127,7 @@ fn bad6() { Package::new("foo", "1.0.0").publish(); assert_that( - p.cargo("publish").arg("-v"), + p.cargo("publish -v"), execs().with_status(101).with_stderr( "\ error: failed to update registry [..] @@ -152,7 +152,7 @@ fn bad_cargo_config_jobs() { ) .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_status(101).with_stderr( "\ [ERROR] error in [..].cargo/config: \ @@ -175,7 +175,7 @@ fn default_cargo_config_jobs() { "#, ) .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -190,7 +190,7 @@ fn good_cargo_config_jobs() { "#, ) .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -213,7 +213,7 @@ fn invalid_global_config() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_status(101).with_stderr( "\ [ERROR] could not load Cargo configuration @@ -239,7 +239,7 @@ fn bad_cargo_lock() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_status(101).with_stderr( "\ [ERROR] failed to parse lock file at: [..]Cargo.lock @@ -342,7 +342,7 @@ fn bad_source_in_cargo_lock() { .build(); assert_that( - p.cargo("build").arg("--verbose"), + p.cargo("build --verbose"), execs().with_status(101).with_stderr( "\ [ERROR] failed to parse lock file at: [..] @@ -393,7 +393,7 @@ fn bad_git_dependency() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_status(101).with_stderr( "\ [UPDATING] git repository `file:///` @@ -431,7 +431,7 @@ fn bad_crate_type() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_status(101).with_stderr_contains( "error: failed to run `rustc` to learn about crate-type bad_type information", ), @@ -536,7 +536,7 @@ fn duplicate_example_names() { .build(); assert_that( - p.cargo("build").arg("--example").arg("ex"), + p.cargo("build --example ex"), execs().with_status(101).with_stderr( "\ [ERROR] failed to parse manifest at `[..]` @@ -876,7 +876,7 @@ fn ambiguous_git_reference() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_status(101).with_stderr_contains( "\ [WARNING] dependency (bar) specification is ambiguous. \ @@ -1096,7 +1096,7 @@ fn both_git_and_path_specified() { .build(); assert_that( - foo.cargo("build").arg("-v"), + foo.cargo("build -v"), execs().with_status(101).with_stderr_contains( "\ [WARNING] dependency (bar) specification is ambiguous. \ @@ -1161,7 +1161,7 @@ fn ignored_git_revision() { .build(); assert_that( - foo.cargo("build").arg("-v"), + foo.cargo("build -v"), execs().with_status(101).with_stderr_contains( "\ [WARNING] key `branch` is ignored for dependency (bar). \ diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index 57185adcb..d78b25ccc 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -88,7 +88,7 @@ fn bench_bench_implicit() { .build(); assert_that( - p.cargo("bench").arg("--benches"), + p.cargo("bench --benches"), execs() .with_stderr(format!( "\ @@ -136,7 +136,7 @@ fn bench_bin_implicit() { .build(); assert_that( - p.cargo("bench").arg("--bins"), + p.cargo("bench --bins"), execs() .with_stderr(format!( "\ @@ -174,7 +174,7 @@ fn bench_tarname() { .build(); assert_that( - p.cargo("bench").arg("--bench").arg("bin2"), + p.cargo("bench --bench bin2"), execs() .with_stderr(format!( "\ @@ -252,7 +252,7 @@ fn cargo_bench_verbose() { .build(); assert_that( - p.cargo("bench").arg("-v").arg("hello"), + p.cargo("bench -v hello"), execs() .with_stderr(&format!( "\ @@ -361,7 +361,7 @@ fn cargo_bench_failing_test() { // Force libtest into serial execution so that the test header will be printed. assert_that( - p.cargo("bench").arg("--").arg("--test-threads=1"), + p.cargo("bench -- --test-threads=1"), execs() .with_stdout_contains("test bench_hello ...[..]") .with_stderr_contains(format!( @@ -746,7 +746,7 @@ fn pass_through_command_line() { .build(); assert_that( - p.cargo("bench").arg("bar"), + p.cargo("bench bar"), execs() .with_stderr(&format!( "\ @@ -759,7 +759,7 @@ fn pass_through_command_line() { ); assert_that( - p.cargo("bench").arg("foo"), + p.cargo("bench foo"), execs() .with_stderr( "[FINISHED] release [optimized] target(s) in [..] @@ -1031,7 +1031,7 @@ fn bench_dylib() { .build(); assert_that( - p.cargo("bench").arg("-v"), + p.cargo("bench -v"), execs() .with_stderr(&format!( "\ @@ -1051,7 +1051,7 @@ fn bench_dylib() { p.root().move_into_the_past(); assert_that( - p.cargo("bench").arg("-v"), + p.cargo("bench -v"), execs() .with_stderr(&format!( "\ @@ -1192,7 +1192,7 @@ fn bench_with_examples() { .build(); assert_that( - p.cargo("bench").arg("-v"), + p.cargo("bench -v"), execs() .with_stderr(&format!( "\ @@ -1277,7 +1277,7 @@ fn test_bench_no_run() { .build(); assert_that( - p.cargo("bench").arg("--no-run"), + p.cargo("bench --no-run"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -1420,7 +1420,7 @@ fn test_bench_multiple_packages() { .build(); assert_that( - p.cargo("bench").arg("-p").arg("bar").arg("-p").arg("baz"), + p.cargo("bench -p bar -p baz"), execs() .with_stderr_contains("[RUNNING] target/release/deps/bbaz-[..][EXE]") .with_stdout_contains("test bench_baz ... bench: [..]") @@ -1479,7 +1479,7 @@ fn bench_all_workspace() { .build(); assert_that( - p.cargo("bench").arg("--all"), + p.cargo("bench --all"), execs() .with_stderr_contains("[RUNNING] target/release/deps/bar-[..][EXE]") .with_stdout_contains("test bench_bar ... bench: [..]") @@ -1526,7 +1526,7 @@ fn bench_all_exclude() { .build(); assert_that( - p.cargo("bench").arg("--all").arg("--exclude").arg("baz"), + p.cargo("bench --all --exclude baz"), execs().with_stdout_contains( "\ running 1 test @@ -1581,7 +1581,7 @@ fn bench_all_virtual_manifest() { // The order in which bar and baz are built is not guaranteed assert_that( - p.cargo("bench").arg("--all"), + p.cargo("bench --all"), execs() .with_stderr_contains("[RUNNING] target/release/deps/baz-[..][EXE]") .with_stdout_contains("test bench_baz ... bench: [..]") diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 732447aaa..81bdee05e 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -35,7 +35,7 @@ fn cargo_fail_with_no_stderr() { .file("src/foo.rs", &String::from("refusal")) .build(); assert_that( - p.cargo("build").arg("--message-format=json"), + p.cargo("build --message-format=json"), execs() .with_status(101) .with_stderr_does_not_contain("--- stderr"), @@ -52,14 +52,14 @@ fn cargo_compile_incremental() { .build(); assert_that( - p.cargo("build").arg("-v").env("CARGO_INCREMENTAL", "1"), + p.cargo("build -v").env("CARGO_INCREMENTAL", "1"), execs().with_stderr_contains( "[RUNNING] `rustc [..] -C incremental=[..]/target/debug/incremental[..]`\n", ) ); assert_that( - p.cargo("test").arg("-v").env("CARGO_INCREMENTAL", "1"), + p.cargo("test -v").env("CARGO_INCREMENTAL", "1"), execs().with_stderr_contains( "[RUNNING] `rustc [..] -C incremental=[..]/target/debug/incremental[..]`\n", ) @@ -88,12 +88,12 @@ fn incremental_profile() { .build(); assert_that( - p.cargo("build").arg("-v").env_remove("CARGO_INCREMENTAL"), + p.cargo("build -v").env_remove("CARGO_INCREMENTAL"), execs().with_stderr_does_not_contain("[..]C incremental=[..]"), ); assert_that( - p.cargo("build").arg("-v").env("CARGO_INCREMENTAL", "1"), + p.cargo("build -v").env("CARGO_INCREMENTAL", "1"), execs().with_stderr_contains("[..]C incremental=[..]"), ); @@ -128,13 +128,13 @@ fn incremental_config() { .build(); assert_that( - p.cargo("build").arg("-v").env_remove("CARGO_INCREMENTAL"), + p.cargo("build -v").env_remove("CARGO_INCREMENTAL"), execs() .with_stderr_does_not_contain("[..]C incremental=[..]"), ); assert_that( - p.cargo("build").arg("-v").env("CARGO_INCREMENTAL", "1"), + p.cargo("build -v").env("CARGO_INCREMENTAL", "1"), execs().with_stderr_contains("[..]C incremental=[..]"), ); } @@ -146,7 +146,7 @@ fn cargo_compile_with_workspace_excluded() { .build(); assert_that( - p.cargo("build").arg("--all").arg("--exclude").arg("foo"), + p.cargo("build --all --exclude foo"), execs() .with_stderr_does_not_contain("[..]virtual[..]") .with_stderr_contains("[..]no packages to compile") @@ -917,14 +917,14 @@ fn cargo_compile_with_filename() { .build(); assert_that( - p.cargo("build").arg("--bin").arg("bin.rs"), + p.cargo("build --bin bin.rs"), execs() .with_status(101) .with_stderr("[ERROR] no bin target named `bin.rs`"), ); assert_that( - p.cargo("build").arg("--bin").arg("a.rs"), + p.cargo("build --bin a.rs"), execs().with_status(101).with_stderr( "\ [ERROR] no bin target named `a.rs` @@ -934,14 +934,14 @@ Did you mean `a`?", ); assert_that( - p.cargo("build").arg("--example").arg("example.rs"), + p.cargo("build --example example.rs"), execs() .with_status(101) .with_stderr("[ERROR] no example target named `example.rs`"), ); assert_that( - p.cargo("build").arg("--example").arg("a.rs"), + p.cargo("build --example a.rs"), execs().with_status(101).with_stderr( "\ [ERROR] no example target named `a.rs` @@ -1381,7 +1381,7 @@ fn cargo_default_env_metadata_env_var() { // No metadata on libbar since it's a dylib path dependency assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr(&format!( "\ [COMPILING] bar v0.0.1 ({url}/bar) @@ -1502,7 +1502,7 @@ fn crate_env_vars() { .build(); println!("build"); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); println!("bin"); assert_that( @@ -1512,7 +1512,7 @@ fn crate_env_vars() { ); println!("test"); - assert_that(p.cargo("test").arg("-v"), execs()); + assert_that(p.cargo("test -v"), execs()); } #[test] @@ -1553,7 +1553,7 @@ fn crate_authors_env_vars() { .build(); println!("build"); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); println!("bin"); assert_that( @@ -1563,7 +1563,7 @@ fn crate_authors_env_vars() { ); println!("test"); - assert_that(p.cargo("test").arg("-v"), execs()); + assert_that(p.cargo("test -v"), execs()); } // The tester may already have LD_LIBRARY_PATH=::/foo/bar which leads to a false positive error @@ -1775,7 +1775,7 @@ fn lto_build() { .file("src/main.rs", "fn main() {}") .build(); assert_that( - p.cargo("build").arg("-v").arg("--release"), + p.cargo("build -v --release"), execs().with_stderr(&format!( "\ [COMPILING] test v0.0.0 ({url}) @@ -1800,7 +1800,7 @@ fn verbose_build() { .file("src/lib.rs", "") .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ({url}) @@ -1823,7 +1823,7 @@ fn verbose_release_build() { .file("src/lib.rs", "") .build(); assert_that( - p.cargo("build").arg("-v").arg("--release"), + p.cargo("build -v --release"), execs().with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ({url}) @@ -1875,7 +1875,7 @@ fn verbose_release_build_deps() { .file("foo/src/lib.rs", "") .build(); assert_that( - p.cargo("build").arg("-v").arg("--release"), + p.cargo("build -v --release"), execs().with_stderr(&format!( "\ [COMPILING] foo v0.0.0 ({url}/foo) @@ -1954,7 +1954,7 @@ fn explicit_examples() { ) .build(); - assert_that(p.cargo("test").arg("-v"), execs()); + assert_that(p.cargo("test -v"), execs()); assert_that( process(&p.bin("examples/hello")), execs().with_stdout("Hello, World!\n"), @@ -1988,7 +1988,7 @@ fn non_existing_example() { .build(); assert_that( - p.cargo("test").arg("-v"), + p.cargo("test -v"), execs().with_status(101).with_stderr( "\ [ERROR] failed to parse manifest at `[..]` @@ -2008,7 +2008,7 @@ fn non_existing_binary() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_status(101).with_stderr( "\ [ERROR] failed to parse manifest at `[..]` @@ -2039,7 +2039,7 @@ fn legacy_binary_paths_warnings() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr_contains( "\ [WARNING] path `[..]src/main.rs` was erroneously implicitly accepted for binary `bar`, @@ -2065,7 +2065,7 @@ please set bin.path in Cargo.toml", .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr_contains( "\ [WARNING] path `[..]src/bin/main.rs` was erroneously implicitly accepted for binary `bar`, @@ -2090,7 +2090,7 @@ please set bin.path in Cargo.toml", .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr_contains( "\ [WARNING] path `[..]src/bar.rs` was erroneously implicitly accepted for binary `bar`, @@ -2184,7 +2184,7 @@ fn release_build_ndebug() { ) .build(); - assert_that(p.cargo("build").arg("--release"), execs()); + assert_that(p.cargo("build --release"), execs()); assert_that( process(&p.release_bin("foo")), execs().with_stdout("fast\n"), @@ -2303,7 +2303,7 @@ fn staticlib_rlib_and_bin() { .file("src/main.rs", "extern crate foo; fn main() { foo::foo(); }") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -2517,7 +2517,7 @@ fn bad_cargo_config() { .file(".cargo/config", "this is not valid toml") .build(); assert_that( - foo.cargo("build").arg("-v"), + foo.cargo("build -v"), execs().with_status(101).with_stderr( "\ [ERROR] could not load Cargo configuration @@ -2655,7 +2655,7 @@ fn example_as_lib() { .file("examples/ex.rs", "") .build(); - assert_that(p.cargo("build").arg("--example=ex"), execs()); + assert_that(p.cargo("build --example=ex"), execs()); assert_that(&p.example_lib("ex", "lib"), existing_file()); } @@ -2679,7 +2679,7 @@ fn example_as_rlib() { .file("examples/ex.rs", "") .build(); - assert_that(p.cargo("build").arg("--example=ex"), execs()); + assert_that(p.cargo("build --example=ex"), execs()); assert_that(&p.example_lib("ex", "rlib"), existing_file()); } @@ -2703,7 +2703,7 @@ fn example_as_dylib() { .file("examples/ex.rs", "") .build(); - assert_that(p.cargo("build").arg("--example=ex"), execs()); + assert_that(p.cargo("build --example=ex"), execs()); assert_that(&p.example_lib("ex", "dylib"), existing_file()); } @@ -2731,7 +2731,7 @@ fn example_as_proc_macro() { .file("examples/ex.rs", "#![feature(proc_macro)]") .build(); - assert_that(p.cargo("build").arg("--example=ex"), execs()); + assert_that(p.cargo("build --example=ex"), execs()); assert_that(&p.example_lib("ex", "proc-macro"), existing_file()); } @@ -2769,14 +2769,14 @@ fn compile_then_delete() { .file("src/main.rs", "fn main() {}") .build(); - assert_that(p.cargo("run").arg("-v"), execs()); + assert_that(p.cargo("run -v"), execs()); assert_that(&p.bin("foo"), existing_file()); if cfg!(windows) { // On windows unlinking immediately after running often fails, so sleep sleep_ms(100); } fs::remove_file(&p.bin("foo")).unwrap(); - assert_that(p.cargo("run").arg("-v"), execs()); + assert_that(p.cargo("run -v"), execs()); } #[test] @@ -2816,7 +2816,7 @@ fn transitive_dependencies_not_available() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs() .with_status(101) .with_stderr_contains("[..] can't find crate for `bbbbb`[..]"), @@ -2854,7 +2854,7 @@ fn cyclic_deps_rejected() { .file("a/src/lib.rs", "") .build(); - assert_that(p.cargo("build").arg("-v"), + assert_that(p.cargo("build -v"), execs().with_status(101) .with_stderr( r#"[ERROR] cyclic package dependency: package `a v0.0.1 ([..])` depends on itself. Cycle: @@ -2881,7 +2881,7 @@ fn predictable_filenames() { .file("src/lib.rs", "") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); assert_that(&p.root().join("target/debug/libfoo.rlib"), existing_file()); let dylib_name = format!("{}foo{}", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX); assert_that( @@ -2898,7 +2898,7 @@ fn dashes_to_underscores() { .file("src/main.rs", "extern crate foo_bar; fn main() {}") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); assert_that(&p.bin("foo-bar"), existing_file()); } @@ -2921,7 +2921,7 @@ fn dashes_in_crate_name_bad() { .file("src/main.rs", "extern crate foo_bar; fn main() {}") .build(); - assert_that(p.cargo("build").arg("-v"), execs().with_status(101)); + assert_that(p.cargo("build -v"), execs().with_status(101)); } #[test] @@ -2956,11 +2956,11 @@ fn filtering() { .file("examples/b.rs", "fn main() {}") .build(); - assert_that(p.cargo("build").arg("--lib"), execs()); + assert_that(p.cargo("build --lib"), execs()); assert_that(&p.bin("a"), is_not(existing_file())); assert_that( - p.cargo("build").arg("--bin=a").arg("--example=a"), + p.cargo("build --bin=a --example=a"), execs(), ); assert_that(&p.bin("a"), existing_file()); @@ -2979,7 +2979,7 @@ fn filtering_implicit_bins() { .file("examples/b.rs", "fn main() {}") .build(); - assert_that(p.cargo("build").arg("--bins"), execs()); + assert_that(p.cargo("build --bins"), execs()); assert_that(&p.bin("a"), existing_file()); assert_that(&p.bin("b"), existing_file()); assert_that(&p.bin("examples/a"), is_not(existing_file())); @@ -2996,7 +2996,7 @@ fn filtering_implicit_examples() { .file("examples/b.rs", "fn main() {}") .build(); - assert_that(p.cargo("build").arg("--examples"), execs()); + assert_that(p.cargo("build --examples"), execs()); 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()); @@ -3259,7 +3259,7 @@ fn invalid_spec() { .build(); assert_that( - p.cargo("build").arg("-p").arg("notAValidDep"), + p.cargo("build -p notAValidDep"), execs() .with_status(101) .with_stderr("[ERROR] package id specification `notAValidDep` matched no packages"), @@ -3291,7 +3291,7 @@ fn manifest_with_bom_is_ok() { ) .file("src/lib.rs", "") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -3312,7 +3312,7 @@ fn panic_abort_compiles_with_panic_abort() { .file("src/lib.rs", "") .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs() .with_stderr_contains("[..] -C panic=abort [..]"), ); @@ -3325,14 +3325,14 @@ fn explicit_color_config_is_propagated_to_rustc() { .file("src/lib.rs", "") .build(); assert_that( - p.cargo("build").arg("-v").arg("--color").arg("always"), + p.cargo("build -v --color always"), execs().with_stderr_contains("[..]rustc [..] src/lib.rs --color always[..]"), ); assert_that(p.cargo("clean"), execs()); assert_that( - p.cargo("build").arg("-v").arg("--color").arg("never"), + p.cargo("build -v --color never"), execs().with_stderr( "\ [COMPILING] test v0.0.0 ([..]) @@ -3567,7 +3567,7 @@ fn wrong_message_format_option() { .build(); assert_that( - p.cargo("build").arg("--message-format").arg("XML"), + p.cargo("build --message-format XML"), execs().with_status(1).with_stderr_contains( "\ error: 'XML' isn't a valid value for '--message-format ' @@ -3671,7 +3671,7 @@ fn cargo_build_empty_target() { .build(); assert_that( - p.cargo("build").arg("--target").arg(""), + p.cargo("build --target").arg(""), execs() .with_status(101) .with_stderr_contains("[..] target was empty"), @@ -3700,7 +3700,7 @@ fn build_all_workspace() { .build(); assert_that( - p.cargo("build").arg("--all"), + p.cargo("build --all"), execs().with_stderr( "[..] Compiling bar v0.1.0 ([..])\n\ [..] Compiling foo v0.1.0 ([..])\n\ @@ -3731,7 +3731,7 @@ fn build_all_exclude() { .build(); assert_that( - p.cargo("build").arg("--all").arg("--exclude").arg("baz"), + p.cargo("build --all --exclude baz"), execs() .with_stderr_contains("[..]Compiling foo v0.1.0 [..]") .with_stderr_contains("[..]Compiling bar v0.1.0 [..]") @@ -3769,7 +3769,7 @@ fn build_all_workspace_implicit_examples() { .build(); assert_that( - p.cargo("build").arg("--all").arg("--examples"), + p.cargo("build --all --examples"), execs().with_stderr( "[..] Compiling bar v0.1.0 ([..])\n\ [..] Compiling foo v0.1.0 ([..])\n\ @@ -3804,7 +3804,7 @@ fn build_all_virtual_manifest() { // The order in which bar and baz are built is not guaranteed assert_that( - p.cargo("build").arg("--all"), + p.cargo("build --all"), execs() .with_stderr_contains("[..] Compiling baz v0.1.0 ([..])") .with_stderr_contains("[..] Compiling bar v0.1.0 ([..])") @@ -3863,7 +3863,7 @@ fn build_virtual_manifest_one_project() { .build(); assert_that( - p.cargo("build").arg("-p").arg("bar"), + p.cargo("build -p bar"), execs() .with_stderr_does_not_contain("[..]baz[..]") .with_stderr_contains("[..] Compiling bar v0.1.0 ([..])") @@ -3900,7 +3900,7 @@ fn build_all_virtual_manifest_implicit_examples() { // The order in which bar and baz are built is not guaranteed assert_that( - p.cargo("build").arg("--all").arg("--examples"), + p.cargo("build --all --examples"), execs() .with_stderr_contains("[..] Compiling baz v0.1.0 ([..])") .with_stderr_contains("[..] Compiling bar v0.1.0 ([..])") @@ -3947,7 +3947,7 @@ fn build_all_member_dependency_same_name() { Package::new("a", "0.1.0").publish(); assert_that( - p.cargo("build").arg("--all"), + p.cargo("build --all"), execs().with_stderr( "[..] Updating registry `[..]`\n\ [..] Downloading a v0.1.0 ([..])\n\ @@ -3980,7 +3980,7 @@ fn run_proper_binary() { .build(); assert_that( - p.cargo("run").arg("--bin").arg("other"), + p.cargo("run --bin other"), execs(), ); } @@ -3994,7 +3994,7 @@ fn run_proper_binary_main_rs() { .build(); assert_that( - p.cargo("run").arg("--bin").arg("foo"), + p.cargo("run --bin foo"), execs(), ); } @@ -4019,7 +4019,7 @@ fn run_proper_alias_binary_from_src() { .file("src/bar.rs", r#"fn main() { println!("bar"); }"#) .build(); - assert_that(p.cargo("build").arg("--all"), execs()); + assert_that(p.cargo("build --all"), execs()); assert_that( process(&p.bin("foo")), execs().with_stdout("foo\n"), @@ -4049,7 +4049,7 @@ fn run_proper_alias_binary_main_rs() { .file("src/main.rs", r#"fn main() { println!("main"); }"#) .build(); - assert_that(p.cargo("build").arg("--all"), execs()); + assert_that(p.cargo("build --all"), execs()); assert_that( process(&p.bin("foo")), execs().with_stdout("main\n"), @@ -4069,7 +4069,7 @@ fn run_proper_binary_main_rs_as_foo() { .build(); assert_that( - p.cargo("run").arg("--bin").arg("foo"), + p.cargo("run --bin foo"), execs(), ); } @@ -4203,7 +4203,7 @@ fn deterministic_cfg_flags() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.1.0 [..] @@ -4340,7 +4340,7 @@ fn inferred_tests() { .build(); assert_that( - p.cargo("test").arg("--test=bar").arg("--test=baz"), + p.cargo("test --test=bar --test=baz"), execs(), ); } @@ -4354,7 +4354,7 @@ fn inferred_benchmarks() { .build(); assert_that( - p.cargo("bench").arg("--bench=bar").arg("--bench=baz"), + p.cargo("bench --bench=bar --bench=baz"), execs(), ); } @@ -4381,7 +4381,7 @@ fn target_edition() { .build(); assert_that( - p.cargo("build").arg("-v").masquerade_as_nightly_cargo(), + p.cargo("build -v").masquerade_as_nightly_cargo(), execs() .with_stderr_contains("\ [COMPILING] foo v0.0.1 ([..]) @@ -4411,7 +4411,7 @@ fn target_edition_override() { .build(); assert_that( - p.cargo("build").arg("-v").masquerade_as_nightly_cargo(), + p.cargo("build -v").masquerade_as_nightly_cargo(), execs().with_stderr_contains("\ [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc [..]--edition=2015 [..] @@ -4438,7 +4438,7 @@ fn target_edition_feature_gated() { .build(); assert_that( - p.cargo("build").arg("-v").masquerade_as_nightly_cargo(), + p.cargo("build -v").masquerade_as_nightly_cargo(), execs().with_status(101).with_stderr( "\ error: failed to parse manifest at `[..]` @@ -4464,7 +4464,7 @@ fn same_metadata_different_directory() { .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) .build(); let output = t!(String::from_utf8( - t!(p.cargo("build").arg("-v").exec_with_output()).stderr, + t!(p.cargo("build -v").exec_with_output()).stderr, )); let metadata = output .split_whitespace() @@ -4477,7 +4477,7 @@ fn same_metadata_different_directory() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs() .with_stderr_contains(format!("[..]{}[..]", metadata)), ); @@ -4593,7 +4593,7 @@ fn build_filter_infer_profile() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs() .with_stderr_contains( "\ @@ -4609,7 +4609,7 @@ fn build_filter_infer_profile() { p.root().join("target").rm_rf(); assert_that( - p.cargo("build").arg("-v").arg("--test=t1"), + p.cargo("build -v --test=t1"), execs() .with_stderr_contains( "\ @@ -4628,7 +4628,7 @@ fn build_filter_infer_profile() { p.root().join("target").rm_rf(); assert_that( - p.cargo("build").arg("-v").arg("--bench=b1"), + p.cargo("build -v --bench=b1"), execs() .with_stderr_contains( "\ @@ -4654,7 +4654,7 @@ fn targets_selected_default() { .file("src/main.rs", "fn main() {}") .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs() // bin .with_stderr_contains("\ @@ -4677,7 +4677,7 @@ fn targets_selected_all() { .file("src/main.rs", "fn main() {}") .build(); assert_that( - p.cargo("build").arg("-v").arg("--all-targets"), + p.cargo("build -v --all-targets"), execs() // bin .with_stderr_contains("\ @@ -4700,7 +4700,7 @@ fn all_targets_no_lib() { .file("src/main.rs", "fn main() {}") .build(); assert_that( - p.cargo("build").arg("-v").arg("--all-targets"), + p.cargo("build -v --all-targets"), execs() // bin .with_stderr_contains("\ @@ -4792,7 +4792,7 @@ fn invalid_jobs() { .build(); assert_that( - p.cargo("build").arg("--jobs").arg("over9000"), + p.cargo("build --jobs over9000"), execs() .with_status(1) .with_stderr("error: Invalid value: could not parse `over9000` as a number"), diff --git a/tests/testsuite/build_auth.rs b/tests/testsuite/build_auth.rs index cd87d6e16..ceef34b38 100644 --- a/tests/testsuite/build_auth.rs +++ b/tests/testsuite/build_auth.rs @@ -84,7 +84,7 @@ fn http_auth_offered() { ) .build(); - assert_that(script.cargo("build").arg("-v"), execs()); + assert_that(script.cargo("build -v"), execs()); let script = script.bin("script"); let config = paths::home().join(".gitconfig"); @@ -186,7 +186,7 @@ fn https_something_happens() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs() .with_status(101) .with_stderr_contains(&format!( @@ -243,7 +243,7 @@ fn ssh_something_happens() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs() .with_status(101) .with_stderr_contains(&format!( diff --git a/tests/testsuite/build_lib.rs b/tests/testsuite/build_lib.rs index f3aae097f..2cf15887f 100644 --- a/tests/testsuite/build_lib.rs +++ b/tests/testsuite/build_lib.rs @@ -27,7 +27,7 @@ fn build_lib_only() { .build(); assert_that( - p.cargo("build").arg("--lib").arg("-v"), + p.cargo("build --lib -v"), execs() .with_stderr(verbose_output_for_lib(&p)), ); @@ -41,7 +41,7 @@ fn build_with_no_lib() { .build(); assert_that( - p.cargo("build").arg("--lib"), + p.cargo("build --lib"), execs() .with_status(101) .with_stderr("[ERROR] no library targets found in package `foo`"), diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index c399c98d9..20925a989 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -30,7 +30,7 @@ fn custom_build_script_failed() { .file("build.rs", "fn main() { std::process::exit(101); }") .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_status(101).with_stderr(&format!( "\ [COMPILING] foo v0.5.0 ({url}) @@ -129,7 +129,7 @@ fn custom_build_env_vars() { let p = p.file("bar/build.rs", &file_content).build(); assert_that( - p.cargo("build").arg("--features").arg("bar_feat"), + p.cargo("build --features bar_feat"), execs(), ); } @@ -166,7 +166,7 @@ fn custom_build_env_var_rustc_linker() { // no crate type set => linker never called => build succeeds if and // only if build.rs succeeds, despite linker binary not existing. assert_that( - p.cargo("build").arg("--target").arg(&target), + p.cargo("build --target").arg(&target), execs(), ); } @@ -233,7 +233,7 @@ fn custom_build_script_rustc_flags() { .build(); // TODO: TEST FAILS BECAUSE OF WRONG STDOUT (but otherwise, the build works) - assert_that(p.cargo("build").arg("--verbose"), + assert_that(p.cargo("build --verbose"), execs().with_status(101) .with_stderr(&format!("\ [COMPILING] bar v0.5.0 ({url}) @@ -451,7 +451,7 @@ fn overrides_and_links() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [..] @@ -497,7 +497,7 @@ fn unused_overrides() { ) .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -554,7 +554,7 @@ fn links_passes_env_vars() { ) .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -574,14 +574,14 @@ fn only_rerun_build_script() { .file("build.rs", "fn main() {}") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); p.root().move_into_the_past(); File::create(&p.root().join("some-new-file")).unwrap(); p.root().move_into_the_past(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.5.0 (file://[..]) @@ -652,13 +652,13 @@ fn rebuild_continues_to_pass_env_vars() { ) .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); p.root().move_into_the_past(); File::create(&p.root().join("some-new-file")).unwrap(); p.root().move_into_the_past(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -679,7 +679,7 @@ fn testing_and_such() { .build(); println!("build"); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); p.root().move_into_the_past(); File::create(&p.root().join("src/lib.rs")).unwrap(); @@ -687,7 +687,7 @@ fn testing_and_such() { println!("test"); assert_that( - p.cargo("test").arg("-vj1"), + p.cargo("test -vj1"), execs() .with_stderr( "\ @@ -705,7 +705,7 @@ fn testing_and_such() { println!("doc"); assert_that( - p.cargo("doc").arg("-v"), + p.cargo("doc -v"), execs().with_stderr( "\ [DOCUMENTING] foo v0.5.0 (file://[..]) @@ -790,7 +790,7 @@ fn propagation_of_l_flags() { .build(); assert_that( - p.cargo("build").arg("-v").arg("-j1"), + p.cargo("build -v -j1"), execs().with_stderr_contains( "\ [RUNNING] `rustc --crate-name a [..] -L bar[..]-L foo[..]` @@ -866,7 +866,7 @@ fn propagation_of_l_flags_new() { .build(); assert_that( - p.cargo("build").arg("-v").arg("-j1"), + p.cargo("build -v -j1"), execs().with_stderr_contains( "\ [RUNNING] `rustc --crate-name a [..] -L bar[..]-L foo[..]` @@ -906,7 +906,7 @@ fn build_deps_simple() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] a v0.5.0 (file://[..]) @@ -954,7 +954,7 @@ fn build_deps_not_for_normal() { .build(); assert_that( - p.cargo("build").arg("-v").arg("--target").arg(&target), + p.cargo("build -v --target").arg(&target), execs() .with_status(101) .with_stderr_contains("[..]can't find crate for `aaaaa`[..]") @@ -1017,7 +1017,7 @@ fn build_cmd_with_a_build_cmd() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] b v0.5.0 (file://[..]) @@ -1077,7 +1077,7 @@ fn out_dir_is_preserved() { .build(); // Make the file - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); p.root().move_into_the_past(); // Change to asserting that it's there @@ -1095,14 +1095,14 @@ fn out_dir_is_preserved() { ) .unwrap(); p.root().move_into_the_past(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); // Run a fresh build where file should be preserved - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); // One last time to make sure it's still there. File::create(&p.root().join("foo")).unwrap(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -1130,7 +1130,7 @@ fn output_separate_lines() { ) .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_status(101).with_stderr_contains( "\ [COMPILING] foo v0.5.0 (file://[..]) @@ -1168,7 +1168,7 @@ fn output_separate_lines_new() { ) .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_status(101).with_stderr_contains( "\ [COMPILING] foo v0.5.0 (file://[..]) @@ -1264,7 +1264,7 @@ fn release_with_build_script() { .build(); assert_that( - p.cargo("build").arg("-v").arg("--release"), + p.cargo("build -v --release"), execs(), ); } @@ -1285,7 +1285,7 @@ fn build_script_only() { .file("build.rs", r#"fn main() {}"#) .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_status(101).with_stderr( "\ [ERROR] failed to parse manifest at `[..]` @@ -1344,7 +1344,7 @@ fn shared_dep_with_a_build_script() { ) .file("b/src/lib.rs", "") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -1716,7 +1716,7 @@ fn cfg_feedback() { .file("src/main.rs", "#[cfg(foo)] fn main() {}") .file("build.rs", r#"fn main() { println!("cargo:rustc-cfg=foo"); }"#) .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -1749,7 +1749,7 @@ fn cfg_override() { ) .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -1791,7 +1791,7 @@ fn cfg_test() { .file("tests/test.rs", "#[cfg(foo)] #[test] fn test_bar() {}") .build(); assert_that( - p.cargo("test").arg("-v"), + p.cargo("test -v"), execs() .with_stderr(format!( "\ @@ -1907,7 +1907,7 @@ fn cfg_override_test() { .file("tests/test.rs", "#[cfg(foo)] #[test] fn test_bar() {}") .build(); assert_that( - p.cargo("test").arg("-v"), + p.cargo("test -v"), execs() .with_stderr(format!( "\ @@ -2009,9 +2009,9 @@ fn env_build() { ) .file("build.rs", r#"fn main() { println!("cargo:rustc-env=FOO=foo"); }"#) .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); assert_that( - p.cargo("run").arg("-v"), + p.cargo("run -v"), execs().with_stdout("foo\n"), ); } @@ -2044,7 +2044,7 @@ fn env_test() { ) .build(); assert_that( - p.cargo("test").arg("-v"), + p.cargo("test -v"), execs() .with_stderr(format!( "\ @@ -2089,7 +2089,7 @@ fn env_doc() { .file("build.rs", r#"fn main() { println!("cargo:rustc-env=FOO=foo"); }"#, ) .build(); - assert_that(p.cargo("doc").arg("-v"), execs()); + assert_that(p.cargo("doc -v"), execs()); } #[test] @@ -2143,7 +2143,7 @@ fn flags_go_into_tests() { .build(); assert_that( - p.cargo("test").arg("-v").arg("--test=foo"), + p.cargo("test -v --test=foo"), execs() .with_stderr( "\ @@ -2163,7 +2163,7 @@ fn flags_go_into_tests() { ); assert_that( - p.cargo("test").arg("-v").arg("-pb").arg("--lib"), + p.cargo("test -v -pb --lib"), execs() .with_stderr( "\ @@ -2242,7 +2242,7 @@ fn diamond_passes_args_only_once() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] c v0.5.0 ([..] @@ -2289,7 +2289,7 @@ fn adding_an_override_invalidates() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.5.0 ([..] @@ -2315,7 +2315,7 @@ fn adding_an_override_invalidates() { .unwrap(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.5.0 ([..] @@ -2356,7 +2356,7 @@ fn changing_an_override_invalidates() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.5.0 ([..] @@ -2380,7 +2380,7 @@ fn changing_an_override_invalidates() { .unwrap(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.5.0 ([..] @@ -2424,7 +2424,7 @@ fn fresh_builds_possible_with_link_libs() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.5.0 ([..] @@ -2482,7 +2482,7 @@ fn fresh_builds_possible_with_multiple_metadata_overrides() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.5.0 ([..] @@ -2530,12 +2530,12 @@ fn rebuild_only_on_explicit_paths() { ) .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); // files don't exist, so should always rerun if they don't exist println!("run without"); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.5.0 ([..]) @@ -2553,7 +2553,7 @@ fn rebuild_only_on_explicit_paths() { // now the exist, so run once, catch the mtime, then shouldn't run again println!("run with"); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.5.0 ([..]) @@ -2566,7 +2566,7 @@ fn rebuild_only_on_explicit_paths() { println!("run with2"); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [FRESH] foo v0.5.0 ([..]) @@ -2581,7 +2581,7 @@ fn rebuild_only_on_explicit_paths() { println!("run baz"); File::create(p.root().join("baz")).unwrap(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [FRESH] foo v0.5.0 ([..]) @@ -2594,7 +2594,7 @@ fn rebuild_only_on_explicit_paths() { println!("run foo change"); File::create(p.root().join("foo")).unwrap(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.5.0 ([..]) @@ -2609,7 +2609,7 @@ fn rebuild_only_on_explicit_paths() { println!("run foo delete"); fs::remove_file(p.root().join("bar")).unwrap(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.5.0 ([..]) @@ -2659,7 +2659,7 @@ fn doctest_receives_build_link_args() { .build(); assert_that( - p.cargo("test").arg("-v"), + p.cargo("test -v"), execs().with_stderr_contains( "[RUNNING] `rustdoc --test [..] --crate-name foo [..]-L native=bar[..]`", ), @@ -2714,7 +2714,7 @@ fn please_respect_the_dag() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs() .with_stderr_contains("[RUNNING] `rustc [..] -L native=foo -L native=bar[..]`"), ); @@ -2754,7 +2754,7 @@ fn non_utf8_output() { .file("src/main.rs", "#[cfg(foo)] fn main() {}") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -2794,7 +2794,7 @@ fn custom_target_dir() { .file("a/src/lib.rs", "") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -2851,7 +2851,7 @@ fn panic_abort_with_build_scripts() { .build(); assert_that( - p.cargo("build").arg("-v").arg("--release"), + p.cargo("build -v --release"), execs(), ); @@ -2889,7 +2889,7 @@ fn warnings_emitted() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.5.0 ([..]) @@ -2946,7 +2946,7 @@ fn warnings_hidden_for_upstream() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [UPDATING] registry `[..]` @@ -3005,7 +3005,7 @@ fn warnings_printed_on_vv() { .build(); assert_that( - p.cargo("build").arg("-vv"), + p.cargo("build -vv"), execs().with_stderr( "\ [UPDATING] registry `[..]` @@ -3052,7 +3052,7 @@ fn output_shows_on_vv() { .build(); assert_that( - p.cargo("build").arg("-vv"), + p.cargo("build -vv"), execs().with_stdout("stdout").with_stderr( "\ [COMPILING] foo v0.5.0 ([..]) @@ -3104,7 +3104,7 @@ fn links_with_dots() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs() .with_stderr_contains("[RUNNING] `rustc --crate-name foo [..] [..] -L foo[..]`"), ); @@ -3220,15 +3220,15 @@ fn switch_features_rerun() { .build(); assert_that( - p.cargo("run").arg("-v").arg("--features=foo"), + p.cargo("run -v --features=foo"), execs().with_stdout("foo\n"), ); assert_that( - p.cargo("run").arg("-v"), + p.cargo("run -v"), execs().with_stdout("bar\n"), ); assert_that( - p.cargo("run").arg("-v").arg("--features=foo"), + p.cargo("run -v --features=foo"), execs().with_stdout("foo\n"), ); } @@ -3256,7 +3256,7 @@ fn assume_build_script_when_build_rs_present() { ) .build(); - assert_that(p.cargo("run").arg("-v"), execs()); + assert_that(p.cargo("run -v"), execs()); } #[test] @@ -3292,7 +3292,7 @@ fn if_build_set_to_false_dont_treat_build_rs_as_build_script() { ) .build(); - assert_that(p.cargo("run").arg("-v"), execs()); + assert_that(p.cargo("run -v"), execs()); } #[test] @@ -3405,7 +3405,7 @@ fn deterministic_rustc_dependency_flags() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr_contains( "\ [RUNNING] `rustc --crate-name foo [..] -L native=test1 -L native=test2 \ diff --git a/tests/testsuite/cargo_alias_config.rs b/tests/testsuite/cargo_alias_config.rs index f33391d62..30689749d 100644 --- a/tests/testsuite/cargo_alias_config.rs +++ b/tests/testsuite/cargo_alias_config.rs @@ -16,7 +16,7 @@ fn alias_incorrect_config_type() { .build(); assert_that( - p.cargo("b-cargo-test").arg("-v"), + p.cargo("b-cargo-test -v"), execs().with_status(101).with_stderr_contains( "\ [ERROR] invalid configuration for key `alias.b-cargo-test` @@ -40,7 +40,7 @@ fn alias_default_config_overrides_config() { .build(); assert_that( - p.cargo("b").arg("-v"), + p.cargo("b -v"), execs() .with_stderr_contains("[COMPILING] foo v0.5.0 [..]"), ); @@ -111,7 +111,7 @@ fn alias_list_test() { .build(); assert_that( - p.cargo("b-cargo-test").arg("-v"), + p.cargo("b-cargo-test -v"), execs() .with_stderr_contains("[COMPILING] foo v0.5.0 [..]") .with_stderr_contains("[RUNNING] `rustc --crate-name [..]"), @@ -133,7 +133,7 @@ fn alias_with_flags_config() { .build(); assert_that( - p.cargo("b-cargo-test").arg("-v"), + p.cargo("b-cargo-test -v"), execs() .with_stderr_contains("[COMPILING] foo v0.5.0 [..]") .with_stderr_contains("[RUNNING] `rustc --crate-name foo [..]"), diff --git a/tests/testsuite/cargo_features.rs b/tests/testsuite/cargo_features.rs index d8a5ff1c8..cbb1a9e4f 100644 --- a/tests/testsuite/cargo_features.rs +++ b/tests/testsuite/cargo_features.rs @@ -273,7 +273,7 @@ fn z_flags_rejected() { .file("src/lib.rs", "") .build(); assert_that( - p.cargo("build").arg("-Zprint-im-a-teapot"), + p.cargo("build -Zprint-im-a-teapot"), execs() .with_status(101) .with_stderr("error: the `-Z` flag is only accepted on the nightly channel of Cargo"), diff --git a/tests/testsuite/cfg.rs b/tests/testsuite/cfg.rs index 2c733a54f..871d7810d 100644 --- a/tests/testsuite/cfg.rs +++ b/tests/testsuite/cfg.rs @@ -162,7 +162,7 @@ fn cfg_easy() { .file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) .file("b/src/lib.rs", "") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -383,7 +383,7 @@ fn multiple_match_ok() { .file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) .file("b/src/lib.rs", "") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -405,7 +405,7 @@ fn any_ok() { .file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) .file("b/src/lib.rs", "") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } // https://github.com/rust-lang/cargo/issues/5313 diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index c847ff42e..fdf7efba6 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -185,7 +185,7 @@ fn issue_3418() { .build(); assert_that( - foo.cargo("check").arg("-v"), + foo.cargo("check -v"), execs() .with_stderr_contains("[..] --emit=dep-info,metadata [..]"), ); @@ -384,7 +384,7 @@ fn check_all() { .build(); assert_that( - p.cargo("check").arg("--all").arg("-v"), + p.cargo("check --all -v"), execs() .with_stderr_contains("[..] --crate-name foo src/lib.rs [..]") .with_stderr_contains("[..] --crate-name foo src/main.rs [..]") @@ -410,7 +410,7 @@ fn check_virtual_all_implied() { .build(); assert_that( - p.cargo("check").arg("-v"), + p.cargo("check -v"), execs() .with_stderr_contains("[..] --crate-name bar bar/src/lib.rs [..]") .with_stderr_contains("[..] --crate-name baz baz/src/lib.rs [..]"), @@ -428,7 +428,7 @@ fn targets_selected_default() { .build(); assert_that( - foo.cargo("check").arg("-v"), + foo.cargo("check -v"), execs() .with_stderr_contains("[..] --crate-name foo src/lib.rs [..]") .with_stderr_contains("[..] --crate-name foo src/main.rs [..]") @@ -449,7 +449,7 @@ fn targets_selected_all() { .build(); assert_that( - foo.cargo("check").arg("--all-targets").arg("-v"), + foo.cargo("check --all-targets -v"), execs() .with_stderr_contains("[..] --crate-name foo src/lib.rs [..]") .with_stderr_contains("[..] --crate-name foo src/main.rs [..]") @@ -478,7 +478,7 @@ fn check_unit_test_profile() { assert_that(foo.cargo("check"), execs()); assert_that( - foo.cargo("check").arg("--profile").arg("test"), + foo.cargo("check --profile test"), execs() .with_status(101) .with_stderr_contains("[..]badtext[..]"), @@ -555,7 +555,7 @@ fn check_filters() { ); p.root().join("target").rm_rf(); assert_that( - p.cargo("check").arg("--tests").arg("-v"), + p.cargo("check --tests -v"), execs() .with_stderr_contains("[..] --crate-name foo src/lib.rs [..] --test [..]") .with_stderr_contains("[..] --crate-name foo src/lib.rs --crate-type lib [..]") @@ -573,7 +573,7 @@ fn check_filters() { ); p.root().join("target").rm_rf(); assert_that( - p.cargo("check").arg("--test").arg("t1").arg("-v"), + p.cargo("check --test t1 -v"), execs() .with_stderr_contains("[..]unused_normal_lib[..]") .with_stderr_contains("[..]unused_unit_t1[..]") @@ -587,7 +587,7 @@ fn check_filters() { ); p.root().join("target").rm_rf(); assert_that( - p.cargo("check").arg("--all-targets").arg("-v"), + p.cargo("check --all-targets -v"), execs() .with_stderr_contains("[..]unused_normal_lib[..]") .with_stderr_contains("[..]unused_normal_bin[..]") @@ -624,7 +624,7 @@ fn check_artifacts() { ); p.root().join("target").rm_rf(); - assert_that(p.cargo("check").arg("--lib"), execs()); + assert_that(p.cargo("check --lib"), execs()); assert_that(&p.root().join("target/debug/libfoo.rmeta"), existing_file()); assert_that( &p.root().join("target/debug/libfoo.rlib"), @@ -637,7 +637,7 @@ fn check_artifacts() { p.root().join("target").rm_rf(); assert_that( - p.cargo("check").arg("--bin").arg("foo"), + p.cargo("check --bin foo"), execs(), ); if is_nightly() { @@ -657,7 +657,7 @@ fn check_artifacts() { p.root().join("target").rm_rf(); assert_that( - p.cargo("check").arg("--test").arg("t1"), + p.cargo("check --test t1"), execs(), ); assert_that( @@ -681,7 +681,7 @@ fn check_artifacts() { p.root().join("target").rm_rf(); assert_that( - p.cargo("check").arg("--example").arg("ex1"), + p.cargo("check --example ex1"), execs(), ); assert_that( @@ -699,7 +699,7 @@ fn check_artifacts() { p.root().join("target").rm_rf(); assert_that( - p.cargo("check").arg("--bench").arg("b1"), + p.cargo("check --bench b1"), execs(), ); assert_that( @@ -780,7 +780,7 @@ fn proc_macro() { ) .build(); assert_that( - p.cargo("check").arg("-v").env("RUST_LOG", "cargo=trace"), + p.cargo("check -v").env("RUST_LOG", "cargo=trace"), execs(), ); } diff --git a/tests/testsuite/clean.rs b/tests/testsuite/clean.rs index 16fe882f8..9adf825dc 100644 --- a/tests/testsuite/clean.rs +++ b/tests/testsuite/clean.rs @@ -105,23 +105,23 @@ fn clean_release() { .file("a/src/lib.rs", "") .build(); - assert_that(p.cargo("build").arg("--release"), execs()); + assert_that(p.cargo("build --release"), execs()); assert_that( - p.cargo("clean").arg("-p").arg("foo"), + p.cargo("clean -p foo"), execs(), ); assert_that( - p.cargo("build").arg("--release"), + p.cargo("build --release"), execs().with_stdout(""), ); assert_that( - p.cargo("clean").arg("-p").arg("foo").arg("--release"), + p.cargo("clean -p foo --release"), execs(), ); assert_that( - p.cargo("build").arg("--release"), + p.cargo("build --release"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -157,7 +157,7 @@ fn clean_doc() { assert_that(doc_path, existing_dir()); - assert_that(p.cargo("clean").arg("--doc"), execs()); + assert_that(p.cargo("clean --doc"), execs()); assert_that(doc_path, is_not(existing_dir())); assert_that(p.build_dir(), existing_dir()); @@ -198,11 +198,11 @@ fn build_script() { assert_that(p.cargo("build").env("FIRST", "1"), execs()); assert_that( - p.cargo("clean").arg("-p").arg("foo"), + p.cargo("clean -p foo"), execs(), ); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -244,7 +244,7 @@ fn clean_git() { assert_that(p.cargo("build"), execs()); assert_that( - p.cargo("clean").arg("-p").arg("dep"), + p.cargo("clean -p dep"), execs().with_stdout(""), ); assert_that(p.cargo("build"), execs()); @@ -272,7 +272,7 @@ fn registry() { assert_that(p.cargo("build"), execs()); assert_that( - p.cargo("clean").arg("-p").arg("bar"), + p.cargo("clean -p bar"), execs().with_stdout(""), ); assert_that(p.cargo("build"), execs()); @@ -299,7 +299,7 @@ fn clean_verbose() { assert_that(p.cargo("build"), execs()); assert_that( - p.cargo("clean").arg("-p").arg("bar").arg("--verbose"), + p.cargo("clean -p bar --verbose"), execs().with_stderr( "\ [REMOVING] [..] diff --git a/tests/testsuite/concurrent.rs b/tests/testsuite/concurrent.rs index 8983aace3..a2b5c2d59 100644 --- a/tests/testsuite/concurrent.rs +++ b/tests/testsuite/concurrent.rs @@ -445,7 +445,7 @@ fn debug_release_ok() { fs::remove_dir_all(p.root().join("target")).unwrap(); let mut a = p.cargo("build").build_command(); - let mut b = p.cargo("build").arg("--release").build_command(); + let mut b = p.cargo("build --release").build_command(); a.stdout(Stdio::piped()).stderr(Stdio::piped()); b.stdout(Stdio::piped()).stderr(Stdio::piped()); let a = a.spawn().unwrap(); diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs index 630c7651f..b4b66b197 100644 --- a/tests/testsuite/cross_compile.rs +++ b/tests/testsuite/cross_compile.rs @@ -47,7 +47,7 @@ fn simple_cross() { let target = cross_compile::alternate(); assert_that( - p.cargo("build").arg("--target").arg(&target).arg("-v"), + p.cargo("build --target").arg(&target).arg("-v"), execs(), ); assert_that(&p.target_bin(&target, "foo"), existing_file()); @@ -111,7 +111,7 @@ fn simple_cross_config() { .build(); let target = cross_compile::alternate(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); assert_that(&p.target_bin(&target, "foo"), existing_file()); assert_that( @@ -148,7 +148,7 @@ fn simple_deps() { let target = cross_compile::alternate(); assert_that( - p.cargo("build").arg("--target").arg(&target), + p.cargo("build --target").arg(&target), execs(), ); assert_that(&p.target_bin(&target, "foo"), existing_file()); @@ -244,7 +244,7 @@ fn plugin_deps() { let target = cross_compile::alternate(); assert_that( - foo.cargo("build").arg("--target").arg(&target), + foo.cargo("build --target").arg(&target), execs(), ); assert_that(&foo.target_bin(&target, "foo"), existing_file()); @@ -347,12 +347,12 @@ fn plugin_to_the_max() { let target = cross_compile::alternate(); assert_that( - foo.cargo("build").arg("--target").arg(&target).arg("-v"), + foo.cargo("build --target").arg(&target).arg("-v"), execs(), ); println!("second"); assert_that( - foo.cargo("build").arg("-v").arg("--target").arg(&target), + foo.cargo("build -v --target").arg(&target), execs(), ); assert_that(&foo.target_bin(&target, "foo"), existing_file()); @@ -398,7 +398,7 @@ fn linker_and_ar() { .build(); assert_that( - p.cargo("build").arg("--target").arg(&target).arg("-v"), + p.cargo("build --target").arg(&target).arg("-v"), execs().with_status(101).with_stderr_contains(&format!( "\ [COMPILING] foo v0.5.0 ({url}) @@ -503,7 +503,7 @@ fn plugin_with_extra_dylib_dep() { let target = cross_compile::alternate(); assert_that( - foo.cargo("build").arg("--target").arg(&target), + foo.cargo("build --target").arg(&target), execs(), ); } @@ -557,7 +557,7 @@ fn cross_tests() { let target = cross_compile::alternate(); assert_that( - p.cargo("test").arg("--target").arg(&target), + p.cargo("test --target").arg(&target), execs() .with_stderr(&format!( "\ @@ -610,7 +610,7 @@ fn no_cross_doctests() { println!("b"); let target = cross_compile::host(); assert_that( - p.cargo("test").arg("--target").arg(&target), + p.cargo("test --target").arg(&target), execs().with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ({foo}) @@ -626,7 +626,7 @@ fn no_cross_doctests() { println!("c"); let target = cross_compile::alternate(); assert_that( - p.cargo("test").arg("--target").arg(&target), + p.cargo("test --target").arg(&target), execs().with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ({foo}) @@ -662,7 +662,7 @@ fn simple_cargo_run() { let target = cross_compile::alternate(); assert_that( - p.cargo("run").arg("--target").arg(&target), + p.cargo("run --target").arg(&target), execs(), ); } @@ -715,7 +715,7 @@ fn cross_with_a_build_script() { .build(); assert_that( - p.cargo("build").arg("--target").arg(&target).arg("-v"), + p.cargo("build --target").arg(&target).arg("-v"), execs().with_stderr(&format!( "\ [COMPILING] foo v0.0.0 (file://[..]) @@ -814,7 +814,7 @@ fn build_script_needed_for_host_and_target() { .build(); assert_that( - p.cargo("build").arg("--target").arg(&target).arg("-v"), + p.cargo("build --target").arg(&target).arg("-v"), execs() .with_stderr_contains(&format!( "[COMPILING] d1 v0.0.0 ({url}/d1)", @@ -896,7 +896,7 @@ fn build_deps_for_the_right_arch() { let target = cross_compile::alternate(); assert_that( - p.cargo("build").arg("--target").arg(&target).arg("-v"), + p.cargo("build --target").arg(&target).arg("-v"), execs(), ); } @@ -950,7 +950,7 @@ fn build_script_only_host() { let target = cross_compile::alternate(); assert_that( - p.cargo("build").arg("--target").arg(&target).arg("-v"), + p.cargo("build --target").arg(&target).arg("-v"), execs(), ); } @@ -1048,7 +1048,7 @@ fn build_script_with_platform_specific_dependencies() { .build(); assert_that( - p.cargo("build").arg("-v").arg("--target").arg(&target), + p.cargo("build -v --target").arg(&target), execs().with_stderr(&format!( "\ [COMPILING] d2 v0.0.0 ([..]) @@ -1115,7 +1115,7 @@ fn platform_specific_dependencies_do_not_leak() { .build(); assert_that( - p.cargo("build").arg("-v").arg("--target").arg(&target), + p.cargo("build -v --target").arg(&target), execs() .with_status(101) .with_stderr_contains("[..] can't find crate for `d2`[..]"), @@ -1204,9 +1204,9 @@ fn platform_specific_variables_reflected_in_build_scripts() { .file("d2/src/lib.rs", "") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); assert_that( - p.cargo("build").arg("-v").arg("--target").arg(&target), + p.cargo("build -v --target").arg(&target), execs(), ); } @@ -1284,7 +1284,7 @@ fn cross_test_dylib() { .build(); assert_that( - p.cargo("test").arg("--target").arg(&target), + p.cargo("test --target").arg(&target), execs() .with_stderr(&format!( "\ diff --git a/tests/testsuite/cross_publish.rs b/tests/testsuite/cross_publish.rs index d1053a6ec..cff23e9f6 100644 --- a/tests/testsuite/cross_publish.rs +++ b/tests/testsuite/cross_publish.rs @@ -43,7 +43,7 @@ fn simple_cross_package() { let target = cross_compile::alternate(); assert_that( - p.cargo("package").arg("--target").arg(&target), + p.cargo("package --target").arg(&target), execs().with_stderr(&format!( " Packaging foo v0.0.0 ({dir}) Verifying foo v0.0.0 ({dir}) diff --git a/tests/testsuite/dep_info.rs b/tests/testsuite/dep_info.rs index 8c1a30efa..1d7e32ede 100644 --- a/tests/testsuite/dep_info.rs +++ b/tests/testsuite/dep_info.rs @@ -37,7 +37,7 @@ fn build_dep_info_lib() { .file("examples/ex.rs", "") .build(); - assert_that(p.cargo("build").arg("--example=ex"), execs()); + assert_that(p.cargo("build --example=ex"), execs()); assert_that( &p.example_lib("ex", "lib").with_extension("d"), existing_file(), @@ -64,7 +64,7 @@ fn build_dep_info_rlib() { .file("examples/ex.rs", "") .build(); - assert_that(p.cargo("build").arg("--example=ex"), execs()); + assert_that(p.cargo("build --example=ex"), execs()); assert_that( &p.example_lib("ex", "rlib").with_extension("d"), existing_file(), @@ -91,7 +91,7 @@ fn build_dep_info_dylib() { .file("examples/ex.rs", "") .build(); - assert_that(p.cargo("build").arg("--example=ex"), execs()); + assert_that(p.cargo("build --example=ex"), execs()); assert_that( &p.example_lib("ex", "dylib").with_extension("d"), existing_file(), diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index 68346e2ce..c2892ec03 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -168,7 +168,7 @@ fn doc_no_deps() { .build(); assert_that( - p.cargo("doc").arg("--no-deps"), + p.cargo("doc --no-deps"), execs().with_stderr(&format!( "\ [CHECKING] bar v0.0.1 ({dir}/bar) @@ -207,7 +207,7 @@ fn doc_only_bin() { .file("bar/src/lib.rs", "pub fn bar() {}") .build(); - assert_that(p.cargo("doc").arg("-v"), execs()); + assert_that(p.cargo("doc -v"), execs()); assert_that(&p.root().join("target/doc"), existing_dir()); assert_that(&p.root().join("target/doc/bar/index.html"), existing_file()); @@ -248,7 +248,7 @@ fn doc_multiple_targets_same_name_lib() { .build(); assert_that( - p.cargo("doc").arg("--all"), + p.cargo("doc --all"), execs() .with_status(101) .with_stderr_contains("[..] library `foo_lib` is specified [..]") @@ -295,7 +295,7 @@ fn doc_multiple_targets_same_name() { let root = path2url(p.root()); assert_that( - p.cargo("doc").arg("--all"), + p.cargo("doc --all"), execs() .with_stderr_contains(&format!("[DOCUMENTING] foo v0.1.0 ({}/foo)", root)) .with_stderr_contains(&format!("[DOCUMENTING] bar v0.1.0 ({}/bar)", root)) @@ -341,7 +341,7 @@ fn doc_multiple_targets_same_name_bin() { .build(); assert_that( - p.cargo("doc").arg("--all"), + p.cargo("doc --all"), execs() .with_status(101) .with_stderr_contains("[..] binary `foo_cli` is specified [..]") @@ -385,7 +385,7 @@ fn doc_multiple_targets_same_name_undoced() { .file("bar/src/foo-cli.rs", "") .build(); - assert_that(p.cargo("doc").arg("--all"), execs()); + assert_that(p.cargo("doc --all"), execs()); } #[test] @@ -455,7 +455,7 @@ fn doc_lib_bin_same_name_documents_lib_when_requested() { .build(); assert_that( - p.cargo("doc").arg("--lib"), + p.cargo("doc --lib"), execs().with_stderr(&format!( "\ [DOCUMENTING] foo v0.0.1 ({dir}) @@ -499,7 +499,7 @@ fn doc_lib_bin_same_name_documents_named_bin_when_requested() { .build(); assert_that( - p.cargo("doc").arg("--bin").arg("foo"), + p.cargo("doc --bin foo"), execs().with_stderr(&format!( "\ [CHECKING] foo v0.0.1 ({dir}) @@ -544,7 +544,7 @@ fn doc_lib_bin_same_name_documents_bins_when_requested() { .build(); assert_that( - p.cargo("doc").arg("--bins"), + p.cargo("doc --bins"), execs().with_stderr(&format!( "\ [CHECKING] foo v0.0.1 ({dir}) @@ -600,7 +600,7 @@ fn doc_dash_p() { .build(); assert_that( - p.cargo("doc").arg("-p").arg("a"), + p.cargo("doc -p a"), execs().with_stderr( "\ [..] b v0.0.1 (file://[..]) @@ -643,7 +643,7 @@ fn doc_target() { .build(); assert_that( - p.cargo("doc").arg("--target").arg(TARGET).arg("--verbose"), + p.cargo("doc --target").arg(TARGET).arg("--verbose"), execs(), ); assert_that( @@ -806,9 +806,9 @@ fn doc_release() { .file("src/lib.rs", "") .build(); - assert_that(p.cargo("build").arg("--release"), execs()); + assert_that(p.cargo("build --release"), execs()); assert_that( - p.cargo("doc").arg("--release").arg("-v"), + p.cargo("doc --release -v"), execs().with_stderr( "\ [DOCUMENTING] foo v0.0.1 ([..]) @@ -901,7 +901,7 @@ fn features() { .file("bar/src/lib.rs", r#"#[cfg(feature = "bar")] pub fn bar() {}"#) .build(); assert_that( - p.cargo("doc").arg("--features").arg("foo"), + p.cargo("doc --features foo"), execs(), ); assert_that(&p.root().join("target/doc"), existing_dir()); @@ -957,7 +957,7 @@ fn document_only_lib() { "#, ) .build(); - assert_that(p.cargo("doc").arg("--lib"), execs()); + assert_that(p.cargo("doc --lib"), execs()); assert_that(&p.root().join("target/doc/foo/index.html"), existing_file()); } @@ -1012,7 +1012,7 @@ fn doc_all_workspace() { // The order in which bar is compiled or documented is not deterministic assert_that( - p.cargo("doc").arg("--all"), + p.cargo("doc --all"), execs() .with_stderr_contains("[..] Documenting bar v0.1.0 ([..])") .with_stderr_contains("[..] Checking bar v0.1.0 ([..])") @@ -1038,7 +1038,7 @@ fn doc_all_virtual_manifest() { // The order in which bar and baz are documented is not guaranteed assert_that( - p.cargo("doc").arg("--all"), + p.cargo("doc --all"), execs() .with_stderr_contains("[..] Documenting baz v0.1.0 ([..])") .with_stderr_contains("[..] Documenting bar v0.1.0 ([..])"), @@ -1101,7 +1101,7 @@ fn doc_all_member_dependency_same_name() { Package::new("bar", "0.1.0").publish(); assert_that( - p.cargo("doc").arg("--all"), + p.cargo("doc --all"), execs() .with_stderr_contains("[..] Updating registry `[..]`") .with_stderr_contains("[..] Documenting bar v0.1.0 ([..])"), @@ -1126,7 +1126,7 @@ fn doc_workspace_open_help_message() { // The order in which bar is compiled or documented is not deterministic assert_that( - p.cargo("doc").arg("--all").arg("--open"), + p.cargo("doc --all --open"), execs() .with_status(101) .with_stderr_contains("[..] Documenting bar v0.1.0 ([..])") @@ -1353,7 +1353,7 @@ fn doc_private_items() { let foo = project() .file("src/lib.rs", "mod private { fn private_item() {} }") .build(); - assert_that(foo.cargo("doc").arg("--document-private-items"), execs()); + assert_that(foo.cargo("doc --document-private-items"), execs()); assert_that(&foo.root().join("target/doc"), existing_dir()); assert_that(&foo.root().join("target/doc/foo/private/index.html"), existing_file()); diff --git a/tests/testsuite/features.rs b/tests/testsuite/features.rs index b70d0c13d..082cc9f6f 100644 --- a/tests/testsuite/features.rs +++ b/tests/testsuite/features.rs @@ -146,7 +146,7 @@ failed to select a version for `bar` which could resolve this conflict", p.change_file("Cargo.toml", &basic_manifest("foo", "0.0.1")); assert_that( - p.cargo("build").arg("--features").arg("test"), + p.cargo("build --features test"), execs() .with_status(101) .with_stderr("error: Package `foo v0.0.1 ([..])` does not have these features: `test`"), @@ -204,7 +204,7 @@ fn invalid6() { .build(); assert_that( - p.cargo("build").arg("--features").arg("foo"), + p.cargo("build --features foo"), execs().with_status(101).with_stderr( "\ [ERROR] failed to parse manifest at `[..]` @@ -236,7 +236,7 @@ fn invalid7() { .build(); assert_that( - p.cargo("build").arg("--features").arg("foo"), + p.cargo("build --features foo"), execs().with_status(101).with_stderr( "\ [ERROR] failed to parse manifest at `[..]` @@ -270,7 +270,7 @@ fn invalid8() { .build(); assert_that( - p.cargo("build").arg("--features").arg("foo"), + p.cargo("build --features foo"), execs() .with_status(101) .with_stderr("[ERROR] feature names may not contain slashes: `foo/bar`"), @@ -297,7 +297,7 @@ fn invalid9() { .file("bar/src/lib.rs", "") .build(); - assert_that(p.cargo("build").arg("--features").arg("bar"), + assert_that(p.cargo("build --features bar"), execs().with_stderr("\ warning: Package `foo v0.0.1 ([..])` does not have feature `bar`. It has a required dependency with \ that name, but only optional dependencies can be used as features. [..] @@ -465,7 +465,7 @@ fn no_feature_doesnt_build() { ); assert_that( - p.cargo("build").arg("--features").arg("bar"), + p.cargo("build --features bar"), execs().with_stderr(format!( "\ [COMPILING] bar v0.0.1 ({dir}/bar) @@ -532,7 +532,7 @@ fn default_feature_pulled_in() { ); assert_that( - p.cargo("build").arg("--no-default-features"), + p.cargo("build --no-default-features"), execs().with_stderr(format!( "\ [COMPILING] foo v0.0.1 ({dir}) @@ -692,7 +692,7 @@ fn many_cli_features() { .build(); assert_that( - p.cargo("build").arg("--features").arg("bar baz"), + p.cargo("build --features bar baz"), execs().with_stderr(format!( "\ [COMPILING] ba[..] v0.0.1 ({dir}/ba[..]) @@ -838,7 +838,7 @@ fn many_features_no_rebuilds() { p.root().move_into_the_past(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [FRESH] a v0.1.0 ([..]/a) @@ -857,7 +857,7 @@ fn empty_features() { .build(); assert_that( - p.cargo("build").arg("--features").arg(""), + p.cargo("build --features").arg(""), execs(), ); } @@ -898,7 +898,7 @@ fn transitive_features() { .build(); assert_that( - p.cargo("build").arg("--features").arg("foo"), + p.cargo("build --features foo"), execs(), ); } @@ -1150,7 +1150,7 @@ fn activating_feature_activates_dep() { .build(); assert_that( - p.cargo("build").arg("--features").arg("a").arg("-v"), + p.cargo("build --features a -v"), execs(), ); } @@ -1230,7 +1230,7 @@ fn dep_feature_in_cmd_line() { // Trying to enable features of transitive dependencies is an error assert_that( - p.cargo("build").arg("--features").arg("bar/some-feat"), + p.cargo("build --features bar/some-feat"), execs() .with_status(101) .with_stderr("error: Package `foo v0.0.1 ([..])` does not have these features: `bar`"), @@ -1290,7 +1290,7 @@ fn all_features_flag_enables_all_features() { .build(); assert_that( - p.cargo("build").arg("--all-features"), + p.cargo("build --all-features"), execs(), ); } @@ -1332,7 +1332,7 @@ fn many_cli_features_comma_delimited() { .build(); assert_that( - p.cargo("build").arg("--features").arg("bar,baz"), + p.cargo("build --features bar,baz"), execs().with_stderr(format!( "\ [COMPILING] ba[..] v0.0.1 ({dir}/ba[..]) @@ -1398,7 +1398,7 @@ fn many_cli_features_comma_and_space_delimited() { .build(); assert_that( - p.cargo("build").arg("--features").arg("bar,baz bam bap"), + p.cargo("build --features bar,baz bam bap"), execs().with_stderr(format!( "\ [COMPILING] ba[..] v0.0.1 ({dir}/ba[..]) diff --git a/tests/testsuite/fetch.rs b/tests/testsuite/fetch.rs index 28d140abd..276788771 100644 --- a/tests/testsuite/fetch.rs +++ b/tests/testsuite/fetch.rs @@ -104,14 +104,14 @@ fn fetch_platform_specific_dependencies() { .build(); assert_that( - p.cargo("fetch").arg("--target").arg(&host), + p.cargo("fetch --target").arg(&host), execs() .with_stderr_contains("[..] Downloading d1 v1.2.3 [..]") .with_stderr_does_not_contain("[..] Downloading d2 v0.1.2 [..]"), ); assert_that( - p.cargo("fetch").arg("--target").arg(&target), + p.cargo("fetch --target").arg(&target), execs() .with_stderr_contains("[..] Downloading d2 v0.1.2[..]") .with_stderr_does_not_contain("[..] Downloading d1 v1.2.3 [..]"), diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index b6ad583c5..cf8ecd630 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -141,7 +141,7 @@ fn rebuild_sub_package_then_while_package() { .write_all(br#"pub fn b() {}"#) .unwrap(); - assert_that(p.cargo("build").arg("-pb"), execs()); + assert_that(p.cargo("build -pb"), execs()); File::create(&p.root().join("src/lib.rs")) .unwrap() @@ -180,7 +180,7 @@ fn changing_lib_features_caches_targets() { ); assert_that( - p.cargo("build").arg("--features").arg("foo"), + p.cargo("build --features foo"), execs().with_stderr( "\ [..]Compiling foo v0.0.1 ([..]) @@ -200,7 +200,7 @@ fn changing_lib_features_caches_targets() { assert_that(p.cargo("build"), execs().with_stdout("")); assert_that( - p.cargo("build").arg("--features").arg("foo"), + p.cargo("build --features foo"), execs() .with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]"), ); @@ -255,7 +255,7 @@ fn changing_profiles_caches_targets() { ); assert_that( - p.cargo("test").arg("foo"), + p.cargo("test foo"), execs().with_stderr( "\ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] @@ -364,7 +364,7 @@ fn changing_bin_paths_common_target_features_caches_targets() { ), ); assert_that( - p.cargo("clean").arg("-p").arg("a").cwd(p.root().join("a")), + p.cargo("clean -p a").cwd(p.root().join("a")), execs(), ); assert_that( @@ -391,7 +391,7 @@ fn changing_bin_paths_common_target_features_caches_targets() { ), ); assert_that( - p.cargo("clean").arg("-p").arg("b").cwd(p.root().join("b")), + p.cargo("clean -p b").cwd(p.root().join("b")), execs(), ); assert_that( @@ -408,7 +408,7 @@ fn changing_bin_paths_common_target_features_caches_targets() { /* Build a/ package again. If we cache different feature dep builds correctly, * this should not cause a rebuild of dep_crate */ assert_that( - p.cargo("clean").arg("-p").arg("a").cwd(p.root().join("a")), + p.cargo("clean -p a").cwd(p.root().join("a")), execs(), ); assert_that( @@ -425,7 +425,7 @@ fn changing_bin_paths_common_target_features_caches_targets() { /* Build b/ package again. If we cache different feature dep builds correctly, * this should not cause a rebuild */ assert_that( - p.cargo("clean").arg("-p").arg("b").cwd(p.root().join("b")), + p.cargo("clean -p b").cwd(p.root().join("b")), execs(), ); assert_that( @@ -492,7 +492,7 @@ fn changing_bin_features_caches_targets() { ); assert_that( - p.cargo("build").arg("--features").arg("foo"), + p.cargo("build --features foo"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -521,7 +521,7 @@ fn changing_bin_features_caches_targets() { ); assert_that( - p.cargo("build").arg("--features").arg("foo"), + p.cargo("build --features foo"), execs().with_stderr( "\ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] @@ -554,8 +554,8 @@ fn rebuild_tests_if_lib_changes() { sleep_ms(1000); File::create(&p.root().join("src/lib.rs")).unwrap(); - assert_that(p.cargo("build").arg("-v"), execs()); - assert_that(p.cargo("test").arg("-v"), execs().with_status(101)); + assert_that(p.cargo("build -v"), execs()); + assert_that(p.cargo("test -v"), execs().with_status(101)); } #[test] @@ -609,7 +609,7 @@ fn no_rebuild_transitive_target_deps() { assert_that(p.cargo("build"), execs()); assert_that( - p.cargo("test").arg("--no-run"), + p.cargo("test --no-run"), execs().with_stderr( "\ [COMPILING] c v0.0.1 ([..]) diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index f6a9f0cbd..a39331213 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -718,7 +718,7 @@ fn two_revs_same_deps() { ) .build(); - assert_that(foo.cargo("build").arg("-v"), execs()); + assert_that(foo.cargo("build -v"), execs()); assert_that(&foo.bin("foo"), existing_file()); assert_that(foo.process(&foo.bin("foo")), execs()); } @@ -824,7 +824,7 @@ fn recompilation() { // Make sure clean only cleans one dep assert_that( - p.cargo("clean").arg("-p").arg("foo"), + p.cargo("clean -p foo"), execs().with_stdout(""), ); assert_that( @@ -938,7 +938,7 @@ fn update_with_shared_deps() { // By default, not transitive updates println!("dep1 update"); assert_that( - p.cargo("update").arg("-p").arg("dep1"), + p.cargo("update -p dep1"), execs().with_stdout(""), ); @@ -976,7 +976,7 @@ Caused by: // Updating aggressively should, however, update the repo. println!("dep1 aggressive update"); assert_that( - p.cargo("update").arg("-p").arg("dep1").arg("--aggressive"), + p.cargo("update -p dep1 --aggressive"), execs().with_stderr(&format!( "[UPDATING] git repository `{}`\n\ [UPDATING] bar v0.5.0 ([..]) -> #[..]\n\ @@ -1003,7 +1003,7 @@ Caused by: // We should be able to update transitive deps assert_that( - p.cargo("update").arg("-p").arg("bar"), + p.cargo("update -p bar"), execs().with_stderr(&format!( "[UPDATING] git repository `{}`", git_project.url() @@ -1191,7 +1191,7 @@ fn two_deps_only_update_one() { git::commit(&repo); assert_that( - p.cargo("update").arg("-p").arg("dep1"), + p.cargo("update -p dep1"), execs().with_stderr(&format!( "[UPDATING] git repository `{}`\n\ [UPDATING] dep1 v0.5.0 ([..]) -> #[..]\n\ @@ -1386,7 +1386,7 @@ fn dep_with_changed_submodule() { // Update the dependency and carry on! println!("update"); assert_that( - p.cargo("update").arg("-v"), + p.cargo("update -v"), execs().with_stderr("").with_stderr(&format!( "[UPDATING] git repository `{}`\n\ [UPDATING] dep1 v0.5.0 ([..]) -> #[..]\n\ @@ -1873,7 +1873,7 @@ fn update_ambiguous() { assert_that(p.cargo("generate-lockfile"), execs()); assert_that( - p.cargo("update").arg("-p").arg("bar"), + p.cargo("update -p bar"), execs().with_status(101).with_stderr( "\ [ERROR] There are multiple `bar` packages in your project, and the specification `bar` \ @@ -1920,7 +1920,7 @@ fn update_one_dep_in_repo_with_many_deps() { assert_that(p.cargo("generate-lockfile"), execs()); assert_that( - p.cargo("update").arg("-p").arg("bar"), + p.cargo("update -p bar"), execs() .with_stderr(&format!("[UPDATING] git repository `{}`", bar.url())), ); @@ -2092,7 +2092,7 @@ fn update_one_source_updates_all_packages_in_that_git_source() { git::commit(&repo); assert_that( - p.cargo("update").arg("-p").arg("dep"), + p.cargo("update -p dep"), execs(), ); let mut lockfile = String::new(); @@ -2225,7 +2225,7 @@ fn dont_require_submodules_are_checked_out() { git2::Repository::clone(&url, &dst).unwrap(); assert_that( - git1.cargo("build").arg("-v").cwd(&dst), + git1.cargo("build -v").cwd(&dst), execs(), ); } @@ -2279,7 +2279,7 @@ fn doctest_same_name() { ) .build(); - assert_that(p.cargo("test").arg("-v"), execs()); + assert_that(p.cargo("test -v"), execs()); } #[test] @@ -2464,7 +2464,7 @@ fn two_at_rev_instead_of_tag() { .build(); assert_that(p.cargo("generate-lockfile"), execs()); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -2530,7 +2530,7 @@ fn include_overrides_gitignore() { println!("build 1: all is new"); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [UPDATING] registry `[..]` @@ -2551,7 +2551,7 @@ fn include_overrides_gitignore() { println!("build 2: nothing changed; file timestamps reset by build script"); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [FRESH] libc [..] @@ -2567,7 +2567,7 @@ fn include_overrides_gitignore() { File::create(p.root().join("src").join("not_incl.rs")).unwrap(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [FRESH] libc [..] @@ -2587,7 +2587,7 @@ fn include_overrides_gitignore() { File::create(p.root().join("src").join("incl.rs")).unwrap(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr( "\ [FRESH] libc [..] diff --git a/tests/testsuite/local_registry.rs b/tests/testsuite/local_registry.rs index 917db2170..a758cc181 100644 --- a/tests/testsuite/local_registry.rs +++ b/tests/testsuite/local_registry.rs @@ -108,7 +108,7 @@ fn multiple_versions() { .publish(); assert_that( - p.cargo("update").arg("-v"), + p.cargo("update -v"), execs() .with_stderr("[UPDATING] bar v0.1.0 -> v0.2.0"), ); diff --git a/tests/testsuite/lockfile_compat.rs b/tests/testsuite/lockfile_compat.rs index 5a65f7cf3..c68e2bafd 100644 --- a/tests/testsuite/lockfile_compat.rs +++ b/tests/testsuite/lockfile_compat.rs @@ -110,7 +110,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" .file("Cargo.lock", &old_lockfile) .build(); - assert_that(p.cargo("build").arg("--locked"), execs()); + assert_that(p.cargo("build --locked"), execs()); let lock = p.read_lockfile(); for (l, r) in old_lockfile.lines().zip(lock.lines()) { @@ -489,7 +489,7 @@ fn locked_correct_error() { let p = p.build(); assert_that( - p.cargo("build").arg("--locked"), + p.cargo("build --locked"), execs().with_status(101).with_stderr( "\ [UPDATING] registry `[..]` diff --git a/tests/testsuite/metadata.rs b/tests/testsuite/metadata.rs index db3545dd0..86a898d2e 100644 --- a/tests/testsuite/metadata.rs +++ b/tests/testsuite/metadata.rs @@ -81,7 +81,7 @@ fn cargo_metadata_warns_on_implicit_version() { execs().with_stderr("[WARNING] please specify `--format-version` flag explicitly to avoid compatibility problems")); assert_that( - p.cargo("metadata").arg("--format-version").arg("1"), + p.cargo("metadata --format-version 1"), execs().with_stderr(""), ); } @@ -738,7 +738,7 @@ fn workspace_metadata_no_deps() { .build(); assert_that( - p.cargo("metadata").arg("--no-deps"), + p.cargo("metadata --no-deps"), execs().with_json( r#" { @@ -819,7 +819,7 @@ fn cargo_metadata_with_invalid_manifest() { let p = project().file("Cargo.toml", "").build(); assert_that( - p.cargo("metadata").arg("--format-version").arg("1"), + p.cargo("metadata --format-version 1"), execs().with_status(101).with_stderr( "\ [ERROR] failed to parse manifest at `[..]` @@ -949,7 +949,7 @@ fn cargo_metadata_no_deps_cwd() { .build(); assert_that( - p.cargo("metadata").arg("--no-deps").cwd(p.root()), + p.cargo("metadata --no-deps").cwd(p.root()), execs().with_json(MANIFEST_OUTPUT), ); } @@ -996,7 +996,7 @@ fn multiple_features() { .build(); assert_that( - p.cargo("metadata").arg("--features").arg("a b"), + p.cargo("metadata --features a b"), execs(), ); } @@ -1024,7 +1024,7 @@ fn package_metadata() { .build(); assert_that( - p.cargo("metadata").arg("--no-deps"), + p.cargo("metadata --no-deps"), execs().with_json( r#" { diff --git a/tests/testsuite/net_config.rs b/tests/testsuite/net_config.rs index 78ec624da..03e51d6e8 100644 --- a/tests/testsuite/net_config.rs +++ b/tests/testsuite/net_config.rs @@ -29,7 +29,7 @@ fn net_retry_loads_from_config() { .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_status(101).with_stderr_contains( "[WARNING] spurious network error \ (1 tries remaining): [..]", @@ -63,7 +63,7 @@ fn net_retry_git_outputs_warning() { .build(); assert_that( - p.cargo("build").arg("-v").arg("-j").arg("1"), + p.cargo("build -v -j 1"), execs() .with_status(101) .with_stderr_contains( diff --git a/tests/testsuite/overrides.rs b/tests/testsuite/overrides.rs index 580a31be5..8216e0495 100644 --- a/tests/testsuite/overrides.rs +++ b/tests/testsuite/overrides.rs @@ -708,7 +708,7 @@ fn test_override_dep() { .build(); assert_that( - p.cargo("test").arg("-p").arg("bar"), + p.cargo("test -p bar"), execs().with_status(101).with_stderr_contains( "\ error: There are multiple `bar` packages in your project, and the [..] @@ -807,7 +807,7 @@ fn no_override_self() { .file("src/lib.rs", "#![no_std] pub extern crate near;") .build(); - assert_that(p.cargo("build").arg("--verbose"), execs()); + assert_that(p.cargo("build --verbose"), execs()); } #[test] @@ -995,7 +995,7 @@ fn override_an_override() { .file("serde/src/lib.rs", "pub fn serde08_override() {}") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index 55fe71eb4..11d6a29ad 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -46,7 +46,7 @@ See [..] existing_file(), ); assert_that( - p.cargo("package").arg("-l"), + p.cargo("package -l"), execs().with_stdout( "\ Cargo.toml @@ -315,7 +315,7 @@ fn exclude() { .build(); assert_that( - p.cargo("package").arg("--no-verify").arg("-v"), + p.cargo("package --no-verify -v"), execs().with_stdout("").with_stderr( "\ [WARNING] manifest has no description[..] @@ -362,7 +362,7 @@ See [..] ); assert_that( - p.cargo("package").arg("-l"), + p.cargo("package -l"), execs().with_stdout( "\ Cargo.toml @@ -405,7 +405,7 @@ fn include() { .build(); assert_that( - p.cargo("package").arg("--no-verify").arg("-v"), + p.cargo("package --no-verify -v"), execs().with_stderr( "\ [WARNING] manifest has no description[..] @@ -427,7 +427,7 @@ fn package_lib_with_bin() { .file("src/lib.rs", "") .build(); - assert_that(p.cargo("package").arg("-v"), execs()); + assert_that(p.cargo("package -v"), execs()); } #[test] @@ -534,7 +534,7 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. existing_file(), ); assert_that( - p.cargo("package").arg("-l"), + p.cargo("package -l"), execs().with_stdout( "\ Cargo.toml @@ -663,7 +663,7 @@ fn broken_symlink() { t!(fs::symlink("nowhere", &p.root().join("src/foo.rs"))); assert_that( - p.cargo("package").arg("-v"), + p.cargo("package -v"), execs().with_status(101).with_stderr_contains( "\ error: failed to prepare local package for uploading @@ -929,7 +929,7 @@ fn package_two_kinds_of_deps() { .build(); assert_that( - p.cargo("package").arg("--no-verify"), + p.cargo("package --no-verify"), execs(), ); } @@ -955,7 +955,7 @@ fn test_edition() { .build(); assert_that( - p.cargo("build").arg("-v").masquerade_as_nightly_cargo(), + p.cargo("build -v").masquerade_as_nightly_cargo(), execs() // --edition is still in flux and we're not passing -Zunstable-options // from Cargo so it will probably error. Only partially match the output @@ -985,7 +985,7 @@ fn test_edition_missing() { .build(); assert_that( - p.cargo("build").arg("-v").masquerade_as_nightly_cargo(), + p.cargo("build -v").masquerade_as_nightly_cargo(), execs() // --edition is still in flux and we're not passing -Zunstable-options // from Cargo so it will probably error. Only partially match the output @@ -1015,7 +1015,7 @@ fn test_edition_malformed() { .build(); assert_that( - p.cargo("build").arg("-v").masquerade_as_nightly_cargo(), + p.cargo("build -v").masquerade_as_nightly_cargo(), execs().with_status(101).with_stderr( "\ error: failed to parse manifest at `[..]` @@ -1047,7 +1047,7 @@ fn test_edition_nightly() { .build(); assert_that( - p.cargo("build").arg("-v").masquerade_as_nightly_cargo(), + p.cargo("build -v").masquerade_as_nightly_cargo(), execs().with_status(101).with_stderr( "\ error: failed to parse manifest at `[..]` @@ -1103,7 +1103,7 @@ See [..] existing_file(), ); assert_that( - p.cargo("package").arg("-l").masquerade_as_nightly_cargo(), + p.cargo("package -l").masquerade_as_nightly_cargo(), execs().with_stdout( "\ Cargo.lock @@ -1161,7 +1161,7 @@ fn package_lockfile_git_repo() { .file("src/main.rs", "fn main() {}") .build(); assert_that( - p.cargo("package").arg("-l").masquerade_as_nightly_cargo(), + p.cargo("package -l").masquerade_as_nightly_cargo(), execs().with_stdout( "\ Cargo.lock diff --git a/tests/testsuite/path.rs b/tests/testsuite/path.rs index 34fab8ef2..54b1fe566 100644 --- a/tests/testsuite/path.rs +++ b/tests/testsuite/path.rs @@ -92,12 +92,12 @@ fn cargo_compile_with_nested_deps_shorthand() { println!("cleaning"); assert_that( - p.cargo("clean").arg("-v"), + p.cargo("clean -v"), execs().with_stdout(""), ); println!("building baz"); assert_that( - p.cargo("build").arg("-p").arg("baz"), + p.cargo("build -p baz"), execs().with_stderr(&format!( "[COMPILING] baz v0.5.0 ({}/bar/baz)\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) \ @@ -107,7 +107,7 @@ fn cargo_compile_with_nested_deps_shorthand() { ); println!("building foo"); assert_that( - p.cargo("build").arg("-p").arg("foo"), + p.cargo("build -p foo"), execs().with_stderr(&format!( "[COMPILING] bar v0.5.0 ({}/bar)\n\ [COMPILING] foo v0.5.0 ({})\n\ @@ -603,7 +603,7 @@ fn override_relative() { ) .file("src/lib.rs", "") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -690,7 +690,7 @@ fn override_path_dep() { .file("src/lib.rs", "") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -1082,7 +1082,7 @@ fn thin_lto_works() { .build(); assert_that( - p.cargo("build").arg("--release").arg("-v"), + p.cargo("build --release -v"), execs().with_stderr( "\ [COMPILING] top [..] diff --git a/tests/testsuite/plugins.rs b/tests/testsuite/plugins.rs index 33bb5937b..0bc0fc910 100644 --- a/tests/testsuite/plugins.rs +++ b/tests/testsuite/plugins.rs @@ -244,7 +244,7 @@ fn plugin_integration() { .file("tests/it_works.rs", "") .build(); - assert_that(p.cargo("test").arg("-v"), execs()); + assert_that(p.cargo("test -v"), execs()); } #[test] @@ -279,7 +279,7 @@ fn doctest_a_plugin() { .file("bar/src/lib.rs", "pub fn bar() {}") .build(); - assert_that(p.cargo("test").arg("-v"), execs()); + assert_that(p.cargo("test -v"), execs()); } // See #1515 @@ -331,7 +331,7 @@ fn native_plugin_dependency_with_custom_ar_linker() { .build(); assert_that( - bar.cargo("build").arg("--verbose"), + bar.cargo("build --verbose"), execs().with_status(101).with_stderr_contains( "\ [COMPILING] foo v0.0.1 ([..]) diff --git a/tests/testsuite/profiles.rs b/tests/testsuite/profiles.rs index c536d56a2..8e4f3ff25 100644 --- a/tests/testsuite/profiles.rs +++ b/tests/testsuite/profiles.rs @@ -25,7 +25,7 @@ fn profile_overrides() { .file("src/lib.rs", "") .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr(&format!( "\ [COMPILING] test v0.0.0 ({url}) @@ -64,7 +64,7 @@ fn opt_level_override_0() { .file("src/lib.rs", "") .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr(&format!( "\ [COMPILING] test v0.0.0 ({url}) @@ -100,7 +100,7 @@ fn debug_override_1() { .file("src/lib.rs", "") .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr(&format!( "\ [COMPILING] test v0.0.0 ({url}) @@ -139,7 +139,7 @@ fn check_opt_level_override(profile_level: &str, rustc_level: &str) { .file("src/lib.rs", "") .build(); assert_that( - p.cargo("build").arg("-v"), + p.cargo("build -v"), execs().with_stderr(&format!( "\ [COMPILING] test v0.0.0 ({url}) @@ -219,7 +219,7 @@ fn top_level_overrides_deps() { .file("foo/src/lib.rs", "") .build(); assert_that( - p.cargo("build").arg("-v").arg("--release"), + p.cargo("build -v --release"), execs().with_stderr(&format!( "\ [COMPILING] foo v0.0.0 ({url}/foo) diff --git a/tests/testsuite/rename_deps.rs b/tests/testsuite/rename_deps.rs index 8b101d391..a725e71b0 100644 --- a/tests/testsuite/rename_deps.rs +++ b/tests/testsuite/rename_deps.rs @@ -350,7 +350,7 @@ fn can_run_doc_tests() { .build(); assert_that( - foo.cargo("test").arg("-v").masquerade_as_nightly_cargo(), + foo.cargo("test -v").masquerade_as_nightly_cargo(), execs().with_stderr_contains(format!( "\ [DOCTEST] foo diff --git a/tests/testsuite/required_features.rs b/tests/testsuite/required_features.rs index 52cc4db41..258791387 100644 --- a/tests/testsuite/required_features.rs +++ b/tests/testsuite/required_features.rs @@ -43,11 +43,11 @@ fn build_bin_default_features() { assert_that(&p.bin("foo"), existing_file()); assert_that( - p.cargo("build").arg("--no-default-features"), + p.cargo("build --no-default-features"), execs(), ); - assert_that(p.cargo("build").arg("--bin=foo"), execs()); + assert_that(p.cargo("build --bin=foo"), execs()); assert_that(&p.bin("foo"), existing_file()); assert_that( @@ -86,7 +86,7 @@ fn build_bin_arg_features() { .build(); assert_that( - p.cargo("build").arg("--features").arg("a"), + p.cargo("build --features a"), execs(), ); assert_that(&p.bin("foo"), existing_file()); @@ -130,7 +130,7 @@ fn build_bin_multiple_required_features() { assert_that(&p.bin("foo_2"), existing_file()); assert_that( - p.cargo("build").arg("--features").arg("c"), + p.cargo("build --features c"), execs(), ); @@ -138,7 +138,7 @@ fn build_bin_multiple_required_features() { assert_that(&p.bin("foo_2"), existing_file()); assert_that( - p.cargo("build").arg("--no-default-features"), + p.cargo("build --no-default-features"), execs(), ); } @@ -167,7 +167,7 @@ fn build_example_default_features() { .build(); assert_that( - p.cargo("build").arg("--example=foo"), + p.cargo("build --example=foo"), execs(), ); assert_that(&p.bin("examples/foo"), existing_file()); @@ -248,7 +248,7 @@ fn build_example_multiple_required_features() { .build(); assert_that( - p.cargo("build").arg("--example=foo_1"), + p.cargo("build --example=foo_1"), execs().with_status(101).with_stderr( "\ error: target `foo_1` in package `foo` requires the features: `b`, `c` @@ -257,7 +257,7 @@ Consider enabling them by passing e.g. `--features=\"b c\"` ), ); assert_that( - p.cargo("build").arg("--example=foo_2"), + p.cargo("build --example=foo_2"), execs(), ); @@ -343,7 +343,7 @@ fn test_default_features() { ); assert_that( - p.cargo("test").arg("--no-default-features"), + p.cargo("test --no-default-features"), execs() .with_stderr( "[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]" @@ -352,7 +352,7 @@ fn test_default_features() { ); assert_that( - p.cargo("test").arg("--test=foo"), + p.cargo("test --test=foo"), execs() .with_stderr( "\ @@ -398,7 +398,7 @@ fn test_arg_features() { .build(); assert_that( - p.cargo("test").arg("--features").arg("a"), + p.cargo("test --features a"), execs() .with_stderr(format!( "\ @@ -455,7 +455,7 @@ fn test_multiple_required_features() { ); assert_that( - p.cargo("test").arg("--features").arg("c"), + p.cargo("test --features c"), execs() .with_stderr(format!( "\ @@ -469,7 +469,7 @@ fn test_multiple_required_features() { ); assert_that( - p.cargo("test").arg("--no-default-features"), + p.cargo("test --no-default-features"), execs() .with_stderr( "[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]" @@ -528,14 +528,14 @@ fn bench_default_features() { ); assert_that( - p.cargo("bench").arg("--no-default-features"), + p.cargo("bench --no-default-features"), execs() .with_stderr("[FINISHED] release [optimized] target(s) in [..]".to_string()) .with_stdout(""), ); assert_that( - p.cargo("bench").arg("--bench=foo"), + p.cargo("bench --bench=foo"), execs() .with_stderr( "\ @@ -594,7 +594,7 @@ fn bench_arg_features() { .build(); assert_that( - p.cargo("bench").arg("--features").arg("a"), + p.cargo("bench --features a"), execs() .with_stderr(format!( "\ @@ -673,7 +673,7 @@ fn bench_multiple_required_features() { ); assert_that( - p.cargo("bench").arg("--features").arg("c"), + p.cargo("bench --features c"), execs() .with_stderr(format!( "\ @@ -687,7 +687,7 @@ fn bench_multiple_required_features() { ); assert_that( - p.cargo("bench").arg("--no-default-features"), + p.cargo("bench --no-default-features"), execs() .with_stderr("[FINISHED] release [optimized] target(s) in [..]") .with_stdout(""), @@ -724,10 +724,10 @@ fn install_default_features() { assert_that(p.cargo("install --path ."), execs()); assert_that(cargo_home(), has_installed_exe("foo")); - assert_that(p.cargo("uninstall").arg("foo"), execs()); + assert_that(p.cargo("uninstall foo"), execs()); assert_that( - p.cargo("install --path .").arg("--no-default-features"), + p.cargo("install --path . --no-default-features"), execs().with_status(101).with_stderr( "\ [INSTALLING] foo v0.0.1 ([..]) @@ -739,11 +739,11 @@ fn install_default_features() { assert_that(cargo_home(), is_not(has_installed_exe("foo"))); assert_that( - p.cargo("install --path .").arg("--bin=foo"), + p.cargo("install --path . --bin=foo"), execs(), ); assert_that(cargo_home(), has_installed_exe("foo")); - assert_that(p.cargo("uninstall").arg("foo"), execs()); + assert_that(p.cargo("uninstall foo"), execs()); assert_that( p.cargo("install --path .") @@ -764,11 +764,11 @@ Consider enabling them by passing e.g. `--features=\"a\"` assert_that(cargo_home(), is_not(has_installed_exe("foo"))); assert_that( - p.cargo("install --path .").arg("--example=foo"), + p.cargo("install --path . --example=foo"), execs(), ); assert_that(cargo_home(), has_installed_exe("foo")); - assert_that(p.cargo("uninstall").arg("foo"), execs()); + assert_that(p.cargo("uninstall foo"), execs()); assert_that( p.cargo("install --path .") @@ -812,11 +812,11 @@ fn install_arg_features() { .build(); assert_that( - p.cargo("install").arg("--features").arg("a"), + p.cargo("install --features a"), execs(), ); assert_that(cargo_home(), has_installed_exe("foo")); - assert_that(p.cargo("uninstall").arg("foo"), execs()); + assert_that(p.cargo("uninstall foo"), execs()); } #[test] @@ -854,18 +854,18 @@ fn install_multiple_required_features() { assert_that(p.cargo("install --path ."), execs()); assert_that(cargo_home(), is_not(has_installed_exe("foo_1"))); assert_that(cargo_home(), has_installed_exe("foo_2")); - assert_that(p.cargo("uninstall").arg("foo"), execs()); + assert_that(p.cargo("uninstall foo"), execs()); assert_that( - p.cargo("install --path .").arg("--features").arg("c"), + p.cargo("install --path . --features c"), execs(), ); assert_that(cargo_home(), has_installed_exe("foo_1")); assert_that(cargo_home(), has_installed_exe("foo_2")); - assert_that(p.cargo("uninstall").arg("foo"), execs()); + assert_that(p.cargo("uninstall foo"), execs()); assert_that( - p.cargo("install --path .").arg("--no-default-features"), + p.cargo("install --path . --no-default-features"), execs().with_status(101).with_stderr( "\ [INSTALLING] foo v0.0.1 ([..]) @@ -940,19 +940,19 @@ fn dep_feature_in_toml() { assert_that(p.cargo("build"), execs()); // bin - assert_that(p.cargo("build").arg("--bin=foo"), execs()); + assert_that(p.cargo("build --bin=foo"), execs()); assert_that(&p.bin("foo"), existing_file()); // example assert_that( - p.cargo("build").arg("--example=foo"), + p.cargo("build --example=foo"), execs(), ); assert_that(&p.bin("examples/foo"), existing_file()); // test assert_that( - p.cargo("test").arg("--test=foo"), + p.cargo("test --test=foo"), execs() .with_stderr(format!( "\ @@ -967,7 +967,7 @@ fn dep_feature_in_toml() { // bench if is_nightly() { assert_that( - p.cargo("bench").arg("--bench=foo"), + p.cargo("bench --bench=foo"), execs() .with_stderr(format!( "\ @@ -984,7 +984,7 @@ fn dep_feature_in_toml() { // install assert_that(p.cargo("install"), execs()); assert_that(cargo_home(), has_installed_exe("foo")); - assert_that(p.cargo("uninstall").arg("foo"), execs()); + assert_that(p.cargo("uninstall foo"), execs()); } #[test] @@ -1050,7 +1050,7 @@ fn dep_feature_in_cmd_line() { // bin assert_that( - p.cargo("build").arg("--bin=foo"), + p.cargo("build --bin=foo"), execs().with_status(101).with_stderr( "\ error: target `foo` in package `foo` requires the features: `bar/a` @@ -1070,7 +1070,7 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` // example assert_that( - p.cargo("build").arg("--example=foo"), + p.cargo("build --example=foo"), execs().with_status(101).with_stderr( "\ error: target `foo` in package `foo` requires the features: `bar/a` @@ -1155,11 +1155,11 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` assert_that(cargo_home(), is_not(has_installed_exe("foo"))); assert_that( - p.cargo("install").arg("--features").arg("bar/a"), + p.cargo("install --features bar/a"), execs(), ); assert_that(cargo_home(), has_installed_exe("foo")); - assert_that(p.cargo("uninstall").arg("foo"), execs()); + assert_that(p.cargo("uninstall foo"), execs()); } #[test] @@ -1279,7 +1279,7 @@ Consider enabling them by passing e.g. `--features=\"a\"` ); assert_that( - p.cargo("run").arg("--features").arg("a"), + p.cargo("run --features a"), execs(), ); } diff --git a/tests/testsuite/run.rs b/tests/testsuite/run.rs index 16050ed42..38671bad6 100644 --- a/tests/testsuite/run.rs +++ b/tests/testsuite/run.rs @@ -48,7 +48,7 @@ fn simple_quiet_and_verbose() { .build(); assert_that( - p.cargo("run").arg("-q").arg("-v"), + p.cargo("run -q -v"), execs() .with_status(101) .with_stderr("[ERROR] cannot set both --verbose and --quiet"), @@ -68,7 +68,7 @@ fn quiet_and_verbose_config() { .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .build(); - assert_that(p.cargo("run").arg("-q"), execs()); + assert_that(p.cargo("run -q"), execs()); } #[test] @@ -86,7 +86,7 @@ fn simple_with_args() { .build(); assert_that( - p.cargo("run").arg("hello").arg("world"), + p.cargo("run hello world"), execs(), ); } @@ -133,7 +133,7 @@ fn exit_code_verbose() { } assert_that( - p.cargo("run").arg("-v"), + p.cargo("run -v"), execs().with_status(2).with_stderr(output), ); } @@ -206,7 +206,7 @@ fn specify_name() { .build(); assert_that( - p.cargo("run").arg("--bin").arg("a").arg("-v"), + p.cargo("run --bin a -v"), execs() .with_stderr(&format!( "\ @@ -221,7 +221,7 @@ fn specify_name() { ); assert_that( - p.cargo("run").arg("--bin").arg("b").arg("-v"), + p.cargo("run --bin b -v"), execs() .with_stderr( "\ @@ -358,7 +358,7 @@ fn run_example() { .build(); assert_that( - p.cargo("run").arg("--example").arg("a"), + p.cargo("run --example a"), execs() .with_stderr(&format!( "\ @@ -391,7 +391,7 @@ fn run_library_example() { .build(); assert_that( - p.cargo("run").arg("--example").arg("bar"), + p.cargo("run --example bar"), execs() .with_status(101) .with_stderr("[ERROR] example target `bar` is a library and cannot be executed"), @@ -548,7 +548,7 @@ fn run_bins() { .build(); assert_that( - p.cargo("run").arg("--bins"), + p.cargo("run --bins"), execs().with_status(1).with_stderr_contains( "error: Found argument '--bins' which wasn't expected, or isn't valid in this context", ), @@ -570,14 +570,14 @@ fn run_with_filename() { .build(); assert_that( - p.cargo("run").arg("--bin").arg("bin.rs"), + p.cargo("run --bin bin.rs"), execs() .with_status(101) .with_stderr("[ERROR] no bin target named `bin.rs`"), ); assert_that( - p.cargo("run").arg("--bin").arg("a.rs"), + p.cargo("run --bin a.rs"), execs().with_status(101).with_stderr( "\ [ERROR] no bin target named `a.rs` @@ -587,14 +587,14 @@ Did you mean `a`?", ); assert_that( - p.cargo("run").arg("--example").arg("example.rs"), + p.cargo("run --example example.rs"), execs() .with_status(101) .with_stderr("[ERROR] no example target named `example.rs`"), ); assert_that( - p.cargo("run").arg("--example").arg("a.rs"), + p.cargo("run --example a.rs"), execs().with_status(101).with_stderr( "\ [ERROR] no example target named `a.rs` @@ -732,7 +732,7 @@ fast2", ); assert_that( - p.cargo("run").arg("-v").arg("--example").arg("a"), + p.cargo("run -v --example a"), execs() .with_stderr(&format!( "\ @@ -798,7 +798,7 @@ fn run_dylib_dep() { .build(); assert_that( - p.cargo("run").arg("hello").arg("world"), + p.cargo("run hello world"), execs(), ); } @@ -815,7 +815,7 @@ fn release_works() { .build(); assert_that( - p.cargo("run").arg("--release"), + p.cargo("run --release"), execs().with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ({dir}) @@ -1013,7 +1013,7 @@ fn fail_no_extra_verbose() { .build(); assert_that( - p.cargo("run").arg("-q"), + p.cargo("run -q"), execs().with_status(1).with_stdout("").with_stderr(""), ); } diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index 20040ca6b..e554a4200 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -13,7 +13,7 @@ fn build_lib_for_foo() { .build(); assert_that( - p.cargo("rustc").arg("--lib").arg("-v"), + p.cargo("rustc --lib -v"), execs().with_stderr(format!( "\ [COMPILING] foo v0.0.1 ({url}) @@ -264,7 +264,7 @@ fn targets_selected_default() { .file("src/main.rs", "fn main() {}") .build(); assert_that( - p.cargo("rustc").arg("-v"), + p.cargo("rustc -v"), execs() // bin .with_stderr_contains("\ @@ -287,7 +287,7 @@ fn targets_selected_all() { .file("src/main.rs", "fn main() {}") .build(); assert_that( - p.cargo("rustc").arg("-v").arg("--all-targets"), + p.cargo("rustc -v --all-targets"), execs() // bin .with_stderr_contains("\ @@ -389,7 +389,7 @@ fn rustc_with_other_profile() { .build(); assert_that( - p.cargo("rustc").arg("--profile").arg("test"), + p.cargo("rustc --profile test"), execs(), ); } diff --git a/tests/testsuite/rustdoc.rs b/tests/testsuite/rustdoc.rs index 7ca9e32eb..765db5ded 100644 --- a/tests/testsuite/rustdoc.rs +++ b/tests/testsuite/rustdoc.rs @@ -8,7 +8,7 @@ fn rustdoc_simple() { .build(); assert_that( - p.cargo("rustdoc").arg("-v"), + p.cargo("rustdoc -v"), execs().with_stderr(format!( "\ [DOCUMENTING] foo v0.0.1 ({url}) @@ -30,7 +30,7 @@ fn rustdoc_args() { .build(); assert_that( - p.cargo("rustdoc").arg("-v").arg("--").arg("--cfg=foo"), + p.cargo("rustdoc -v -- --cfg=foo"), execs().with_stderr(format!( "\ [DOCUMENTING] foo v0.0.1 ({url}) @@ -69,7 +69,7 @@ fn rustdoc_foo_with_bar_dependency() { .build(); assert_that( - foo.cargo("rustdoc").arg("-v").arg("--").arg("--cfg=foo"), + foo.cargo("rustdoc -v -- --cfg=foo"), execs().with_stderr(format!( "\ [CHECKING] bar v0.0.1 ([..]) @@ -139,7 +139,7 @@ fn rustdoc_same_name_documents_lib() { .build(); assert_that( - p.cargo("rustdoc").arg("-v").arg("--").arg("--cfg=foo"), + p.cargo("rustdoc -v -- --cfg=foo"), execs().with_stderr(format!( "\ [DOCUMENTING] foo v0.0.1 ([..]) diff --git a/tests/testsuite/rustdocflags.rs b/tests/testsuite/rustdocflags.rs index 15eaa1f68..7337cf7b1 100644 --- a/tests/testsuite/rustdocflags.rs +++ b/tests/testsuite/rustdocflags.rs @@ -28,7 +28,7 @@ fn parses_config() { .build(); assert_that( - p.cargo("doc").arg("-v"), + p.cargo("doc -v"), execs() .with_stderr_contains("[RUNNING] `rustdoc [..] --cfg foo[..]`"), ); diff --git a/tests/testsuite/rustflags.rs b/tests/testsuite/rustflags.rs index 1940f12cf..ba3e5385c 100644 --- a/tests/testsuite/rustflags.rs +++ b/tests/testsuite/rustflags.rs @@ -483,10 +483,10 @@ fn build_rustflags_normal_source() { ) .build(); - assert_that(p.cargo("build").arg("--lib"), execs().with_status(101)); - assert_that(p.cargo("build").arg("--bin=a"), execs().with_status(101)); + assert_that(p.cargo("build --lib"), execs().with_status(101)); + assert_that(p.cargo("build --bin=a"), execs().with_status(101)); assert_that( - p.cargo("build").arg("--example=b"), + p.cargo("build --example=b"), execs().with_status(101), ); assert_that(p.cargo("test"), execs().with_status(101)); @@ -682,11 +682,11 @@ fn build_rustflags_normal_source_with_target() { // Use RUSTFLAGS to pass an argument that will generate an error assert_that( - p.cargo("build").arg("--lib").arg("--target").arg(host), + p.cargo("build --lib --target").arg(host), execs().with_status(101), ); assert_that( - p.cargo("build").arg("--bin=a").arg("--target").arg(host), + p.cargo("build --bin=a --target").arg(host), execs().with_status(101), ); assert_that( @@ -697,11 +697,11 @@ fn build_rustflags_normal_source_with_target() { execs().with_status(101), ); assert_that( - p.cargo("test").arg("--target").arg(host), + p.cargo("test --target").arg(host), execs().with_status(101), ); assert_that( - p.cargo("bench").arg("--target").arg(host), + p.cargo("bench --target").arg(host), execs().with_status(101), ); } @@ -741,7 +741,7 @@ fn build_rustflags_build_script_with_target() { let host = rustc_host(); assert_that( - p.cargo("build").arg("--target").arg(host), + p.cargo("build --target").arg(host), execs(), ); } @@ -788,7 +788,7 @@ fn build_rustflags_build_script_dep_with_target() { let host = rustc_host(); assert_that( - foo.cargo("build").arg("--target").arg(host), + foo.cargo("build --target").arg(host), execs(), ); } @@ -830,7 +830,7 @@ fn build_rustflags_plugin_with_target() { let host = rustc_host(); assert_that( - p.cargo("build").arg("--target").arg(host), + p.cargo("build --target").arg(host), execs(), ); } @@ -879,7 +879,7 @@ fn build_rustflags_plugin_dep_with_target() { let host = rustc_host(); assert_that( - foo.cargo("build").arg("--target").arg(host), + foo.cargo("build --target").arg(host), execs(), ); } @@ -974,7 +974,7 @@ fn build_rustflags_with_home_config() { .file("src/lib.rs", "") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); } #[test] @@ -1003,10 +1003,10 @@ fn target_rustflags_normal_source() { ) .build(); - assert_that(p.cargo("build").arg("--lib"), execs().with_status(101)); - assert_that(p.cargo("build").arg("--bin=a"), execs().with_status(101)); + assert_that(p.cargo("build --lib"), execs().with_status(101)); + assert_that(p.cargo("build --bin=a"), execs().with_status(101)); assert_that( - p.cargo("build").arg("--example=b"), + p.cargo("build --example=b"), execs().with_status(101), ); assert_that(p.cargo("test"), execs().with_status(101)); @@ -1033,10 +1033,10 @@ fn target_rustflags_precedence() { ) .build(); - assert_that(p.cargo("build").arg("--lib"), execs().with_status(101)); - assert_that(p.cargo("build").arg("--bin=a"), execs().with_status(101)); + assert_that(p.cargo("build --lib"), execs().with_status(101)); + assert_that(p.cargo("build --bin=a"), execs().with_status(101)); assert_that( - p.cargo("build").arg("--example=b"), + p.cargo("build --example=b"), execs().with_status(101), ); assert_that(p.cargo("test"), execs().with_status(101)); @@ -1067,7 +1067,7 @@ fn cfg_rustflags_normal_source() { .build(); assert_that( - p.cargo("build").arg("--lib").arg("-v"), + p.cargo("build --lib -v"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -1078,7 +1078,7 @@ fn cfg_rustflags_normal_source() { ); assert_that( - p.cargo("build").arg("--bin=a").arg("-v"), + p.cargo("build --bin=a -v"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -1089,7 +1089,7 @@ fn cfg_rustflags_normal_source() { ); assert_that( - p.cargo("build").arg("--example=b").arg("-v"), + p.cargo("build --example=b -v"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -1100,7 +1100,7 @@ fn cfg_rustflags_normal_source() { ); assert_that( - p.cargo("test").arg("--no-run").arg("-v"), + p.cargo("test --no-run -v"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -1113,7 +1113,7 @@ fn cfg_rustflags_normal_source() { ); assert_that( - p.cargo("bench").arg("--no-run").arg("-v"), + p.cargo("bench --no-run -v"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -1154,7 +1154,7 @@ fn cfg_rustflags_precedence() { .build(); assert_that( - p.cargo("build").arg("--lib").arg("-v"), + p.cargo("build --lib -v"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -1165,7 +1165,7 @@ fn cfg_rustflags_precedence() { ); assert_that( - p.cargo("build").arg("--bin=a").arg("-v"), + p.cargo("build --bin=a -v"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -1176,7 +1176,7 @@ fn cfg_rustflags_precedence() { ); assert_that( - p.cargo("build").arg("--example=b").arg("-v"), + p.cargo("build --example=b -v"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -1187,7 +1187,7 @@ fn cfg_rustflags_precedence() { ); assert_that( - p.cargo("test").arg("--no-run").arg("-v"), + p.cargo("test --no-run -v"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -1200,7 +1200,7 @@ fn cfg_rustflags_precedence() { ); assert_that( - p.cargo("bench").arg("--no-run").arg("-v"), + p.cargo("bench --no-run -v"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -1227,7 +1227,7 @@ fn target_rustflags_string_and_array_form1() { .build(); assert_that( - p1.cargo("build").arg("-v"), + p1.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -1249,7 +1249,7 @@ fn target_rustflags_string_and_array_form1() { .build(); assert_that( - p2.cargo("build").arg("-v"), + p2.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -1277,7 +1277,7 @@ fn target_rustflags_string_and_array_form2() { .build(); assert_that( - p1.cargo("build").arg("-v"), + p1.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -1302,7 +1302,7 @@ fn target_rustflags_string_and_array_form2() { .build(); assert_that( - p2.cargo("build").arg("-v"), + p2.cargo("build -v"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 1141bd7d2..c7992fb94 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -93,7 +93,7 @@ fn cargo_test_release() { .build(); assert_that( - p.cargo("test").arg("-v").arg("--release"), + p.cargo("test -v --release"), execs() .with_stderr(format!( "\ @@ -149,7 +149,7 @@ fn cargo_test_overflow_checks() { ) .build(); - assert_that(p.cargo("build").arg("--release"), execs()); + assert_that(p.cargo("build --release"), execs()); assert_that(&p.release_bin("foo"), existing_file()); assert_that( @@ -172,7 +172,7 @@ fn cargo_test_verbose() { .build(); assert_that( - p.cargo("test").arg("-v").arg("hello"), + p.cargo("test -v hello"), execs() .with_stderr(format!( "\ @@ -213,7 +213,7 @@ fn many_similar_names() { ) .build(); - let output = p.cargo("test").arg("-v").exec_with_output().unwrap(); + let output = p.cargo("test -v").exec_with_output().unwrap(); let output = str::from_utf8(&output.stdout).unwrap(); assert!( output.contains("test bin_test"), @@ -648,7 +648,7 @@ fn pass_through_command_line() { .build(); assert_that( - p.cargo("test").arg("bar"), + p.cargo("test bar"), execs() .with_stderr(&format!( "\ @@ -663,7 +663,7 @@ fn pass_through_command_line() { ); assert_that( - p.cargo("test").arg("foo"), + p.cargo("test foo"), execs() .with_stderr( "\ @@ -1120,7 +1120,7 @@ fn bin_there_for_integration() { ) .build(); - let output = p.cargo("test").arg("-v").exec_with_output().unwrap(); + let output = p.cargo("test -v").exec_with_output().unwrap(); let output = str::from_utf8(&output.stdout).unwrap(); assert!( output.contains("main_test ... ok"), @@ -1295,7 +1295,7 @@ fn test_no_run() { .build(); assert_that( - p.cargo("test").arg("--no-run"), + p.cargo("test --no-run"), execs().with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ({dir}) @@ -1331,7 +1331,7 @@ fn test_run_specific_bin_target() { .build(); assert_that( - prj.cargo("test").arg("--bin").arg("bin2"), + prj.cargo("test --bin bin2"), execs() .with_stderr(format!( "\ @@ -1375,7 +1375,7 @@ fn test_run_implicit_bin_target() { .build(); assert_that( - prj.cargo("test").arg("--bins"), + prj.cargo("test --bins"), execs() .with_stderr(format!( "\ @@ -1398,7 +1398,7 @@ fn test_run_specific_test_target() { .build(); assert_that( - prj.cargo("test").arg("--test").arg("b"), + prj.cargo("test --test b"), execs() .with_stderr(format!( "\ @@ -1441,7 +1441,7 @@ fn test_run_implicit_test_target() { .build(); assert_that( - prj.cargo("test").arg("--tests"), + prj.cargo("test --tests"), execs() .with_stderr(format!( "\ @@ -1485,7 +1485,7 @@ fn test_run_implicit_bench_target() { .build(); assert_that( - prj.cargo("test").arg("--benches"), + prj.cargo("test --benches"), execs() .with_stderr(format!( "\ @@ -1609,7 +1609,7 @@ fn test_no_harness() { .build(); assert_that( - p.cargo("test").arg("--").arg("--nocapture"), + p.cargo("test -- --nocapture"), execs().with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ({dir}) @@ -1683,7 +1683,7 @@ fn selective_testing() { println!("d1"); assert_that( - p.cargo("test").arg("-p").arg("d1"), + p.cargo("test -p d1"), execs() .with_stderr(&format!( "\ @@ -1698,7 +1698,7 @@ fn selective_testing() { println!("d2"); assert_that( - p.cargo("test").arg("-p").arg("d2"), + p.cargo("test -p d2"), execs() .with_stderr(&format!( "\ @@ -1809,7 +1809,7 @@ fn build_then_selective_test() { assert_that(p.cargo("build"), execs()); p.root().move_into_the_past(); - assert_that(p.cargo("test").arg("-p").arg("b"), execs()); + assert_that(p.cargo("test -p b"), execs()); } #[test] @@ -1901,7 +1901,7 @@ fn selective_testing_with_docs() { let p = p.build(); assert_that( - p.cargo("test").arg("-p").arg("d1"), + p.cargo("test -p d1"), execs() .with_stderr(&format!( "\ @@ -1923,7 +1923,7 @@ fn example_bin_same_name() { .build(); assert_that( - p.cargo("test").arg("--no-run").arg("-v"), + p.cargo("test --no-run -v"), execs().with_stderr(&format!( "\ [COMPILING] foo v0.0.1 ({dir}) @@ -1965,10 +1965,10 @@ fn test_with_example_twice() { .build(); println!("first"); - assert_that(p.cargo("test").arg("-v"), execs()); + assert_that(p.cargo("test -v"), execs()); assert_that(&p.bin("examples/foo"), existing_file()); println!("second"); - assert_that(p.cargo("test").arg("-v"), execs()); + assert_that(p.cargo("test -v"), execs()); assert_that(&p.bin("examples/foo"), existing_file()); } @@ -2002,7 +2002,7 @@ fn example_with_dev_dep() { .build(); assert_that( - p.cargo("test").arg("-v"), + p.cargo("test -v"), execs().with_stderr( "\ [..] @@ -2023,11 +2023,11 @@ fn bin_is_preserved() { .file("src/main.rs", "fn main() {}") .build(); - assert_that(p.cargo("build").arg("-v"), execs()); + assert_that(p.cargo("build -v"), execs()); assert_that(&p.bin("foo"), existing_file()); println!("testing"); - assert_that(p.cargo("test").arg("-v"), execs()); + assert_that(p.cargo("test -v"), execs()); assert_that(&p.bin("foo"), existing_file()); } @@ -2038,13 +2038,13 @@ fn bad_example() { let p = p.build(); assert_that( - p.cargo("run").arg("--example").arg("foo"), + p.cargo("run --example foo"), execs() .with_status(101) .with_stderr("[ERROR] no example target named `foo`"), ); assert_that( - p.cargo("run").arg("--bin").arg("foo"), + p.cargo("run --bin foo"), execs() .with_status(101) .with_stderr("[ERROR] no bin target named `foo`"), @@ -2078,7 +2078,7 @@ fn doctest_feature() { .build(); assert_that( - p.cargo("test").arg("--features").arg("bar"), + p.cargo("test --features bar"), execs() .with_stderr( "\ @@ -2107,7 +2107,7 @@ fn dashes_to_underscores() { ) .build(); - assert_that(p.cargo("test").arg("-v"), execs()); + assert_that(p.cargo("test -v"), execs()); } #[test] @@ -2138,7 +2138,7 @@ fn doctest_dev_dep() { .file("b/src/lib.rs", "") .build(); - assert_that(p.cargo("test").arg("-v"), execs()); + assert_that(p.cargo("test -v"), execs()); } #[test] @@ -2157,7 +2157,7 @@ fn filter_no_doc_tests() { .build(); assert_that( - p.cargo("test").arg("--test=foo"), + p.cargo("test --test=foo"), execs() .with_stderr( "\ @@ -2384,7 +2384,7 @@ fn no_fail_fast() { ) .build(); assert_that( - p.cargo("test").arg("--no-fail-fast"), + p.cargo("test --no-fail-fast"), execs() .with_status(101) .with_stderr_contains( @@ -2459,7 +2459,7 @@ fn test_multiple_packages() { let p = p.build(); assert_that( - p.cargo("test").arg("-p").arg("d1").arg("-p").arg("d2"), + p.cargo("test -p d1 -p d2"), execs() .with_stderr_contains("[RUNNING] target/debug/deps/d1-[..][EXE]") .with_stderr_contains("[RUNNING] target/debug/deps/d2-[..][EXE]") @@ -2475,7 +2475,7 @@ fn bin_does_not_rebuild_tests() { .file("tests/foo.rs", ""); let p = p.build(); - assert_that(p.cargo("test").arg("-v"), execs()); + assert_that(p.cargo("test -v"), execs()); sleep_ms(1000); File::create(&p.root().join("src/main.rs")) @@ -2484,7 +2484,7 @@ fn bin_does_not_rebuild_tests() { .unwrap(); assert_that( - p.cargo("test").arg("-v").arg("--no-run"), + p.cargo("test -v --no-run"), execs().with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -2587,7 +2587,7 @@ fn only_test_docs() { let p = p.build(); assert_that( - p.cargo("test").arg("--doc"), + p.cargo("test --doc"), execs() .with_stderr( "\ @@ -2629,7 +2629,7 @@ fn test_panic_abort_with_dep() { .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "") .build(); - assert_that(p.cargo("test").arg("-v"), execs()); + assert_that(p.cargo("test -v"), execs()); } #[test] @@ -2651,7 +2651,7 @@ fn cfg_test_even_with_no_harness() { .file("src/lib.rs", r#"#[cfg(test)] fn main() { println!("hello!"); }"#) .build(); assert_that( - p.cargo("test").arg("-v"), + p.cargo("test -v"), execs().with_stdout("hello!\n").with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -2778,7 +2778,7 @@ fn pass_correct_cfgs_flags_to_rustdoc() { ); assert_that( - p.cargo("test").arg("--verbose"), + p.cargo("test --verbose"), execs().with_stderr_contains( "\ [DOCTEST] foo @@ -2815,9 +2815,9 @@ fn test_release_ignore_panic() { .file("a/src/lib.rs", ""); let p = p.build(); println!("test"); - assert_that(p.cargo("test").arg("-v"), execs()); + assert_that(p.cargo("test -v"), execs()); println!("bench"); - assert_that(p.cargo("bench").arg("-v"), execs()); + assert_that(p.cargo("bench -v"), execs()); } #[test] @@ -2873,7 +2873,7 @@ fn test_all_workspace() { .build(); assert_that( - p.cargo("test").arg("--all"), + p.cargo("test --all"), execs() .with_stdout_contains("test foo_test ... ok") .with_stdout_contains("test bar_test ... ok"), @@ -2902,7 +2902,7 @@ fn test_all_exclude() { .build(); assert_that( - p.cargo("test").arg("--all").arg("--exclude").arg("baz"), + p.cargo("test --all --exclude baz"), execs().with_stdout_contains( "running 1 test test bar ... ok", @@ -2927,7 +2927,7 @@ fn test_all_virtual_manifest() { .build(); assert_that( - p.cargo("test").arg("--all"), + p.cargo("test --all"), execs() .with_stdout_contains("test a ... ok") .with_stdout_contains("test b ... ok"), @@ -2985,7 +2985,7 @@ fn test_all_member_dependency_same_name() { Package::new("a", "0.1.0").publish(); assert_that( - p.cargo("test").arg("--all"), + p.cargo("test --all"), execs().with_stdout_contains("test a ... ok"), ); } @@ -3020,7 +3020,7 @@ fn doctest_only_with_dev_dep() { .build(); assert_that( - p.cargo("test").arg("--doc").arg("-v"), + p.cargo("test --doc -v"), execs(), ); } @@ -3139,7 +3139,7 @@ fn doctest_and_registry() { Package::new("b", "0.1.0").publish(); assert_that( - p.cargo("test").arg("--all").arg("-v"), + p.cargo("test --all -v"), execs(), ); } @@ -3186,7 +3186,7 @@ fn test_order() { .build(); assert_that( - p.cargo("test").arg("--all"), + p.cargo("test --all"), execs().with_stdout_contains( " running 1 test @@ -3228,7 +3228,7 @@ fn cyclic_dev() { .file("tests/foo.rs", "extern crate foo;") .build(); - assert_that(p.cargo("test").arg("--all"), execs()); + assert_that(p.cargo("test --all"), execs()); } #[test] @@ -3270,7 +3270,7 @@ fn publish_a_crate_without_tests() { assert_that(p.cargo("test"), execs()); assert_that( - p.cargo("test").arg("--package").arg("testless"), + p.cargo("test --package testless"), execs(), ); } @@ -3374,7 +3374,7 @@ fn test_hint_not_masked_by_doctest() { ) .build(); assert_that( - p.cargo("test").arg("--no-fail-fast"), + p.cargo("test --no-fail-fast"), execs() .with_status(101) .with_stdout_contains("test this_fails ... FAILED") diff --git a/tests/testsuite/tool_paths.rs b/tests/testsuite/tool_paths.rs index ab07d2135..102e1089d 100644 --- a/tests/testsuite/tool_paths.rs +++ b/tests/testsuite/tool_paths.rs @@ -23,7 +23,7 @@ fn pathless_tools() { .build(); assert_that( - foo.cargo("build").arg("--verbose"), + foo.cargo("build --verbose"), execs().with_stderr(&format!( "\ [COMPILING] foo v0.5.0 ({url}) @@ -77,7 +77,7 @@ fn absolute_tools() { }; assert_that( - foo.cargo("build").arg("--verbose"), + foo.cargo("build --verbose"), execs().with_stderr(&format!( "\ [COMPILING] foo v0.5.0 ({url}) diff --git a/tests/testsuite/update.rs b/tests/testsuite/update.rs index df480c0ef..5a416768c 100644 --- a/tests/testsuite/update.rs +++ b/tests/testsuite/update.rs @@ -110,7 +110,7 @@ fn transitive_minor_update() { // Also note that this is probably counterintuitive and weird. We may wish // to change this one day. assert_that( - p.cargo("update").arg("-p").arg("serde"), + p.cargo("update -p serde"), execs().with_stderr( "\ [UPDATING] registry `[..]` @@ -161,7 +161,7 @@ fn conservative() { Package::new("serde", "0.1.1").dep("log", "0.1").publish(); assert_that( - p.cargo("update").arg("-p").arg("serde"), + p.cargo("update -p serde"), execs().with_stderr( "\ [UPDATING] registry `[..]` diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index 4cbfccc3f..22bc3ea70 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -999,7 +999,7 @@ fn new_warns_you_this_will_not_work() { let p = p.build(); assert_that( - p.cargo("new").arg("--lib").arg("bar").env("USER", "foo"), + p.cargo("new --lib bar").env("USER", "foo"), execs().with_stderr( "\ warning: compiling this new crate may not work due to invalid workspace \ @@ -1867,7 +1867,7 @@ fn dep_used_with_separate_features() { // Build the entire workspace assert_that( - p.cargo("build").arg("--all"), + p.cargo("build --all"), execs().with_stderr( "\ [..]Compiling feat_lib v0.1.0 ([..]) @@ -2015,7 +2015,7 @@ fn cargo_home_at_root_works() { assert_that(p.cargo("build"), execs()); assert_that( - p.cargo("build").arg("--frozen").env("CARGO_HOME", p.root()), + p.cargo("build --frozen").env("CARGO_HOME", p.root()), execs(), ); } From 511d4bc503c4e33e352083799bf49ae8e5aeb0c1 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Sat, 18 Aug 2018 15:12:15 +0100 Subject: [PATCH 2/4] Collapse multiline ProcessBuilder::arg calls in tests .. by calling this a bunch of times: fastmod --multiline '\.cargo\("([^"]+)"\).[ ]+\.arg\("([^"]+)"\)' '.cargo("${1} ${2}")' tests/testsuite/ --- tests/testsuite/bad_config.rs | 4 +- tests/testsuite/bad_manifest_path.rs | 16 ++--- tests/testsuite/bench.rs | 14 +---- tests/testsuite/build.rs | 53 ++++------------ tests/testsuite/build_script.rs | 12 ++-- tests/testsuite/cargo_features.rs | 3 +- tests/testsuite/check.rs | 12 +--- tests/testsuite/concurrent.rs | 6 +- tests/testsuite/cross_compile.rs | 4 +- tests/testsuite/cross_publish.rs | 3 +- tests/testsuite/custom_target.rs | 18 +----- tests/testsuite/doc.rs | 11 +--- tests/testsuite/features.rs | 8 +-- tests/testsuite/git.rs | 11 +--- tests/testsuite/metadata.rs | 34 +++------- tests/testsuite/overrides.rs | 7 +-- tests/testsuite/package.rs | 3 +- tests/testsuite/path.rs | 3 +- tests/testsuite/publish.rs | 43 ++++--------- tests/testsuite/read_manifest.rs | 14 ++--- tests/testsuite/registry.rs | 10 +-- tests/testsuite/required_features.rs | 79 +++++------------------- tests/testsuite/run.rs | 28 ++------- tests/testsuite/rustc.rs | 25 ++------ tests/testsuite/rustdoc.rs | 7 +-- tests/testsuite/rustdocflags.rs | 6 +- tests/testsuite/rustflags.rs | 4 +- tests/testsuite/support/cross_compile.rs | 3 +- tests/testsuite/test.rs | 38 ++---------- tests/testsuite/update.rs | 6 +- tests/testsuite/verify_project.rs | 7 +-- 31 files changed, 110 insertions(+), 382 deletions(-) diff --git a/tests/testsuite/bad_config.rs b/tests/testsuite/bad_config.rs index 5df0464bd..80e05b746 100644 --- a/tests/testsuite/bad_config.rs +++ b/tests/testsuite/bad_config.rs @@ -15,9 +15,7 @@ fn bad1() { ) .build(); assert_that( - p.cargo("build") - .arg("-v") - .arg("--target=nonexistent-target"), + p.cargo("build -v --target=nonexistent-target"), execs().with_status(101).with_stderr( "\ [ERROR] expected table for configuration key `target.nonexistent-target`, \ diff --git a/tests/testsuite/bad_manifest_path.rs b/tests/testsuite/bad_manifest_path.rs index 170534c8f..85acc71fb 100644 --- a/tests/testsuite/bad_manifest_path.rs +++ b/tests/testsuite/bad_manifest_path.rs @@ -326,9 +326,7 @@ fn verify_project_dir_containing_cargo_toml() { .build(); assert_that( - p.cargo("verify-project") - .arg("--manifest-path") - .arg("foo") + p.cargo("verify-project --manifest-path foo") .cwd(p.root().parent().unwrap()), execs().with_status(1).with_stdout( "{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\ @@ -345,9 +343,7 @@ fn verify_project_dir_plus_file() { .build(); assert_that( - p.cargo("verify-project") - .arg("--manifest-path") - .arg("foo/bar") + p.cargo("verify-project --manifest-path foo/bar") .cwd(p.root().parent().unwrap()), execs().with_status(1).with_stdout( "{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\ @@ -364,9 +360,7 @@ fn verify_project_dir_plus_path() { .build(); assert_that( - p.cargo("verify-project") - .arg("--manifest-path") - .arg("foo/bar/baz") + p.cargo("verify-project --manifest-path foo/bar/baz") .cwd(p.root().parent().unwrap()), execs().with_status(1).with_stdout( "{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\ @@ -379,9 +373,7 @@ fn verify_project_dir_plus_path() { fn verify_project_dir_to_nonexistent_cargo_toml() { let p = project().build(); assert_that( - p.cargo("verify-project") - .arg("--manifest-path") - .arg("foo/bar/baz/Cargo.toml") + p.cargo("verify-project --manifest-path foo/bar/baz/Cargo.toml") .cwd(p.root().parent().unwrap()), execs().with_status(1).with_stdout( "{\"invalid\":\"manifest path `foo[..]bar[..]baz[..]Cargo.toml` does not exist\"}\ diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index d78b25ccc..a4e04b57d 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -219,11 +219,7 @@ fn bench_multiple_targets() { .build(); assert_that( - p.cargo("bench") - .arg("--bench") - .arg("bin1") - .arg("--bench") - .arg("bin2"), + p.cargo("bench --bench bin1 --bench bin2"), execs() .with_stdout_contains("test run1 ... bench: [..]") .with_stdout_contains("test run2 ... bench: [..]") @@ -680,8 +676,7 @@ fn bench_autodiscover_2015() { .build(); assert_that( - p.cargo("bench") - .arg("bench_basic") + p.cargo("bench bench_basic") .masquerade_as_nightly_cargo(), execs().with_stderr(&format!( "warning: \ @@ -1322,10 +1317,7 @@ fn test_bench_no_fail_fast() { .build(); assert_that( - p.cargo("bench") - .arg("--no-fail-fast") - .arg("--") - .arg("--test-threads=1"), + p.cargo("bench --no-fail-fast -- --test-threads=1"), execs() .with_status(101) .with_stderr_contains("[RUNNING] target/release/deps/foo-[..][EXE]") diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 81bdee05e..2404c3d68 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -98,17 +98,13 @@ fn incremental_profile() { ); assert_that( - p.cargo("build") - .arg("--release") - .arg("-v") + p.cargo("build --release -v") .env_remove("CARGO_INCREMENTAL"), execs().with_stderr_contains("[..]C incremental=[..]"), ); assert_that( - p.cargo("build") - .arg("--release") - .arg("-v") + p.cargo("build --release -v") .env("CARGO_INCREMENTAL", "0"), execs().with_stderr_does_not_contain("[..]C incremental=[..]"), ); @@ -162,9 +158,7 @@ fn cargo_compile_manifest_path() { .build(); assert_that( - p.cargo("build") - .arg("--manifest-path") - .arg("foo/Cargo.toml") + p.cargo("build --manifest-path foo/Cargo.toml") .cwd(p.root().parent().unwrap()), execs(), ); @@ -223,9 +217,7 @@ fn cargo_compile_with_invalid_manifest3() { .build(); assert_that( - p.cargo("build") - .arg("--manifest-path") - .arg("src/Cargo.toml"), + p.cargo("build --manifest-path src/Cargo.toml"), execs().with_status(101).with_stderr( "\ [ERROR] failed to parse manifest at `[..]` @@ -1411,8 +1403,7 @@ fn cargo_default_env_metadata_env_var() { // If you set the env-var, then we expect metadata on libbar assert_that( - p.cargo("build") - .arg("-v") + p.cargo("build -v") .env("__CARGO_DEFAULT_LIB_METADATA", "stable"), execs().with_stderr(&format!( "\ @@ -2742,9 +2733,7 @@ fn example_bin_same_name() { .file("examples/foo.rs", "fn main() {}") .build(); - p.cargo("test") - .arg("--no-run") - .arg("-v") + p.cargo("test --no-run -v") .exec_with_output() .unwrap(); @@ -2752,9 +2741,7 @@ fn example_bin_same_name() { // We expect a file of the form bin/foo-{metadata_hash} assert_that(&p.bin("examples/foo"), existing_file()); - p.cargo("test") - .arg("--no-run") - .arg("-v") + p.cargo("test --no-run -v") .exec_with_output() .unwrap(); @@ -3266,11 +3253,7 @@ fn invalid_spec() { ); assert_that( - p.cargo("build") - .arg("-p") - .arg("d1") - .arg("-p") - .arg("notAValidDep"), + p.cargo("build -p d1 -p notAValidDep"), execs() .with_status(101) .with_stderr("[ERROR] package id specification `notAValidDep` matched no packages"), @@ -3585,12 +3568,7 @@ fn message_format_json_forward_stderr() { .build(); assert_that( - p.cargo("rustc") - .arg("--release") - .arg("--bin") - .arg("foo") - .arg("--message-format") - .arg("JSON"), + p.cargo("rustc --release --bin foo --message-format JSON"), execs().with_json( r#" { @@ -4087,8 +4065,7 @@ fn rustc_wrapper() { .build(); assert_that( - p.cargo("build") - .arg("-v") + p.cargo("build -v") .env("RUSTC_WRAPPER", "/usr/bin/env"), execs().with_stderr_contains("[RUNNING] `/usr/bin/env rustc --crate-name foo [..]"), ); @@ -4536,10 +4513,7 @@ fn uplift_dsym_of_bin_on_mac() { .build(); assert_that( - p.cargo("build") - .arg("--bins") - .arg("--examples") - .arg("--tests"), + p.cargo("build --bins --examples --tests"), execs(), ); assert_that(&p.bin("foo.dSYM"), existing_dir()); @@ -4568,10 +4542,7 @@ fn uplift_pdb_of_bin_on_windows() { .build(); assert_that( - p.cargo("build") - .arg("--bins") - .arg("--examples") - .arg("--tests"), + p.cargo("build --bins --examples --tests"), execs(), ); assert_that(&p.target_debug_dir().join("foo.pdb"), existing_file()); diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index 20925a989..2bd9d9a5b 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -1562,15 +1562,13 @@ fn build_script_with_dynamic_native_dependency() { assert_that( build - .cargo("build") - .arg("-v") + .cargo("build -v") .env("RUST_LOG", "cargo::ops::cargo_rustc"), execs(), ); assert_that( - foo.cargo("build") - .arg("-v") + foo.cargo("build -v") .env("SRC", build.root()) .env("RUST_LOG", "cargo::ops::cargo_rustc"), execs(), @@ -2435,8 +2433,7 @@ fn fresh_builds_possible_with_link_libs() { ); assert_that( - p.cargo("build") - .arg("-v") + p.cargo("build -v") .env("RUST_LOG", "cargo::ops::cargo_rustc::fingerprint=info"), execs().with_stderr( "\ @@ -2493,8 +2490,7 @@ fn fresh_builds_possible_with_multiple_metadata_overrides() { ); assert_that( - p.cargo("build") - .arg("-v") + p.cargo("build -v") .env("RUST_LOG", "cargo::ops::cargo_rustc::fingerprint=info"), execs().with_stderr( "\ diff --git a/tests/testsuite/cargo_features.rs b/tests/testsuite/cargo_features.rs index cbb1a9e4f..c9a920092 100644 --- a/tests/testsuite/cargo_features.rs +++ b/tests/testsuite/cargo_features.rs @@ -320,8 +320,7 @@ fn publish_allowed() { .file("src/lib.rs", "") .build(); assert_that( - p.cargo("publish") - .arg("--index") + p.cargo("publish --index") .arg(publish::registry().to_string()) .masquerade_as_nightly_cargo(), execs(), diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index fdf7efba6..1e942e2e2 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -317,11 +317,7 @@ fn rustc_check() { .build(); assert_that( - foo.cargo("rustc") - .arg("--profile") - .arg("check") - .arg("--") - .arg("--emit=metadata"), + foo.cargo("rustc --profile check -- --emit=metadata"), execs(), ); } @@ -349,11 +345,7 @@ fn rustc_check_err() { .build(); assert_that( - foo.cargo("rustc") - .arg("--profile") - .arg("check") - .arg("--") - .arg("--emit=metadata"), + foo.cargo("rustc --profile check -- --emit=metadata"), execs().with_status(101), ); } diff --git a/tests/testsuite/concurrent.rs b/tests/testsuite/concurrent.rs index a2b5c2d59..9c6efa141 100644 --- a/tests/testsuite/concurrent.rs +++ b/tests/testsuite/concurrent.rs @@ -246,12 +246,10 @@ fn git_same_repo_different_tags() { .file("b/src/main.rs", "extern crate dep; fn main() { dep::tag2(); }"); let p = p.build(); - let mut a = p.cargo("build") - .arg("-v") + let mut a = p.cargo("build -v") .cwd(p.root().join("a")) .build_command(); - let mut b = p.cargo("build") - .arg("-v") + let mut b = p.cargo("build -v") .cwd(p.root().join("b")) .build_command(); diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs index b4b66b197..ec97d495e 100644 --- a/tests/testsuite/cross_compile.rs +++ b/tests/testsuite/cross_compile.rs @@ -980,9 +980,7 @@ fn plugin_build_script_right_arch() { .build(); assert_that( - p.cargo("build") - .arg("-v") - .arg("--target") + p.cargo("build -v --target") .arg(cross_compile::alternate()), execs().with_stderr( "\ diff --git a/tests/testsuite/cross_publish.rs b/tests/testsuite/cross_publish.rs index cff23e9f6..951086eb1 100644 --- a/tests/testsuite/cross_publish.rs +++ b/tests/testsuite/cross_publish.rs @@ -116,8 +116,7 @@ fn publish_with_target() { let target = cross_compile::alternate(); assert_that( - p.cargo("publish") - .arg("--index") + p.cargo("publish --index") .arg(publish::registry().to_string()) .arg("--target") .arg(&target), diff --git a/tests/testsuite/custom_target.rs b/tests/testsuite/custom_target.rs index 03b153bc6..dcb4c7d69 100644 --- a/tests/testsuite/custom_target.rs +++ b/tests/testsuite/custom_target.rs @@ -47,19 +47,11 @@ fn custom_target_minimal() { .build(); assert_that( - p.cargo("build") - .arg("--lib") - .arg("--target") - .arg("custom-target.json") - .arg("-v"), + p.cargo("build --lib --target custom-target.json -v"), execs(), ); assert_that( - p.cargo("build") - .arg("--lib") - .arg("--target") - .arg("src/../custom-target.json") - .arg("-v"), + p.cargo("build --lib --target src/../custom-target.json -v"), execs(), ); } @@ -141,11 +133,7 @@ fn custom_target_dependency() { .build(); assert_that( - p.cargo("build") - .arg("--lib") - .arg("--target") - .arg("custom-target.json") - .arg("-v"), + p.cargo("build --lib --target custom-target.json -v"), execs(), ); } diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index c2892ec03..f65f41dd2 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -845,12 +845,7 @@ fn doc_multiple_deps() { .build(); assert_that( - p.cargo("doc") - .arg("-p") - .arg("bar") - .arg("-p") - .arg("baz") - .arg("-v"), + p.cargo("doc -p bar -p baz -v"), execs(), ); @@ -982,9 +977,7 @@ fn plugins_no_use_target() { .file("src/lib.rs", "") .build(); assert_that( - p.cargo("doc") - .arg("--target=x86_64-unknown-openbsd") - .arg("-v"), + p.cargo("doc --target=x86_64-unknown-openbsd -v"), execs(), ); } diff --git a/tests/testsuite/features.rs b/tests/testsuite/features.rs index 082cc9f6f..c5aaac6a5 100644 --- a/tests/testsuite/features.rs +++ b/tests/testsuite/features.rs @@ -1222,9 +1222,7 @@ fn dep_feature_in_cmd_line() { // We should be able to enable the feature "derived-feat", which enables "some-feat", // on the command line. The feature is enabled, thus building should be successful: assert_that( - p.cargo("build") - .arg("--features") - .arg("derived/derived-feat"), + p.cargo("build --features derived/derived-feat"), execs(), ); @@ -1238,9 +1236,7 @@ fn dep_feature_in_cmd_line() { // Hierarchical feature specification should still be disallowed assert_that( - p.cargo("build") - .arg("--features") - .arg("derived/bar/some-feat"), + p.cargo("build --features derived/bar/some-feat"), execs() .with_status(101) .with_stderr("[ERROR] feature names may not contain slashes: `bar/some-feat`"), diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index a39331213..04b658ff4 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -945,11 +945,7 @@ fn update_with_shared_deps() { // Don't do anything bad on a weird --precise argument println!("bar bad precise update"); assert_that( - p.cargo("update") - .arg("-p") - .arg("bar") - .arg("--precise") - .arg("0.1.2"), + p.cargo("update -p bar --precise 0.1.2"), execs().with_status(101).with_stderr( "\ [UPDATING] git repository [..] @@ -965,10 +961,7 @@ Caused by: // anything because we already have the rev in the db. println!("bar precise update"); assert_that( - p.cargo("update") - .arg("-p") - .arg("bar") - .arg("--precise") + p.cargo("update -p bar --precise") .arg(&old_head.to_string()), execs().with_stdout(""), ); diff --git a/tests/testsuite/metadata.rs b/tests/testsuite/metadata.rs index 86a898d2e..e1b7edb71 100644 --- a/tests/testsuite/metadata.rs +++ b/tests/testsuite/metadata.rs @@ -277,10 +277,7 @@ fn cargo_metadata_with_deps_and_version() { Package::new("bar", "0.0.1").dep("baz", "0.0.1").publish(); assert_that( - p.cargo("metadata") - .arg("-q") - .arg("--format-version") - .arg("1"), + p.cargo("metadata -q --format-version 1"), execs().with_json( r#" { @@ -875,10 +872,7 @@ fn cargo_metadata_no_deps_path_to_cargo_toml_relative() { .build(); assert_that( - p.cargo("metadata") - .arg("--no-deps") - .arg("--manifest-path") - .arg("foo/Cargo.toml") + p.cargo("metadata --no-deps --manifest-path foo/Cargo.toml") .cwd(p.root().parent().unwrap()), execs().with_json(MANIFEST_OUTPUT), ); @@ -892,9 +886,7 @@ fn cargo_metadata_no_deps_path_to_cargo_toml_absolute() { .build(); assert_that( - p.cargo("metadata") - .arg("--no-deps") - .arg("--manifest-path") + p.cargo("metadata --no-deps --manifest-path") .arg(p.root().join("Cargo.toml")) .cwd(p.root().parent().unwrap()), execs().with_json(MANIFEST_OUTPUT), @@ -909,10 +901,7 @@ fn cargo_metadata_no_deps_path_to_cargo_toml_parent_relative() { .build(); assert_that( - p.cargo("metadata") - .arg("--no-deps") - .arg("--manifest-path") - .arg("foo") + p.cargo("metadata --no-deps --manifest-path foo") .cwd(p.root().parent().unwrap()), execs().with_status(101).with_stderr( "[ERROR] the manifest-path must be \ @@ -929,9 +918,7 @@ fn cargo_metadata_no_deps_path_to_cargo_toml_parent_absolute() { .build(); assert_that( - p.cargo("metadata") - .arg("--no-deps") - .arg("--manifest-path") + p.cargo("metadata --no-deps --manifest-path") .arg(p.root()) .cwd(p.root().parent().unwrap()), execs().with_status(101).with_stderr( @@ -962,10 +949,7 @@ fn cargo_metadata_bad_version() { .build(); assert_that( - p.cargo("metadata") - .arg("--no-deps") - .arg("--format-version") - .arg("2") + p.cargo("metadata --no-deps --format-version 2") .cwd(p.root()), execs().with_status(1).with_stderr_contains( "\ @@ -1087,16 +1071,14 @@ fn cargo_metadata_path_to_cargo_toml_project() { .build(); assert_that( - p.cargo("package") - .arg("--manifest-path") + p.cargo("package --manifest-path") .arg(p.root().join("bar/Cargo.toml")) .cwd(p.root().parent().unwrap()), execs() ); assert_that( - p.cargo("metadata") - .arg("--manifest-path") + p.cargo("metadata --manifest-path") .arg(p.root().join("target/package/bar-0.5.0/Cargo.toml")), execs().with_json( r#" diff --git a/tests/testsuite/overrides.rs b/tests/testsuite/overrides.rs index 8216e0495..39e745189 100644 --- a/tests/testsuite/overrides.rs +++ b/tests/testsuite/overrides.rs @@ -425,8 +425,7 @@ fn override_adds_some_deps() { Package::new("baz", "0.1.2").publish(); assert_that( - p.cargo("update") - .arg("-p") + p.cargo("update -p") .arg(&format!("{}#bar", foo.url())), execs().with_stderr( "\ @@ -436,9 +435,7 @@ fn override_adds_some_deps() { ), ); assert_that( - p.cargo("update") - .arg("-p") - .arg("https://github.com/rust-lang/crates.io-index#bar"), + p.cargo("update -p https://github.com/rust-lang/crates.io-index#bar"), execs().with_stderr( "\ [UPDATING] registry `file://[..]` diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index 11d6a29ad..083513e2b 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -867,8 +867,7 @@ fn ignore_workspace_specifier() { .build(); assert_that( - p.cargo("package") - .arg("--no-verify") + p.cargo("package --no-verify") .cwd(p.root().join("bar")), execs(), ); diff --git a/tests/testsuite/path.rs b/tests/testsuite/path.rs index 54b1fe566..225916f08 100644 --- a/tests/testsuite/path.rs +++ b/tests/testsuite/path.rs @@ -881,8 +881,7 @@ fn custom_target_no_rebuild() { p.root().join("target_moved") )); assert_that( - p.cargo("build") - .arg("--manifest-path=b/Cargo.toml") + p.cargo("build --manifest-path=b/Cargo.toml") .env("CARGO_TARGET_DIR", "target_moved"), execs().with_stderr( "\ diff --git a/tests/testsuite/publish.rs b/tests/testsuite/publish.rs index a27111a0f..fb2b5bf08 100644 --- a/tests/testsuite/publish.rs +++ b/tests/testsuite/publish.rs @@ -30,9 +30,7 @@ fn simple() { .build(); assert_that( - p.cargo("publish") - .arg("--no-verify") - .arg("--index") + p.cargo("publish --no-verify --index") .arg(publish::registry().to_string()), execs().with_stderr(&format!( "\ @@ -106,9 +104,7 @@ fn old_token_location() { .build(); assert_that( - p.cargo("publish") - .arg("--no-verify") - .arg("--index") + p.cargo("publish --no-verify --index") .arg(publish::registry().to_string()), execs().with_stderr(&format!( "\ @@ -175,9 +171,7 @@ fn simple_with_host() { .build(); assert_that( - p.cargo("publish") - .arg("--no-verify") - .arg("--host") + p.cargo("publish --no-verify --host") .arg(publish::registry().to_string()), execs().with_stderr(&format!( "\ @@ -253,9 +247,7 @@ fn simple_with_index_and_host() { .build(); assert_that( - p.cargo("publish") - .arg("--no-verify") - .arg("--index") + p.cargo("publish --no-verify --index") .arg(publish::registry().to_string()) .arg("--host") .arg(publish::registry().to_string()), @@ -334,10 +326,7 @@ fn git_deps() { .build(); assert_that( - p.cargo("publish") - .arg("-v") - .arg("--no-verify") - .arg("--index") + p.cargo("publish -v --no-verify --index") .arg(publish::registry().to_string()), execs().with_status(101).with_stderr( "\ @@ -377,8 +366,7 @@ fn path_dependency_no_version() { .build(); assert_that( - p.cargo("publish") - .arg("--index") + p.cargo("publish --index") .arg(publish::registry().to_string()), execs().with_status(101).with_stderr( "\ @@ -411,8 +399,7 @@ fn unpublishable_crate() { .build(); assert_that( - p.cargo("publish") - .arg("--index") + p.cargo("publish --index") .arg(publish::registry().to_string()), execs().with_status(101).with_stderr( "\ @@ -447,8 +434,7 @@ fn dont_publish_dirty() { .build(); assert_that( - p.cargo("publish") - .arg("--index") + p.cargo("publish --index") .arg(publish::registry().to_string()), execs().with_status(101).with_stderr( "\ @@ -489,8 +475,7 @@ fn publish_clean() { .build(); assert_that( - p.cargo("publish") - .arg("--index") + p.cargo("publish --index") .arg(publish::registry().to_string()), execs(), ); @@ -555,8 +540,7 @@ fn publish_when_ignored() { .build(); assert_that( - p.cargo("publish") - .arg("--index") + p.cargo("publish --index") .arg(publish::registry().to_string()), execs(), ); @@ -617,8 +601,7 @@ fn new_crate_rejected() { ) .nocommit_file("src/main.rs", "fn main() {}"); assert_that( - p.cargo("publish") - .arg("--index") + p.cargo("publish --index") .arg(publish::registry().to_string()), execs().with_status(101), ); @@ -644,9 +627,7 @@ fn dry_run() { .build(); assert_that( - p.cargo("publish") - .arg("--dry-run") - .arg("--index") + p.cargo("publish --dry-run --index") .arg(publish::registry().to_string()), execs().with_stderr(&format!( "\ diff --git a/tests/testsuite/read_manifest.rs b/tests/testsuite/read_manifest.rs index 71d112d47..2d8553e94 100644 --- a/tests/testsuite/read_manifest.rs +++ b/tests/testsuite/read_manifest.rs @@ -39,9 +39,7 @@ fn cargo_read_manifest_path_to_cargo_toml_relative() { .build(); assert_that( - p.cargo("read-manifest") - .arg("--manifest-path") - .arg("foo/Cargo.toml") + p.cargo("read-manifest --manifest-path foo/Cargo.toml") .cwd(p.root().parent().unwrap()), execs().with_json(MANIFEST_OUTPUT), ); @@ -55,8 +53,7 @@ fn cargo_read_manifest_path_to_cargo_toml_absolute() { .build(); assert_that( - p.cargo("read-manifest") - .arg("--manifest-path") + p.cargo("read-manifest --manifest-path") .arg(p.root().join("Cargo.toml")) .cwd(p.root().parent().unwrap()), execs().with_json(MANIFEST_OUTPUT), @@ -71,9 +68,7 @@ fn cargo_read_manifest_path_to_cargo_toml_parent_relative() { .build(); assert_that( - p.cargo("read-manifest") - .arg("--manifest-path") - .arg("foo") + p.cargo("read-manifest --manifest-path foo") .cwd(p.root().parent().unwrap()), execs().with_status(101).with_stderr( "[ERROR] the manifest-path must be \ @@ -90,8 +85,7 @@ fn cargo_read_manifest_path_to_cargo_toml_parent_absolute() { .build(); assert_that( - p.cargo("read-manifest") - .arg("--manifest-path") + p.cargo("read-manifest --manifest-path") .arg(p.root()) .cwd(p.root().parent().unwrap()), execs().with_status(101).with_stderr( diff --git a/tests/testsuite/registry.rs b/tests/testsuite/registry.rs index b1d3dec84..c66beda83 100644 --- a/tests/testsuite/registry.rs +++ b/tests/testsuite/registry.rs @@ -672,11 +672,7 @@ fn update_lockfile() { paths::home().join(".cargo/registry").rm_rf(); println!("0.0.2 update"); assert_that( - p.cargo("update") - .arg("-p") - .arg("bar") - .arg("--precise") - .arg("0.0.2"), + p.cargo("update -p bar --precise 0.0.2"), execs().with_stderr( "\ [UPDATING] registry `[..]` @@ -864,9 +860,7 @@ fn bad_license_file() { .file("src/main.rs", "fn main() {}") .build(); assert_that( - p.cargo("publish") - .arg("-v") - .arg("--index") + p.cargo("publish -v --index") .arg(registry().to_string()), execs() .with_status(101) diff --git a/tests/testsuite/required_features.rs b/tests/testsuite/required_features.rs index 258791387..86aafb5a5 100644 --- a/tests/testsuite/required_features.rs +++ b/tests/testsuite/required_features.rs @@ -51,9 +51,7 @@ fn build_bin_default_features() { assert_that(&p.bin("foo"), existing_file()); assert_that( - p.cargo("build") - .arg("--bin=foo") - .arg("--no-default-features"), + p.cargo("build --bin=foo --no-default-features"), execs().with_status(101).with_stderr( "\ error: target `foo` in package `foo` requires the features: `a` @@ -173,9 +171,7 @@ fn build_example_default_features() { assert_that(&p.bin("examples/foo"), existing_file()); assert_that( - p.cargo("build") - .arg("--example=foo") - .arg("--no-default-features"), + p.cargo("build --example=foo --no-default-features"), execs().with_status(101).with_stderr( "\ error: target `foo` in package `foo` requires the features: `a` @@ -208,10 +204,7 @@ fn build_example_arg_features() { .build(); assert_that( - p.cargo("build") - .arg("--example=foo") - .arg("--features") - .arg("a"), + p.cargo("build --example=foo --features a"), execs(), ); assert_that(&p.bin("examples/foo"), existing_file()); @@ -265,17 +258,11 @@ Consider enabling them by passing e.g. `--features=\"b c\"` assert_that(&p.bin("examples/foo_2"), existing_file()); assert_that( - p.cargo("build") - .arg("--example=foo_1") - .arg("--features") - .arg("c"), + p.cargo("build --example=foo_1 --features c"), execs(), ); assert_that( - p.cargo("build") - .arg("--example=foo_2") - .arg("--features") - .arg("c"), + p.cargo("build --example=foo_2 --features c"), execs(), ); @@ -283,9 +270,7 @@ Consider enabling them by passing e.g. `--features=\"b c\"` assert_that(&p.bin("examples/foo_2"), existing_file()); assert_that( - p.cargo("build") - .arg("--example=foo_1") - .arg("--no-default-features"), + p.cargo("build --example=foo_1 --no-default-features"), execs().with_status(101).with_stderr( "\ error: target `foo_1` in package `foo` requires the features: `b`, `c` @@ -294,9 +279,7 @@ Consider enabling them by passing e.g. `--features=\"b c\"` ), ); assert_that( - p.cargo("build") - .arg("--example=foo_2") - .arg("--no-default-features"), + p.cargo("build --example=foo_2 --no-default-features"), execs().with_status(101).with_stderr( "\ error: target `foo_2` in package `foo` requires the features: `a` @@ -363,9 +346,7 @@ fn test_default_features() { ); assert_that( - p.cargo("test") - .arg("--test=foo") - .arg("--no-default-features"), + p.cargo("test --test=foo --no-default-features"), execs().with_status(101).with_stderr( "\ error: target `foo` in package `foo` requires the features: `a` @@ -546,9 +527,7 @@ fn bench_default_features() { ); assert_that( - p.cargo("bench") - .arg("--bench=foo") - .arg("--no-default-features"), + p.cargo("bench --bench=foo --no-default-features"), execs().with_status(101).with_stderr( "\ error: target `foo` in package `foo` requires the features: `a` @@ -746,9 +725,7 @@ fn install_default_features() { assert_that(p.cargo("uninstall foo"), execs()); assert_that( - p.cargo("install --path .") - .arg("--bin=foo") - .arg("--no-default-features"), + p.cargo("install --path . --bin=foo --no-default-features"), execs().with_status(101).with_stderr( "\ [INSTALLING] foo v0.0.1 ([..]) @@ -771,9 +748,7 @@ Consider enabling them by passing e.g. `--features=\"a\"` assert_that(p.cargo("uninstall foo"), execs()); assert_that( - p.cargo("install --path .") - .arg("--example=foo") - .arg("--no-default-features"), + p.cargo("install --path . --example=foo --no-default-features"), execs().with_status(101).with_stderr( "\ [INSTALLING] foo v0.0.1 ([..]) @@ -1060,10 +1035,7 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` ); assert_that( - p.cargo("build") - .arg("--bin=foo") - .arg("--features") - .arg("bar/a"), + p.cargo("build --bin=foo --features bar/a"), execs(), ); assert_that(&p.bin("foo"), existing_file()); @@ -1080,10 +1052,7 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` ); assert_that( - p.cargo("build") - .arg("--example=foo") - .arg("--features") - .arg("bar/a"), + p.cargo("build --example=foo --features bar/a"), execs(), ); assert_that(&p.bin("examples/foo"), existing_file()); @@ -1099,10 +1068,7 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` ); assert_that( - p.cargo("test") - .arg("--test=foo") - .arg("--features") - .arg("bar/a"), + p.cargo("test --test=foo --features bar/a"), execs() .with_stderr(format!( "\ @@ -1124,10 +1090,7 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` ); assert_that( - p.cargo("bench") - .arg("--bench=foo") - .arg("--features") - .arg("bar/a"), + p.cargo("bench --bench=foo --features bar/a"), execs() .with_stderr(format!( "\ @@ -1201,11 +1164,7 @@ fn test_skips_compiling_bin_with_missing_required_features() { ); assert_that( - p.cargo("test") - .arg("--features") - .arg("a") - .arg("-j") - .arg("1"), + p.cargo("test --features a -j 1"), execs().with_status(101).with_stderr_contains(format!( "\ [COMPILING] foo v0.0.1 ({}) @@ -1229,11 +1188,7 @@ error[E0463]: can't find crate for `bar`", ); assert_that( - p.cargo("bench") - .arg("--features") - .arg("a") - .arg("-j") - .arg("1"), + p.cargo("bench --features a -j 1"), execs().with_status(101).with_stderr_contains(format!( "\ [COMPILING] foo v0.0.1 ({}) diff --git a/tests/testsuite/run.rs b/tests/testsuite/run.rs index 38671bad6..c3405156e 100644 --- a/tests/testsuite/run.rs +++ b/tests/testsuite/run.rs @@ -446,9 +446,7 @@ fn run_example_autodiscover_2015() { let p = autodiscover_examples_project("2015", None); assert_that( - p.cargo("run") - .arg("--example") - .arg("a") + p.cargo("run --example a") .masquerade_as_nightly_cargo(), execs().with_status(101).with_stderr( "warning: \ @@ -481,9 +479,7 @@ fn run_example_autodiscover_2015_with_autoexamples_enabled() { let p = autodiscover_examples_project("2015", Some(true)); assert_that( - p.cargo("run") - .arg("--example") - .arg("a") + p.cargo("run --example a") .masquerade_as_nightly_cargo(), execs() .with_stderr(&format!( @@ -505,9 +501,7 @@ fn run_example_autodiscover_2015_with_autoexamples_disabled() { let p = autodiscover_examples_project("2015", Some(false)); assert_that( - p.cargo("run") - .arg("--example") - .arg("a") + p.cargo("run --example a") .masquerade_as_nightly_cargo(), execs() .with_status(101) @@ -523,9 +517,7 @@ fn run_example_autodiscover_2018() { let p = autodiscover_examples_project("2018", None); assert_that( - p.cargo("run") - .arg("--example") - .arg("a") + p.cargo("run --example a") .masquerade_as_nightly_cargo(), execs() .with_stderr(&format!( @@ -612,11 +604,7 @@ fn either_name_or_example() { .build(); assert_that( - p.cargo("run") - .arg("--bin") - .arg("a") - .arg("--example") - .arg("b"), + p.cargo("run --bin a --example b"), execs().with_status(101).with_stderr( "[ERROR] `cargo run` can run at most one \ executable, but multiple were \ @@ -695,11 +683,7 @@ fn example_with_release_flag() { .build(); assert_that( - p.cargo("run") - .arg("-v") - .arg("--release") - .arg("--example") - .arg("a"), + p.cargo("run -v --release --example a"), execs() .with_stderr(&format!( "\ diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index e554a4200..1e0d29cb5 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -38,12 +38,7 @@ fn lib() { .build(); assert_that( - p.cargo("rustc") - .arg("--lib") - .arg("-v") - .arg("--") - .arg("-C") - .arg("debug-assertions=off"), + p.cargo("rustc --lib -v -- -C debug-assertions=off"), execs().with_stderr(format!( "\ [COMPILING] foo v0.0.1 ({url}) @@ -103,11 +98,7 @@ fn fails_when_trying_to_build_main_and_lib_with_args() { .build(); assert_that( - p.cargo("rustc") - .arg("-v") - .arg("--") - .arg("-C") - .arg("debug-assertions"), + p.cargo("rustc -v -- -C debug-assertions"), execs().with_status(101).with_stderr(CARGO_RUSTC_ERROR), ); } @@ -148,11 +139,7 @@ fn fails_with_args_to_all_binaries() { .build(); assert_that( - p.cargo("rustc") - .arg("-v") - .arg("--") - .arg("-C") - .arg("debug-assertions"), + p.cargo("rustc -v -- -C debug-assertions"), execs().with_status(101).with_stderr(CARGO_RUSTC_ERROR), ); } @@ -206,11 +193,7 @@ fn build_foo_with_bar_dependency() { .build(); assert_that( - foo.cargo("rustc") - .arg("-v") - .arg("--") - .arg("-C") - .arg("debug-assertions"), + foo.cargo("rustc -v -- -C debug-assertions"), execs().with_stderr(format!( "\ [COMPILING] bar v0.1.0 ([..]) diff --git a/tests/testsuite/rustdoc.rs b/tests/testsuite/rustdoc.rs index 765db5ded..2778b257d 100644 --- a/tests/testsuite/rustdoc.rs +++ b/tests/testsuite/rustdoc.rs @@ -111,12 +111,7 @@ fn rustdoc_only_bar_dependency() { .build(); assert_that( - foo.cargo("rustdoc") - .arg("-v") - .arg("-p") - .arg("bar") - .arg("--") - .arg("--cfg=foo"), + foo.cargo("rustdoc -v -p bar -- --cfg=foo"), execs().with_stderr(format!( "\ [DOCUMENTING] bar v0.0.1 ([..]) diff --git a/tests/testsuite/rustdocflags.rs b/tests/testsuite/rustdocflags.rs index 7337cf7b1..76f97169e 100644 --- a/tests/testsuite/rustdocflags.rs +++ b/tests/testsuite/rustdocflags.rs @@ -86,8 +86,7 @@ fn rustdocflags_passed_to_rustdoc_through_cargo_test() { .build(); assert_that( - p.cargo("test") - .arg("--doc") + p.cargo("test --doc") .env("RUSTDOCFLAGS", "--cfg do_not_choke"), execs(), ); @@ -100,8 +99,7 @@ fn rustdocflags_passed_to_rustdoc_through_cargo_test_only_once() { .build(); assert_that( - p.cargo("test") - .arg("--doc") + p.cargo("test --doc") .env("RUSTDOCFLAGS", "--markdown-no-toc"), execs(), ); diff --git a/tests/testsuite/rustflags.rs b/tests/testsuite/rustflags.rs index ba3e5385c..7a4217dcc 100644 --- a/tests/testsuite/rustflags.rs +++ b/tests/testsuite/rustflags.rs @@ -690,9 +690,7 @@ fn build_rustflags_normal_source_with_target() { execs().with_status(101), ); assert_that( - p.cargo("build") - .arg("--example=b") - .arg("--target") + p.cargo("build --example=b --target") .arg(host), execs().with_status(101), ); diff --git a/tests/testsuite/support/cross_compile.rs b/tests/testsuite/support/cross_compile.rs index 94c8ff7c3..85c132035 100644 --- a/tests/testsuite/support/cross_compile.rs +++ b/tests/testsuite/support/cross_compile.rs @@ -33,8 +33,7 @@ pub fn disabled() -> bool { .file("src/cross_test.rs", &main_file(r#""testing!""#, &[])) .build(); - let result = p.cargo("build") - .arg("--target") + let result = p.cargo("build --target") .arg(&cross_target) .exec_with_output(); diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index c7992fb94..602de9cc5 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -1851,11 +1851,7 @@ fn example_dev_dep() { .build(); assert_that(p.cargo("test"), execs()); assert_that( - p.cargo("run") - .arg("--example") - .arg("e1") - .arg("--release") - .arg("-v"), + p.cargo("run --example e1 --release -v"), execs(), ); } @@ -2546,13 +2542,7 @@ fn selective_test_optional_dep() { let p = p.build(); assert_that( - p.cargo("test") - .arg("-v") - .arg("--no-run") - .arg("--features") - .arg("a") - .arg("-p") - .arg("a"), + p.cargo("test -v --no-run --features a -p a"), execs().with_stderr( "\ [COMPILING] a v0.0.1 ([..]) @@ -2766,10 +2756,7 @@ fn pass_correct_cfgs_flags_to_rustdoc() { let p = p.build(); assert_that( - p.cargo("test") - .arg("--package") - .arg("feature_a") - .arg("--verbose"), + p.cargo("test --package feature_a --verbose"), execs().with_stderr_contains( "\ [DOCTEST] feature_a @@ -3070,20 +3057,7 @@ fn test_many_targets() { .build(); assert_that( - p.cargo("test") - .arg("--verbose") - .arg("--bin") - .arg("a") - .arg("--bin") - .arg("b") - .arg("--example") - .arg("a") - .arg("--example") - .arg("b") - .arg("--test") - .arg("a") - .arg("--test") - .arg("b"), + p.cargo("test --verbose --bin a --bin b --example a --example b --test a --test b"), execs() .with_stdout_contains("test bin_a ... ok") .with_stdout_contains("test bin_b ... ok") @@ -3343,9 +3317,7 @@ fn find_dependency_of_proc_macro_dependency_with_target() { .publish(); assert_that( p - .cargo("test") - .arg("--all") - .arg("--target") + .cargo("test --all --target") .arg(rustc_host()), execs(), ); diff --git a/tests/testsuite/update.rs b/tests/testsuite/update.rs index 5a416768c..ebfa3ba14 100644 --- a/tests/testsuite/update.rs +++ b/tests/testsuite/update.rs @@ -392,11 +392,7 @@ fn update_precise() { Package::new("serde", "0.2.0").publish(); assert_that( - p.cargo("update") - .arg("-p") - .arg("serde:0.2.1") - .arg("--precise") - .arg("0.2.0"), + p.cargo("update -p serde:0.2.1 --precise 0.2.0"), execs().with_stderr( "\ [UPDATING] registry `[..]` diff --git a/tests/testsuite/verify_project.rs b/tests/testsuite/verify_project.rs index 3373c26b7..0d2eb60cc 100644 --- a/tests/testsuite/verify_project.rs +++ b/tests/testsuite/verify_project.rs @@ -13,9 +13,7 @@ fn cargo_verify_project_path_to_cargo_toml_relative() { .build(); assert_that( - p.cargo("verify-project") - .arg("--manifest-path") - .arg("foo/Cargo.toml") + p.cargo("verify-project --manifest-path foo/Cargo.toml") .cwd(p.root().parent().unwrap()), execs() .with_stdout(verify_project_success_output()), @@ -30,8 +28,7 @@ fn cargo_verify_project_path_to_cargo_toml_absolute() { .build(); assert_that( - p.cargo("verify-project") - .arg("--manifest-path") + p.cargo("verify-project --manifest-path") .arg(p.root().join("Cargo.toml")) .cwd(p.root().parent().unwrap()), execs() From 0152f264057791968eba251dd46f0700cf9e5322 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Sat, 18 Aug 2018 21:34:09 +0100 Subject: [PATCH 3/4] Move .env/.masquerade_as_nightly_cargo to collapse some more p.cargo calls --- tests/testsuite/alt_registry.rs | 66 +++++++----------------- tests/testsuite/build.rs | 35 ++++++------- tests/testsuite/build_plan.rs | 18 +++---- tests/testsuite/cargo_features.rs | 7 ++- tests/testsuite/corrupt_git.rs | 8 +-- tests/testsuite/cross_compile.rs | 14 +++--- tests/testsuite/doc.rs | 2 +- tests/testsuite/generate_lockfile.rs | 5 +- tests/testsuite/git.rs | 13 ++--- tests/testsuite/package.rs | 5 +- tests/testsuite/plugins.rs | 2 +- tests/testsuite/profiles.rs | 4 +- tests/testsuite/publish.rs | 28 +++-------- tests/testsuite/registry.rs | 5 +- tests/testsuite/resolve.rs | 5 +- tests/testsuite/run.rs | 4 +- tests/testsuite/rustdocflags.rs | 2 +- tests/testsuite/rustflags.rs | 75 ++++++++++++---------------- tests/testsuite/test.rs | 7 +-- tests/testsuite/tool_paths.rs | 2 +- tests/testsuite/workspaces.rs | 12 ++--- 21 files changed, 118 insertions(+), 201 deletions(-) diff --git a/tests/testsuite/alt_registry.rs b/tests/testsuite/alt_registry.rs index 33c12aa13..23c003ced 100644 --- a/tests/testsuite/alt_registry.rs +++ b/tests/testsuite/alt_registry.rs @@ -316,10 +316,9 @@ fn cannot_publish_to_crates_io_with_registry_dependency() { Package::new("bar", "0.0.1").alternative(true).publish(); assert_that( - p.cargo("publish") - .masquerade_as_nightly_cargo() - .arg("--index") - .arg(registry::registry().to_string()), + p.cargo("publish --index") + .arg(registry::registry().to_string()) + .masquerade_as_nightly_cargo(), execs().with_status(101), ); } @@ -349,21 +348,14 @@ fn publish_with_registry_dependency() { // Login so that we have the token available assert_that( - p.cargo("login") - .masquerade_as_nightly_cargo() - .arg("--registry") - .arg("alternative") - .arg("TOKEN") - .arg("-Zunstable-options"), + p.cargo("login --registry alternative TOKEN -Zunstable-options") + .masquerade_as_nightly_cargo(), execs(), ); assert_that( - p.cargo("publish") - .masquerade_as_nightly_cargo() - .arg("--registry") - .arg("alternative") - .arg("-Zunstable-options"), + p.cargo("publish --registry alternative -Zunstable-options") + .masquerade_as_nightly_cargo(), execs(), ); } @@ -427,11 +419,8 @@ fn block_publish_due_to_no_token() { // Now perform the actual publish assert_that( - p.cargo("publish") - .masquerade_as_nightly_cargo() - .arg("--registry") - .arg("alternative") - .arg("-Zunstable-options"), + p.cargo("publish --registry alternative -Zunstable-options") + .masquerade_as_nightly_cargo(), execs() .with_status(101) .with_stderr_contains("error: no upload token found, please run `cargo login`"), @@ -460,22 +449,15 @@ fn publish_to_alt_registry() { // Login so that we have the token available assert_that( - p.cargo("login") - .masquerade_as_nightly_cargo() - .arg("--registry") - .arg("alternative") - .arg("TOKEN") - .arg("-Zunstable-options"), + p.cargo("login --registry alternative TOKEN -Zunstable-options") + .masquerade_as_nightly_cargo(), execs(), ); // Now perform the actual publish assert_that( - p.cargo("publish") - .masquerade_as_nightly_cargo() - .arg("--registry") - .arg("alternative") - .arg("-Zunstable-options"), + p.cargo("publish --registry alternative -Zunstable-options") + .masquerade_as_nightly_cargo(), execs(), ); @@ -509,21 +491,14 @@ fn publish_with_crates_io_dep() { // Login so that we have the token available assert_that( - p.cargo("login") - .masquerade_as_nightly_cargo() - .arg("--registry") - .arg("alternative") - .arg("TOKEN") - .arg("-Zunstable-options"), + p.cargo("login --registry alternative TOKEN -Zunstable-options") + .masquerade_as_nightly_cargo(), execs(), ); assert_that( - p.cargo("publish") - .masquerade_as_nightly_cargo() - .arg("--registry") - .arg("alternative") - .arg("-Zunstable-options"), + p.cargo("publish --registry alternative -Zunstable-options") + .masquerade_as_nightly_cargo(), execs(), ); } @@ -560,11 +535,8 @@ fn credentials_in_url_forbidden() { .build(); assert_that( - p.cargo("publish") - .masquerade_as_nightly_cargo() - .arg("--registry") - .arg("alternative") - .arg("-Zunstable-options"), + p.cargo("publish --registry alternative -Zunstable-options") + .masquerade_as_nightly_cargo(), execs() .with_status(101) .with_stderr_contains("error: Registry URLs may not contain credentials"), diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 2404c3d68..642c8acd5 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -964,9 +964,8 @@ fn cargo_compile_path_with_offline() { .build(); assert_that( - p.cargo("build") - .masquerade_as_nightly_cargo() - .arg("-Zoffline"), + p.cargo("build -Zoffline") + .masquerade_as_nightly_cargo(), execs(), ); } @@ -1013,9 +1012,8 @@ fn cargo_compile_with_downloaded_dependency_with_offline() { .build(); assert_that( - p2.cargo("build") - .masquerade_as_nightly_cargo() - .arg("-Zoffline"), + p2.cargo("build -Zoffline") + .masquerade_as_nightly_cargo(), execs().with_stderr( "\ [COMPILING] present_dep v1.2.3 @@ -1043,9 +1041,8 @@ fn cargo_compile_offline_not_try_update() { .build(); assert_that( - p.cargo("build") - .masquerade_as_nightly_cargo() - .arg("-Zoffline"), + p.cargo("build -Zoffline") + .masquerade_as_nightly_cargo(), execs().with_status(101).with_stderr( "\ error: no matching package named `not_cached_dep` found @@ -1116,9 +1113,8 @@ fn main(){ .build(); assert_that( - p2.cargo("run") - .masquerade_as_nightly_cargo() - .arg("-Zoffline"), + p2.cargo("run -Zoffline") + .masquerade_as_nightly_cargo(), execs() .with_stderr(format!( "\ @@ -1267,9 +1263,8 @@ fn compile_offline_while_transitive_dep_not_cached() { drop(File::create(baz_path).ok().unwrap().write_all(&content)); assert_that( - p.cargo("build") - .masquerade_as_nightly_cargo() - .arg("-Zoffline"), + p.cargo("build -Zoffline") + .masquerade_as_nightly_cargo(), execs().with_status(101).with_stderr( "\ error: no matching package named `baz` found @@ -2918,9 +2913,8 @@ fn rustc_env_var() { .build(); assert_that( - p.cargo("build") - .env("RUSTC", "rustc-that-does-not-exist") - .arg("-v"), + p.cargo("build -v") + .env("RUSTC", "rustc-that-does-not-exist"), execs().with_status(101).with_stderr( "\ [ERROR] could not execute process `rustc-that-does-not-exist -vV` ([..]) @@ -4748,9 +4742,8 @@ fn avoid_dev_deps() { assert_that(p.cargo("build"), execs().with_status(101)); assert_that( - p.cargo("build") - .masquerade_as_nightly_cargo() - .arg("-Zavoid-dev-deps"), + p.cargo("build -Zavoid-dev-deps") + .masquerade_as_nightly_cargo(), execs(), ); } diff --git a/tests/testsuite/build_plan.rs b/tests/testsuite/build_plan.rs index 1e4d63b65..d2eeae26c 100644 --- a/tests/testsuite/build_plan.rs +++ b/tests/testsuite/build_plan.rs @@ -10,10 +10,8 @@ fn cargo_build_plan_simple() { .build(); assert_that( - p.cargo("build") - .masquerade_as_nightly_cargo() - .arg("--build-plan") - .arg("-Zunstable-options"), + p.cargo("build --build-plan -Zunstable-options") + .masquerade_as_nightly_cargo(), execs().with_json( r#" { @@ -71,10 +69,8 @@ fn cargo_build_plan_single_dep() { .file("bar/src/lib.rs", "pub fn bar() {}") .build(); assert_that( - p.cargo("build") - .masquerade_as_nightly_cargo() - .arg("--build-plan") - .arg("-Zunstable-options"), + p.cargo("build --build-plan -Zunstable-options") + .masquerade_as_nightly_cargo(), execs().with_json( r#" { @@ -139,10 +135,8 @@ fn cargo_build_plan_build_script() { .build(); assert_that( - p.cargo("build") - .masquerade_as_nightly_cargo() - .arg("--build-plan") - .arg("-Zunstable-options"), + p.cargo("build --build-plan -Zunstable-options") + .masquerade_as_nightly_cargo(), execs().with_json( r#" { diff --git a/tests/testsuite/cargo_features.rs b/tests/testsuite/cargo_features.rs index c9a920092..73bb32ed7 100644 --- a/tests/testsuite/cargo_features.rs +++ b/tests/testsuite/cargo_features.rs @@ -280,16 +280,15 @@ fn z_flags_rejected() { ); assert_that( - p.cargo("build").masquerade_as_nightly_cargo().arg("-Zarg"), + p.cargo("build -Zarg").masquerade_as_nightly_cargo(), execs() .with_status(101) .with_stderr("error: unknown `-Z` flag specified: arg"), ); assert_that( - p.cargo("build") - .masquerade_as_nightly_cargo() - .arg("-Zprint-im-a-teapot"), + p.cargo("build -Zprint-im-a-teapot") + .masquerade_as_nightly_cargo(), execs() .with_stdout("im-a-teapot = true\n") .with_stderr( diff --git a/tests/testsuite/corrupt_git.rs b/tests/testsuite/corrupt_git.rs index 7d31575aa..f91c9c4f1 100644 --- a/tests/testsuite/corrupt_git.rs +++ b/tests/testsuite/corrupt_git.rs @@ -48,7 +48,7 @@ fn deleting_database_files() { println!("deleting {}", file.display()); cargopaths::remove_file(&file).unwrap(); assert_that( - project.cargo("build").env("RUST_LOG", log).arg("-v"), + project.cargo("build -v").env("RUST_LOG", log), execs(), ); @@ -64,7 +64,7 @@ fn deleting_database_files() { .set_len(2) .unwrap(); assert_that( - project.cargo("build").env("RUST_LOG", log).arg("-v"), + project.cargo("build -v").env("RUST_LOG", log), execs(), ); } @@ -130,7 +130,7 @@ fn deleting_checkout_files() { println!("deleting {}", file.display()); cargopaths::remove_file(&file).unwrap(); assert_that( - project.cargo("build").env("RUST_LOG", log).arg("-v"), + project.cargo("build -v").env("RUST_LOG", log), execs(), ); @@ -146,7 +146,7 @@ fn deleting_checkout_files() { .set_len(2) .unwrap(); assert_that( - project.cargo("build").env("RUST_LOG", log).arg("-v"), + project.cargo("build -v").env("RUST_LOG", log), execs(), ); } diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs index ec97d495e..b56c325c2 100644 --- a/tests/testsuite/cross_compile.rs +++ b/tests/testsuite/cross_compile.rs @@ -47,7 +47,7 @@ fn simple_cross() { let target = cross_compile::alternate(); assert_that( - p.cargo("build --target").arg(&target).arg("-v"), + p.cargo("build -v --target").arg(&target), execs(), ); assert_that(&p.target_bin(&target, "foo"), existing_file()); @@ -347,7 +347,7 @@ fn plugin_to_the_max() { let target = cross_compile::alternate(); assert_that( - foo.cargo("build --target").arg(&target).arg("-v"), + foo.cargo("build -v --target").arg(&target), execs(), ); println!("second"); @@ -398,7 +398,7 @@ fn linker_and_ar() { .build(); assert_that( - p.cargo("build --target").arg(&target).arg("-v"), + p.cargo("build -v --target").arg(&target), execs().with_status(101).with_stderr_contains(&format!( "\ [COMPILING] foo v0.5.0 ({url}) @@ -715,7 +715,7 @@ fn cross_with_a_build_script() { .build(); assert_that( - p.cargo("build --target").arg(&target).arg("-v"), + p.cargo("build -v --target").arg(&target), execs().with_stderr(&format!( "\ [COMPILING] foo v0.0.0 (file://[..]) @@ -814,7 +814,7 @@ fn build_script_needed_for_host_and_target() { .build(); assert_that( - p.cargo("build --target").arg(&target).arg("-v"), + p.cargo("build -v --target").arg(&target), execs() .with_stderr_contains(&format!( "[COMPILING] d1 v0.0.0 ({url}/d1)", @@ -896,7 +896,7 @@ fn build_deps_for_the_right_arch() { let target = cross_compile::alternate(); assert_that( - p.cargo("build --target").arg(&target).arg("-v"), + p.cargo("build -v --target").arg(&target), execs(), ); } @@ -950,7 +950,7 @@ fn build_script_only_host() { let target = cross_compile::alternate(); assert_that( - p.cargo("build --target").arg(&target).arg("-v"), + p.cargo("build -v --target").arg(&target), execs(), ); } diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index f65f41dd2..5004c81de 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -643,7 +643,7 @@ fn doc_target() { .build(); assert_that( - p.cargo("doc --target").arg(TARGET).arg("--verbose"), + p.cargo("doc --verbose --target").arg(TARGET), execs(), ); assert_that( diff --git a/tests/testsuite/generate_lockfile.rs b/tests/testsuite/generate_lockfile.rs index d291f9623..f25cb2338 100644 --- a/tests/testsuite/generate_lockfile.rs +++ b/tests/testsuite/generate_lockfile.rs @@ -92,9 +92,8 @@ fn no_index_update() { ); assert_that( - p.cargo("generate-lockfile") - .masquerade_as_nightly_cargo() - .arg("-Zno-index-update"), + p.cargo("generate-lockfile -Zno-index-update") + .masquerade_as_nightly_cargo(), execs().with_stdout("").with_stderr(""), ); } diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index 04b658ff4..8963ad70a 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -94,7 +94,7 @@ fn cargo_compile_forbird_git_httpsrepo_offline() { .file("src/main.rs", "") .build(); - assert_that(p.cargo("build").masquerade_as_nightly_cargo().arg("-Zoffline"), + assert_that(p.cargo("build -Zoffline").masquerade_as_nightly_cargo(), execs().with_status(101). with_stderr("\ error: failed to load source for a dependency on `dep1` @@ -198,9 +198,8 @@ fn cargo_compile_offline_with_cached_git_dep() { assert_that( p - .cargo("build") - .masquerade_as_nightly_cargo() - .arg("-Zoffline"), + .cargo("build -Zoffline") + .masquerade_as_nightly_cargo(), execs().with_stderr(format!( "\ [COMPILING] dep1 v0.5.0 ({}#[..]) @@ -236,9 +235,8 @@ fn cargo_compile_offline_with_cached_git_dep() { .unwrap(); let _out = p - .cargo("build") + .cargo("build -Zoffline") .masquerade_as_nightly_cargo() - .arg("-Zoffline") .exec_with_output(); assert_that( process(&p.bin("foo")), @@ -961,8 +959,7 @@ Caused by: // anything because we already have the rev in the db. println!("bar precise update"); assert_that( - p.cargo("update -p bar --precise") - .arg(&old_head.to_string()), + p.cargo("update -p bar --precise").arg(&old_head.to_string()), execs().with_stdout(""), ); diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index 083513e2b..c9722b0cb 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -769,9 +769,8 @@ fn generated_manifest() { .build(); assert_that( - p.cargo("package") - .masquerade_as_nightly_cargo() - .arg("--no-verify"), + p.cargo("package --no-verify") + .masquerade_as_nightly_cargo(), execs(), ); diff --git a/tests/testsuite/plugins.rs b/tests/testsuite/plugins.rs index 0bc0fc910..51d99c4a3 100644 --- a/tests/testsuite/plugins.rs +++ b/tests/testsuite/plugins.rs @@ -216,7 +216,7 @@ fn plugin_with_dynamic_native_dependency() { .unwrap(); assert_that( - foo.cargo("build").env("SRC", &lib).arg("-v"), + foo.cargo("build -v").env("SRC", &lib), execs(), ); } diff --git a/tests/testsuite/profiles.rs b/tests/testsuite/profiles.rs index 8e4f3ff25..a0a3a25cc 100644 --- a/tests/testsuite/profiles.rs +++ b/tests/testsuite/profiles.rs @@ -289,7 +289,7 @@ fn profile_in_non_root_manifest_triggers_a_warning() { .build(); assert_that( - p.cargo("build").cwd(p.root().join("bar")).arg("-v"), + p.cargo("build -v").cwd(p.root().join("bar")), execs().with_stderr( "\ [WARNING] profiles for the non root package will be ignored, specify profiles at the workspace root: @@ -331,7 +331,7 @@ fn profile_in_virtual_manifest_works() { .build(); assert_that( - p.cargo("build").cwd(p.root().join("bar")).arg("-v"), + p.cargo("build -v").cwd(p.root().join("bar")), execs().with_stderr( "\ [COMPILING] bar v0.1.0 ([..]) diff --git a/tests/testsuite/publish.rs b/tests/testsuite/publish.rs index fb2b5bf08..bcc1d61c8 100644 --- a/tests/testsuite/publish.rs +++ b/tests/testsuite/publish.rs @@ -672,11 +672,8 @@ fn block_publish_feature_not_enabled() { .build(); assert_that( - p.cargo("publish") - .masquerade_as_nightly_cargo() - .arg("--registry") - .arg("alternative") - .arg("-Zunstable-options"), + p.cargo("publish --registry alternative -Zunstable-options") + .masquerade_as_nightly_cargo(), execs().with_status(101).with_stderr( "\ error: failed to parse manifest at `[..]` @@ -755,11 +752,8 @@ fn publish_empty_list() { .build(); assert_that( - p.cargo("publish") - .masquerade_as_nightly_cargo() - .arg("--registry") - .arg("alternative") - .arg("-Zunstable-options"), + p.cargo("publish --registry alternative -Zunstable-options") + .masquerade_as_nightly_cargo(), execs().with_status(101).with_stderr( "\ [ERROR] some crates cannot be published. @@ -796,11 +790,8 @@ fn publish_allowed_registry() { .build(); assert_that( - p.cargo("publish") - .masquerade_as_nightly_cargo() - .arg("--registry") - .arg("alternative") - .arg("-Zunstable-options"), + p.cargo("publish --registry alternative -Zunstable-options") + .masquerade_as_nightly_cargo(), execs(), ); } @@ -828,11 +819,8 @@ fn block_publish_no_registry() { .build(); assert_that( - p.cargo("publish") - .masquerade_as_nightly_cargo() - .arg("--registry") - .arg("alternative") - .arg("-Zunstable-options"), + p.cargo("publish --registry alternative -Zunstable-options") + .masquerade_as_nightly_cargo(), execs().with_status(101).with_stderr( "\ [ERROR] some crates cannot be published. diff --git a/tests/testsuite/registry.rs b/tests/testsuite/registry.rs index c66beda83..64dad2e07 100644 --- a/tests/testsuite/registry.rs +++ b/tests/testsuite/registry.rs @@ -767,9 +767,8 @@ fn update_offline() { .file("src/main.rs", "fn main() {}") .build(); assert_that( - p.cargo("update") - .masquerade_as_nightly_cargo() - .arg("-Zoffline"), + p.cargo("update -Zoffline") + .masquerade_as_nightly_cargo(), execs() .with_status(101) .with_stderr("error: you can't update in the offline mode[..]"), diff --git a/tests/testsuite/resolve.rs b/tests/testsuite/resolve.rs index a7ff4a6ec..2acaadab0 100644 --- a/tests/testsuite/resolve.rs +++ b/tests/testsuite/resolve.rs @@ -412,9 +412,8 @@ fn minimal_version_cli() { .build(); assert_that( - p.cargo("generate-lockfile") - .masquerade_as_nightly_cargo() - .arg("-Zminimal-versions"), + p.cargo("generate-lockfile -Zminimal-versions") + .masquerade_as_nightly_cargo(), execs(), ); diff --git a/tests/testsuite/run.rs b/tests/testsuite/run.rs index c3405156e..aaf50f96a 100644 --- a/tests/testsuite/run.rs +++ b/tests/testsuite/run.rs @@ -260,12 +260,12 @@ fn specify_default_run() { .with_stdout("hello A"), ); assert_that( - p.cargo("run").masquerade_as_nightly_cargo().arg("--bin").arg("a"), + p.cargo("run --bin a").masquerade_as_nightly_cargo(), execs() .with_stdout("hello A"), ); assert_that( - p.cargo("run").masquerade_as_nightly_cargo().arg("--bin").arg("b"), + p.cargo("run --bin b").masquerade_as_nightly_cargo(), execs() .with_stdout("hello B"), ); diff --git a/tests/testsuite/rustdocflags.rs b/tests/testsuite/rustdocflags.rs index 76f97169e..d3a1cea3a 100644 --- a/tests/testsuite/rustdocflags.rs +++ b/tests/testsuite/rustdocflags.rs @@ -8,7 +8,7 @@ fn parses_env() { .build(); assert_that( - p.cargo("doc").env("RUSTDOCFLAGS", "--cfg=foo").arg("-v"), + p.cargo("doc -v").env("RUSTDOCFLAGS", "--cfg=foo"), execs() .with_stderr_contains("[RUNNING] `rustdoc [..] --cfg=foo[..]`"), ); diff --git a/tests/testsuite/rustflags.rs b/tests/testsuite/rustflags.rs index 7a4217dcc..e75c32577 100644 --- a/tests/testsuite/rustflags.rs +++ b/tests/testsuite/rustflags.rs @@ -23,17 +23,16 @@ fn env_rustflags_normal_source() { // Use RUSTFLAGS to pass an argument that will generate an error assert_that( - p.cargo("build").env("RUSTFLAGS", "-Z bogus").arg("--lib"), + p.cargo("build --lib").env("RUSTFLAGS", "-Z bogus"), execs().with_status(101), ); assert_that( - p.cargo("build").env("RUSTFLAGS", "-Z bogus").arg("--bin=a"), + p.cargo("build --bin=a").env("RUSTFLAGS", "-Z bogus"), execs().with_status(101), ); assert_that( - p.cargo("build") - .env("RUSTFLAGS", "-Z bogus") - .arg("--example=b"), + p.cargo("build --example=b") + .env("RUSTFLAGS", "-Z bogus"), execs().with_status(101), ); assert_that( @@ -212,41 +211,33 @@ fn env_rustflags_normal_source_with_target() { // Use RUSTFLAGS to pass an argument that will generate an error assert_that( - p.cargo("build") - .env("RUSTFLAGS", "-Z bogus") - .arg("--lib") - .arg("--target") - .arg(host), + p.cargo("build --lib --target") + .arg(host) + .env("RUSTFLAGS", "-Z bogus"), execs().with_status(101), ); assert_that( - p.cargo("build") - .env("RUSTFLAGS", "-Z bogus") - .arg("--bin=a") - .arg("--target") - .arg(host), + p.cargo("build --bin=a --target") + .arg(host) + .env("RUSTFLAGS", "-Z bogus"), execs().with_status(101), ); assert_that( - p.cargo("build") - .env("RUSTFLAGS", "-Z bogus") - .arg("--example=b") - .arg("--target") - .arg(host), + p.cargo("build --example=b --target") + .arg(host) + .env("RUSTFLAGS", "-Z bogus"), execs().with_status(101), ); assert_that( - p.cargo("test") - .env("RUSTFLAGS", "-Z bogus") - .arg("--target") - .arg(host), + p.cargo("test --target") + .arg(host) + .env("RUSTFLAGS", "-Z bogus"), execs().with_status(101), ); assert_that( - p.cargo("bench") - .env("RUSTFLAGS", "-Z bogus") - .arg("--target") - .arg(host), + p.cargo("bench --target") + .arg(host) + .env("RUSTFLAGS", "-Z bogus"), execs().with_status(101), ); } @@ -279,10 +270,9 @@ fn env_rustflags_build_script_with_target() { let host = rustc_host(); assert_that( - p.cargo("build") - .env("RUSTFLAGS", "--cfg foo") - .arg("--target") - .arg(host), + p.cargo("build --target") + .arg(host) + .env("RUSTFLAGS", "--cfg foo"), execs(), ); } @@ -322,10 +312,9 @@ fn env_rustflags_build_script_dep_with_target() { let host = rustc_host(); assert_that( - foo.cargo("build") - .env("RUSTFLAGS", "--cfg foo") - .arg("--target") - .arg(host), + foo.cargo("build --target") + .arg(host) + .env("RUSTFLAGS", "--cfg foo"), execs(), ); } @@ -360,10 +349,9 @@ fn env_rustflags_plugin_with_target() { let host = rustc_host(); assert_that( - p.cargo("build") - .env("RUSTFLAGS", "--cfg foo") - .arg("--target") - .arg(host), + p.cargo("build --target") + .arg(host) + .env("RUSTFLAGS", "--cfg foo"), execs(), ); } @@ -405,10 +393,9 @@ fn env_rustflags_plugin_dep_with_target() { let host = rustc_host(); assert_that( - foo.cargo("build") - .env("RUSTFLAGS", "--cfg foo") - .arg("--target") - .arg(host), + foo.cargo("build --target") + .arg(host) + .env("RUSTFLAGS", "--cfg foo"), execs(), ); } diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 602de9cc5..9e082c60c 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -3315,12 +3315,7 @@ fn find_dependency_of_proc_macro_dependency_with_target() { .dep("bar", "0.1") .file("src/lib.rs", "extern crate bar;") .publish(); - assert_that( - p - .cargo("test --all --target") - .arg(rustc_host()), - execs(), - ); + assert_that(p.cargo("test --all --target").arg(rustc_host()), execs()); } #[test] diff --git a/tests/testsuite/tool_paths.rs b/tests/testsuite/tool_paths.rs index 102e1089d..a204130cc 100644 --- a/tests/testsuite/tool_paths.rs +++ b/tests/testsuite/tool_paths.rs @@ -139,7 +139,7 @@ fn relative_tools() { }; assert_that( - p.cargo("build").cwd(foo_path).arg("--verbose"), + p.cargo("build --verbose").cwd(foo_path), execs().with_stderr(&format!( "\ [COMPILING] bar v0.5.0 ({url}) diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index 22bc3ea70..227ac7af7 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -1355,18 +1355,14 @@ fn relative_path_for_root_works() { let p = p.build(); assert_that( - p.cargo("build") - .cwd(p.root()) - .arg("--manifest-path") - .arg("./Cargo.toml"), + p.cargo("build --manifest-path ./Cargo.toml") + .cwd(p.root()), execs(), ); assert_that( - p.cargo("build") - .cwd(p.root().join("subproj")) - .arg("--manifest-path") - .arg("../Cargo.toml"), + p.cargo("build --manifest-path ../Cargo.toml") + .cwd(p.root().join("subproj")), execs(), ); } From c882b4e02ed67bf76793f96da0faba746c609e4f Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Sun, 19 Aug 2018 10:16:08 +0100 Subject: [PATCH 4/4] Fix 3 corner tests where whitespaces are important --- tests/testsuite/features.rs | 4 ++-- tests/testsuite/metadata.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testsuite/features.rs b/tests/testsuite/features.rs index c5aaac6a5..17524b96c 100644 --- a/tests/testsuite/features.rs +++ b/tests/testsuite/features.rs @@ -692,7 +692,7 @@ fn many_cli_features() { .build(); assert_that( - p.cargo("build --features bar baz"), + p.cargo("build --features").arg("bar baz"), execs().with_stderr(format!( "\ [COMPILING] ba[..] v0.0.1 ({dir}/ba[..]) @@ -1394,7 +1394,7 @@ fn many_cli_features_comma_and_space_delimited() { .build(); assert_that( - p.cargo("build --features bar,baz bam bap"), + p.cargo("build --features").arg("bar,baz bam bap"), execs().with_stderr(format!( "\ [COMPILING] ba[..] v0.0.1 ({dir}/ba[..]) diff --git a/tests/testsuite/metadata.rs b/tests/testsuite/metadata.rs index e1b7edb71..2ad48f7db 100644 --- a/tests/testsuite/metadata.rs +++ b/tests/testsuite/metadata.rs @@ -980,7 +980,7 @@ fn multiple_features() { .build(); assert_that( - p.cargo("metadata --features a b"), + p.cargo("metadata --features").arg("a b"), execs(), ); }