mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00

By rewriting the tests, with rerast (https://github.com/google/rerast), to use the newly introduced "at" method. First I added the following temporary function to cargotest::support: pub fn project_foo() -> ProjectBuilder { project("foo") } Then I defined the following rewrite.rs: use cargotest::support::{ project, project_foo }; fn rule1(a: &'static str) { replace!(project("foo") => project_foo()); replace!(project(a) => project_foo().at(a)); } Then I ran rerast: cargo +nightly rerast --rules_file=rewrite.rs --force --targets tests --file tests/testsuite/main.rs Finally I searched and replaced the references to project_foo with argument-less project (a little awkardly on macOS with a git clean). find tests -type f -exec sed -i -e 's/project_foo/project/g' {} + git clean -d tests
76 lines
1.6 KiB
Rust
76 lines
1.6 KiB
Rust
use cargotest::support::{execs, project};
|
|
use hamcrest::assert_that;
|
|
|
|
#[test]
|
|
fn net_retry_loads_from_config() {
|
|
let p = project()
|
|
.file(
|
|
"Cargo.toml",
|
|
r#"
|
|
[project]
|
|
name = "foo"
|
|
version = "0.0.1"
|
|
authors = []
|
|
|
|
[dependencies.bar]
|
|
git = "https://127.0.0.1:11/foo/bar"
|
|
"#,
|
|
)
|
|
.file("src/main.rs", "")
|
|
.file(
|
|
".cargo/config",
|
|
r#"
|
|
[net]
|
|
retry=1
|
|
[http]
|
|
timeout=1
|
|
"#,
|
|
)
|
|
.build();
|
|
|
|
assert_that(
|
|
p.cargo("build").arg("-v"),
|
|
execs().with_status(101).with_stderr_contains(
|
|
"[WARNING] spurious network error \
|
|
(1 tries remaining): [..]",
|
|
),
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn net_retry_git_outputs_warning() {
|
|
let p = project()
|
|
.file(
|
|
"Cargo.toml",
|
|
r#"
|
|
[project]
|
|
name = "foo"
|
|
version = "0.0.1"
|
|
authors = []
|
|
|
|
[dependencies.bar]
|
|
git = "https://127.0.0.1:11/foo/bar"
|
|
"#,
|
|
)
|
|
.file(
|
|
".cargo/config",
|
|
r#"
|
|
[http]
|
|
timeout=1
|
|
"#,
|
|
)
|
|
.file("src/main.rs", "")
|
|
.build();
|
|
|
|
assert_that(
|
|
p.cargo("build").arg("-v").arg("-j").arg("1"),
|
|
execs()
|
|
.with_status(101)
|
|
.with_stderr_contains(
|
|
"[WARNING] spurious network error \
|
|
(2 tries remaining): [..]",
|
|
)
|
|
.with_stderr_contains("[WARNING] spurious network error (1 tries remaining): [..]"),
|
|
);
|
|
}
|