eng: fix off-by-1 error in selfhost test error messages (#213081)

Fixes #212808
This commit is contained in:
Connor Peet 2024-05-20 10:26:43 -07:00 committed by GitHub
parent c00f2792a4
commit 7828baaa8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -204,7 +204,7 @@ export async function scanTestOutput(
return;
}
const logLocation = store.getSourceLocation(match[2], Number(match[3]));
const logLocation = store.getSourceLocation(match[2], Number(match[3]) - 1);
const logContents = replaceAllLocations(store, match[1]);
const test = currentTest;
@ -459,7 +459,8 @@ export class SourceMapStore {
};
}
async getSourceLocation(fileUri: string, line: number, col = 1) {
/** Gets an original location from a base 0 line and column */
async getSourceLocation(fileUri: string, line: number, col = 0) {
return this.getSourceLocationMapper(fileUri).then(m => m(line, col));
}
@ -599,5 +600,5 @@ async function tryDeriveStackLocation(
async function deriveSourceLocation(store: SourceMapStore, parts: RegExpMatchArray) {
const [, fileUri, line, col] = parts;
return store.getSourceLocation(fileUri, Number(line), Number(col));
return store.getSourceLocation(fileUri, Number(line) - 1, Number(col));
}