|
45 | 45 | //! a ref (rollback / remove find it) but marked unattested: a module's |
46 | 46 | //! own literal `<version>` overrides it, and only the root pom is read here |
47 | 47 | //! (the rewriter refuses such roots, #261). A `${property}` version is |
48 | | -//! read twice: as the pom spells it (the root `<properties>`, what the |
49 | | -//! rewriter writes and rolls back) and as the build resolves it |
50 | | -//! (`.mvn/maven.config`'s `-D` user properties first, Maven's order). A |
51 | | -//! Socket version only the build config supplies is diagnosed, never a |
52 | | -//! ref (hosted mode never writes one; rollback / remove never edit |
53 | | -//! `.mvn/maven.config`). Every pin is then weighed by [`bypasses`]: an |
54 | | -//! executable classifier copy, a `<profiles>` declaration, profile |
55 | | -//! `<properties>` that move its version or its `${property}` coordinates, |
56 | | -//! or a `-D` override that makes the build resolve anything else keeps |
57 | | -//! the ref but marks it unattested. |
| 48 | +//! interpolated through every property it names (at most 16 deep; a cycle |
| 49 | +//! or an undefined name never resolves to a pin) twice: as the pom spells |
| 50 | +//! it (the root `<properties>`, what the rewriter writes and rolls back) |
| 51 | +//! and as the build resolves it (`.mvn/maven.config`'s `-D` user |
| 52 | +//! properties first, Maven's order). A Socket version only the build |
| 53 | +//! config supplies is diagnosed, never a ref (hosted mode never writes |
| 54 | +//! one; rollback / remove never edit `.mvn/maven.config`). |
| 55 | +//! |
| 56 | +//! Every pin is then weighed by [`bypasses`], and each way the build may |
| 57 | +//! resolve something else keeps the ref but marks it unattested: |
| 58 | +//! - an executable classifier copy (anything but `sources` / `javadoc`), |
| 59 | +//! live or in a profile, at another version or none in this pom; |
| 60 | +//! - a `<profiles>` declaration of the main jar at another version (a |
| 61 | +//! profile's `<dependencyManagement>` only where management governs the |
| 62 | +//! pin); every profile counts, as vendored mode treats every profile |
| 63 | +//! as live; |
| 64 | +//! - profile `<properties>` (any combination of profiles) that move the |
| 65 | +//! pin's `${property}` version, or a `${property}` groupId / artifactId |
| 66 | +//! so the pin names another package or another declaration names this |
| 67 | +//! one (a coordinate property this pom cannot resolve may name |
| 68 | +//! anything); |
| 69 | +//! - a `-D` user property that moves the pin's `${property}` version. |
58 | 70 | //! |
59 | 71 | //! Integrity: when the pom sha256 was known the rewriter also writes Maven |
60 | 72 | //! Trusted Checksums — `.mvn/checksums/checksums.sha256` lines |
@@ -1554,6 +1566,7 @@ mod tests { |
1554 | 1566 | &out, |
1555 | 1567 | UnattestedKind::MavenClassifierUnpatched, |
1556 | 1568 | &["org.slf4j:slf4j-api:"], |
| 1569 | + &format!("{deps} {managed}"), |
1557 | 1570 | ); |
1558 | 1571 | } |
1559 | 1572 |
|
@@ -2044,6 +2057,7 @@ mod tests { |
2044 | 2057 | &out, |
2045 | 2058 | UnattestedKind::MavenConfigOverride, |
2046 | 2059 | &[".mvn/maven.config"], |
| 2060 | + &what, |
2047 | 2061 | ); |
2048 | 2062 | } |
2049 | 2063 | assert!( |
@@ -2158,7 +2172,12 @@ mod tests { |
2158 | 2172 | ]; |
2159 | 2173 | for (live, profile, kind) in &unattested { |
2160 | 2174 | let out = run(&project(live, profile)).await; |
2161 | | - assert_withheld(&out, *kind, &["org.slf4j:slf4j-api", "<profiles>"]); |
| 2175 | + assert_withheld( |
| 2176 | + &out, |
| 2177 | + *kind, |
| 2178 | + &["org.slf4j:slf4j-api", "<profiles>"], |
| 2179 | + &format!("{live} {profile}"), |
| 2180 | + ); |
2162 | 2181 | } |
2163 | 2182 |
|
2164 | 2183 | let attested = [ |
@@ -2209,16 +2228,24 @@ mod tests { |
2209 | 2228 |
|
2210 | 2229 | /// `out` finds the hosted slf4j-api pin for `UUID_A` but withholds it: |
2211 | 2230 | /// exactly one unattested entry, of `kind`, for that pin, whose detail |
2212 | | - /// names every one of `needles`. |
| 2231 | + /// names every one of `needles` (`case` names the case in a failure). |
2213 | 2232 | #[track_caller] |
2214 | | - fn assert_withheld(out: &Discovery, kind: UnattestedKind, needles: &[&str]) { |
| 2233 | + fn assert_withheld(out: &Discovery, kind: UnattestedKind, needles: &[&str], case: &str) { |
2215 | 2234 | assert_refs(out, &[(FX_PURL, UUID_A, WiringMode::Hosted)]); |
2216 | | - assert_eq!(out.unattested.len(), 1, "{:?}", out.unattested); |
| 2235 | + assert_eq!(out.unattested.len(), 1, "{case}: {:?}", out.unattested); |
2217 | 2236 | let u = &out.unattested[0]; |
2218 | | - assert_eq!(u.kind, kind, "{}", u.detail); |
2219 | | - assert_eq!((u.purl.as_str(), u.uuid.as_str()), (FX_PURL, UUID_A)); |
| 2237 | + assert_eq!(u.kind, kind, "{case}: {}", u.detail); |
| 2238 | + assert_eq!( |
| 2239 | + (u.purl.as_str(), u.uuid.as_str()), |
| 2240 | + (FX_PURL, UUID_A), |
| 2241 | + "{case}" |
| 2242 | + ); |
2220 | 2243 | for needle in needles { |
2221 | | - assert!(u.detail.contains(needle), "{needle:?}: {}", u.detail); |
| 2244 | + assert!( |
| 2245 | + u.detail.contains(needle), |
| 2246 | + "{case}: {needle:?}: {}", |
| 2247 | + u.detail |
| 2248 | + ); |
2222 | 2249 | } |
2223 | 2250 | } |
2224 | 2251 |
|
@@ -2298,6 +2325,7 @@ mod tests { |
2298 | 2325 | &out, |
2299 | 2326 | UnattestedKind::MavenProfileUnpatched, |
2300 | 2327 | &["org.slf4j:slf4j-api", "<properties>"], |
| 2328 | + &format!("{root} {decl} {profiles:?}"), |
2301 | 2329 | ); |
2302 | 2330 | } |
2303 | 2331 |
|
@@ -3166,7 +3194,7 @@ mod tests { |
3166 | 3194 | "<properties><revision>1.7.36</revision></properties>", |
3167 | 3195 | )) |
3168 | 3196 | .await; |
3169 | | - assert_withheld(&out, UnattestedKind::MavenProfileUnpatched, &[]); |
| 3197 | + assert_withheld(&out, UnattestedKind::MavenProfileUnpatched, &[], ""); |
3170 | 3198 | // One that keeps it does not. |
3171 | 3199 | let out = run(&project( |
3172 | 3200 | &pin, |
@@ -3289,7 +3317,7 @@ mod tests { |
3289 | 3317 | &[broken], |
3290 | 3318 | ); |
3291 | 3319 | let out = run(&p).await; |
3292 | | - assert_withheld(&out, UnattestedKind::MavenProfileUnpatched, &[]); |
| 3320 | + assert_withheld(&out, UnattestedKind::MavenProfileUnpatched, &[], ""); |
3293 | 3321 | let p = property_project("", &direct_decl(&pin), &[broken]); |
3294 | 3322 | let out = run(&p).await; |
3295 | 3323 | assert!( |
|
0 commit comments