Skip to content

Collapse ProcessBuilder::arg calls in tests #5907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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