* Test callers for as many affected symbols as the cap allows. * * A symbol whose answer came back `unknown` or `unsupported` is left out of * `checked` on purpose: nobody answered, so it is unchecked, and counting it as * uncovered would turn a backend that did not reply into a finding about th
(
source: ImpactSource,
root: string,
symbols: readonly ChangeImpactSymbol[],
cap: number,
opts: ProviderQueryOptions,
)
| 102 | * repository. |
| 103 | */ |
| 104 | async function testLookup( |
| 105 | source: ImpactSource, |
| 106 | root: string, |
| 107 | symbols: readonly ChangeImpactSymbol[], |
| 108 | cap: number, |
| 109 | opts: ProviderQueryOptions, |
| 110 | ): Promise<ImpactTestLookup> { |
| 111 | const candidates = testCandidates(symbols, cap); |
| 112 | const bySymbol = new Map<string, TestRef[]>(); |
| 113 | const checked = new Set<string>(); |
| 114 | for (const symbol of candidates) { |
| 115 | const ref = twinTargetOf({ |
| 116 | name: symbol.name, |
| 117 | qualifiedName: symbol.qualifiedName, |
| 118 | kind: symbol.kind, |
| 119 | filePath: symbol.filePath, |
| 120 | startLine: symbol.line, |
| 121 | }); |
| 122 | if (ref === undefined) { |
| 123 | continue; |
| 124 | } |
| 125 | const facts = await source.getFacts(root, ref, ['testedBy'], opts).catch(() => undefined); |
| 126 | const fact = facts?.testedBy; |
| 127 | if (fact === undefined || (fact.state !== 'known' && fact.state !== 'inferred')) { |
| 128 | continue; |
| 129 | } |
| 130 | checked.add(symbol.qualifiedName!); |
| 131 | bySymbol.set(symbol.qualifiedName!, fact.value); |
| 132 | } |
| 133 | const more = symbols.some( |
| 134 | (symbol) => |
| 135 | symbol.changeKind !== 'module' |
| 136 | && symbol.isTest !== true |
| 137 | && symbol.qualifiedName !== undefined |
| 138 | && !candidates.some((candidate) => candidate.qualifiedName === symbol.qualifiedName), |
| 139 | ); |
| 140 | return { bySymbol, checked, ...(more ? { cappedAt: cap } : {}) }; |
| 141 | } |
| 142 | |
| 143 | /** The whole assessment, from the four readings. */ |
| 144 | export async function readImpact( |
no test coverage detected