|
5 | 5 | REACH_CONTINUE_ON_INSTALL_ERRORS_FLAG, |
6 | 6 | renderResolutionErrorReport, |
7 | 7 | } from './resolution-report-render.mts' |
| 8 | +import { moduleKey } from './resolution-report.mts' |
8 | 9 |
|
9 | 10 | import type { BuildOptionHints } from './resolution-report-render.mts' |
10 | 11 | import type { ResolutionFailure } from './resolution-report.mts' |
@@ -49,6 +50,63 @@ describe('resolution failure classification', () => { |
49 | 50 | expect(r.nonBlockingNotice).toContain('ambiguous variant') |
50 | 51 | }) |
51 | 52 |
|
| 53 | + it.each([ |
| 54 | + 'Found multiple transformation chains that produce a variant of com.example:amb:1.0', |
| 55 | + 'Found multiple transforms that can produce a variant of com.example:amb:1.0', |
| 56 | + ])( |
| 57 | + 'classifies an ambiguous Gradle artifact transform as variant ambiguity: %s', |
| 58 | + detail => { |
| 59 | + const r = renderResolutionErrorReport( |
| 60 | + [f('com.example:amb:1.0', detail)], |
| 61 | + ['runtimeClasspath'], |
| 62 | + 'gradle', |
| 63 | + ) |
| 64 | + expect(r.hasBlockingFailures).toBe(false) |
| 65 | + expect(r.nonBlockingNotice).toContain('ambiguous variant') |
| 66 | + }, |
| 67 | + ) |
| 68 | + |
| 69 | + it('treats a checksum missing from Gradle verification metadata as non-blocking, unlike a mismatch', () => { |
| 70 | + const header = |
| 71 | + "Dependency verification failed for configuration ':runtimeClasspath':" |
| 72 | + const missing = renderResolutionErrorReport( |
| 73 | + [ |
| 74 | + f( |
| 75 | + 'com.example:lib:1.0', |
| 76 | + `${header}\nOn artifact lib-1.0.jar (com.example:lib:1.0) in repository 'maven': checksum is missing from verification metadata.`, |
| 77 | + ), |
| 78 | + ], |
| 79 | + ['runtimeClasspath'], |
| 80 | + 'gradle', |
| 81 | + { resolvedModules: new Set([moduleKey(':', 'com.example:lib')]) }, |
| 82 | + ) |
| 83 | + expect(missing.hasBlockingFailures).toBe(false) |
| 84 | + expect(missing.nonBlockingNotice).toContain('no checksum') |
| 85 | + const mismatch = renderResolutionErrorReport( |
| 86 | + [ |
| 87 | + f( |
| 88 | + 'com.example:lib:1.0', |
| 89 | + `${header}\nOn artifact lib-1.0.jar (com.example:lib:1.0) in repository 'maven': expected a 'sha256' checksum of '00' but was '11'`, |
| 90 | + ), |
| 91 | + ], |
| 92 | + ['runtimeClasspath'], |
| 93 | + 'gradle', |
| 94 | + ) |
| 95 | + expect(mismatch.hasBlockingFailures).toBe(true) |
| 96 | + const both = renderResolutionErrorReport( |
| 97 | + [ |
| 98 | + f( |
| 99 | + 'com.example:lib:1.0', |
| 100 | + `${header}\nOn artifact lib-1.0.jar (com.example:lib:1.0) in repository 'a': checksum is missing from verification metadata.\nOn artifact lib-1.0.jar (com.example:lib:1.0) in repository 'b': expected a 'sha256' checksum of '00' but was '11'`, |
| 101 | + ), |
| 102 | + ], |
| 103 | + ['runtimeClasspath'], |
| 104 | + 'gradle', |
| 105 | + { resolvedModules: new Set([moduleKey(':', 'com.example:lib')]) }, |
| 106 | + ) |
| 107 | + expect(both.hasBlockingFailures).toBe(true) |
| 108 | + }) |
| 109 | + |
52 | 110 | it("classifies Gradle's 'unable to find a matching variant' phrasing as blocking no-matching-variant", () => { |
53 | 111 | const r = renderResolutionErrorReport( |
54 | 112 | [ |
|
0 commit comments