Skip to content

Commit

Permalink
Auto merge of #5907 - dwijnand:collapse-test-cmd-args, r=matklad
Browse files Browse the repository at this point in the history
Collapse ProcessBuilder::arg calls in tests

Refs #5742
More of #5854
  • Loading branch information
bors committed Aug 19, 2018
2 parents 8b6f710 + c882b4e commit a06570c
Show file tree
Hide file tree
Showing 52 changed files with 727 additions and 1,082 deletions.
66 changes: 19 additions & 47 deletions tests/testsuite/alt_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}
Expand Down Expand Up @@ -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(),
);
}
Expand Down Expand Up @@ -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`"),
Expand Down Expand Up @@ -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(),
);

Expand Down Expand Up @@ -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(),
);
}
Expand Down Expand Up @@ -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"),
Expand Down
36 changes: 17 additions & 19 deletions tests/testsuite/bad_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`, \
Expand All @@ -40,7 +38,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
Expand Down Expand Up @@ -76,7 +74,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 [..]
Expand All @@ -100,7 +98,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 `[..]`
Expand All @@ -127,7 +125,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 [..]
Expand All @@ -152,7 +150,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: \
Expand All @@ -175,7 +173,7 @@ fn default_cargo_config_jobs() {
"#,
)
.build();
assert_that(p.cargo("build").arg("-v"), execs());
assert_that(p.cargo("build -v"), execs());
}

#[test]
Expand All @@ -190,7 +188,7 @@ fn good_cargo_config_jobs() {
"#,
)
.build();
assert_that(p.cargo("build").arg("-v"), execs());
assert_that(p.cargo("build -v"), execs());
}

#[test]
Expand All @@ -213,7 +211,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
Expand All @@ -239,7 +237,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
Expand Down Expand Up @@ -342,7 +340,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: [..]
Expand Down Expand Up @@ -393,7 +391,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:///`
Expand Down Expand Up @@ -431,7 +429,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",
),
Expand Down Expand Up @@ -536,7 +534,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 `[..]`
Expand Down Expand Up @@ -876,7 +874,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. \
Expand Down Expand Up @@ -1096,7 +1094,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. \
Expand Down Expand Up @@ -1161,7 +1159,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). \
Expand Down
16 changes: 4 additions & 12 deletions tests/testsuite/bad_manifest_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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\"}\
Expand All @@ -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\"}\
Expand All @@ -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\"}\
Expand All @@ -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\"}\
Expand Down
Loading

0 comments on commit a06570c

Please sign in to comment.