Skip to content

Commit

Permalink
test(git): added tests for issue #14621
Browse files Browse the repository at this point in the history
  • Loading branch information
dacianpascu06 committed Nov 17, 2024
1 parent d8cb5fb commit cbb6075
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions tests/testsuite/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4052,6 +4052,94 @@ src/lib.rs
.run();
}

#[cargo_test(public_network_test, requires_git)]
fn github_fastpath_error_message() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2015"
[dependencies]
bitflags = { git = "https://github.com/rust-lang/bitflags.git", rev="11111b376b93484341c68fbca3ca110ae5cd2790" }
"#,
)
.file("src/lib.rs", "")
.build();
p.cargo("fetch")
.env("CARGO_NET_GIT_FETCH_WITH_CLI", "true")
.with_status(101)
.with_stderr_data(str![[r#"
[UPDATING] git repository `https://github.com/rust-lang/bitflags.git`
fatal: remote [ERROR] upload-pack: not our ref 11111b376b93484341c68fbca3ca110ae5cd2790
[ERROR] failed to get `bitflags` as a dependency of package `foo v0.1.0 ([ROOT]/foo)`
Caused by:
failed to load source for dependency `bitflags`
Caused by:
Unable to update https://github.com/rust-lang/bitflags.git?rev=11111b376b93484341c68fbca3ca110ae5cd2790
Caused by:
failed to clone into: [ROOT]/home/.cargo/git/db/bitflags-[HASH]
Caused by:
process didn't exit successfully: `git fetch --no-tags --force --update-head-ok 'https://github.com/rust-lang/bitflags.git' '+11111b376b93484341c68fbca3ca110ae5cd2790:refs/commit/11111b376b93484341c68fbca3ca110ae5cd2790'` ([EXIT_STATUS]: 128)
"#]])
.run();
}

#[cargo_test(public_network_test, requires_git)]
fn git_fetch_libgit2_error_message() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2015"
[dependencies]
bitflags = { git = "https://github.com/rust-lang/bitflags.git", rev="11111b376b93484341c68fbca3ca110ae5cd2790" }
"#,
)
.file("src/lib.rs", "")
.build();
p.cargo("fetch")
.with_status(101)
.with_stderr_data(str![[r#"
[UPDATING] git repository `https://github.com/rust-lang/bitflags.git`
[WARNING] spurious network error (3 tries remaining): could not read from remote repository; class=Net (12); code=Eof (-20)
[WARNING] spurious network error (2 tries remaining): could not read from remote repository; class=Net (12); code=Eof (-20)
[WARNING] spurious network error (1 tries remaining): could not read from remote repository; class=Net (12); code=Eof (-20)
[ERROR] failed to get `bitflags` as a dependency of package `foo v0.1.0 ([ROOT]/foo)`
Caused by:
failed to load source for dependency `bitflags`
Caused by:
Unable to update https://github.com/rust-lang/bitflags.git?rev=11111b376b93484341c68fbca3ca110ae5cd2790
Caused by:
failed to clone into: [ROOT]/home/.cargo/git/db/bitflags-[HASH]
Caused by:
network failure seems to have happened
if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
Caused by:
could not read from remote repository; class=Net (12); code=Eof (-20)
"#]])
.run();
}

#[cargo_test]
fn git_worktree_with_bare_original_repo() {
let project = project().build();
Expand Down

0 comments on commit cbb6075

Please sign in to comment.