|
4 | 4 | //! or CARGO_PUBLIC_NETWORK_TESTS.
|
5 | 5 |
|
6 | 6 | use cargo_test_support::containers::Container;
|
| 7 | +use cargo_test_support::paths::{self, CargoPathExt}; |
7 | 8 | use cargo_test_support::project;
|
8 | 9 |
|
9 | 10 | #[cargo_test(container_test)]
|
@@ -134,22 +135,65 @@ fn self_signed_with_cacert() {
|
134 | 135 | #[cargo_test(public_network_test)]
|
135 | 136 | fn github_works() {
|
136 | 137 | // Check that an https connection to github.com works.
|
137 |
| - let p = project() |
138 |
| - .file( |
139 |
| - "Cargo.toml", |
140 |
| - r#" |
141 |
| - [package] |
142 |
| - name = "foo" |
143 |
| - version = "0.1.0" |
144 |
| - edition = "2015" |
| 138 | + // This tries all the different types of git references, and verifies the fast-path behavior. |
| 139 | + for (manifest_ref, oid, refspecs, up_to_date) in [ |
| 140 | + ( |
| 141 | + r#", tag = "1.3.2""#, |
| 142 | + "ed185cfb1c447c1b4bd6ac021c9ec3bb02c9e2f2", |
| 143 | + r#""+refs/tags/1.3.2:refs/remotes/origin/tags/1.3.2""#, |
| 144 | + "github fast path up-to-date", |
| 145 | + ), |
| 146 | + ( |
| 147 | + r#", rev = "6c67922300d5abae779ca147bac00f6ff9c87f8a""#, |
| 148 | + "6c67922300d5abae779ca147bac00f6ff9c87f8a", |
| 149 | + r#""+6c67922300d5abae779ca147bac00f6ff9c87f8a:refs/commit/6c67922300d5abae779ca147bac00f6ff9c87f8a""#, |
| 150 | + "github fast path already has 6c67922300d5abae779ca147bac00f6ff9c87f8a", |
| 151 | + ), |
| 152 | + ( |
| 153 | + r#", branch = "main""#, |
| 154 | + "[..]", |
| 155 | + r#""+refs/heads/main:refs/remotes/origin/main""#, |
| 156 | + "github fast path up-to-date", |
| 157 | + ), |
| 158 | + ( |
| 159 | + "", |
| 160 | + "[..]", |
| 161 | + r#""+HEAD:refs/remotes/origin/HEAD""#, |
| 162 | + "github fast path up-to-date", |
| 163 | + ), |
| 164 | + ] { |
| 165 | + eprintln!("test {manifest_ref}"); |
| 166 | + let p = project() |
| 167 | + .file( |
| 168 | + "Cargo.toml", |
| 169 | + &format!( |
| 170 | + r#" |
| 171 | + [package] |
| 172 | + name = "foo" |
| 173 | + version = "0.1.0" |
| 174 | + edition = "2015" |
145 | 175 |
|
146 |
| - [dependencies] |
147 |
| - bitflags = { git = "https://github.com/rust-lang/bitflags.git", tag="1.3.2" } |
148 |
| - "#, |
149 |
| - ) |
150 |
| - .file("src/lib.rs", "") |
151 |
| - .build(); |
152 |
| - p.cargo("fetch") |
153 |
| - .with_stderr("[UPDATING] git repository `https://github.com/rust-lang/bitflags.git`") |
154 |
| - .run(); |
| 176 | + [dependencies] |
| 177 | + bitflags = {{ git = "https://github.com/rust-lang/bitflags.git"{manifest_ref}}} |
| 178 | + "# |
| 179 | + ), |
| 180 | + ) |
| 181 | + .file("src/lib.rs", "") |
| 182 | + .build(); |
| 183 | + p.cargo("fetch") |
| 184 | + .env("CARGO_LOG", "cargo::sources::git::utils=debug") |
| 185 | + .with_stderr_contains("[UPDATING] git repository `https://github.com/rust-lang/bitflags.git`") |
| 186 | + .with_stderr_contains("[..]attempting GitHub fast path[..]") |
| 187 | + .with_stderr_contains(&format!("[..]github fast path fetch {oid}")) |
| 188 | + .with_stderr_contains(&format!("[..]initiating fetch of [{refspecs}] from https://github.com/rust-lang/bitflags.git")) |
| 189 | + .run(); |
| 190 | + // Remove the lock file, and test the up-to-date code path. |
| 191 | + p.root().join("Cargo.lock").rm_rf(); |
| 192 | + p.cargo("fetch") |
| 193 | + .env("CARGO_LOG", "cargo::sources::git::utils=debug") |
| 194 | + .with_stderr_contains(&format!("[..]{up_to_date}")) |
| 195 | + .run(); |
| 196 | + |
| 197 | + paths::home().join(".cargo/git").rm_rf(); |
| 198 | + } |
155 | 199 | }
|
0 commit comments