perf(test): use core.currentUserCallSite (#20669)

Speeds up `Deno.test` calls by a bit.
This commit is contained in:
Luca Casonato 2023-09-26 10:01:56 +09:00 committed by GitHub
parent a27ee8f368
commit 26f431fd14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 25 deletions

View file

@ -769,22 +769,8 @@ function testInner(
// Delete this prop in case the user passed it. It's used to detect steps.
delete testDesc.parent;
const jsError = core.destructureError(new Error());
let location;
for (let i = 0; i < jsError.frames.length; i++) {
const filename = jsError.frames[i].fileName;
if (filename.startsWith("ext:") || filename.startsWith("node:")) {
continue;
}
location = {
fileName: jsError.frames[i].fileName,
lineNumber: jsError.frames[i].lineNumber,
columnNumber: jsError.frames[i].columnNumber,
};
break;
}
testDesc.location = location;
testDesc.location = core.currentUserCallSite();
testDesc.fn = wrapTest(testDesc);
testDesc.name = escapeName(testDesc.name);
@ -1307,12 +1293,7 @@ function createTestContext(desc) {
stepDesc.sanitizeOps ??= desc.sanitizeOps;
stepDesc.sanitizeResources ??= desc.sanitizeResources;
stepDesc.sanitizeExit ??= desc.sanitizeExit;
const jsError = core.destructureError(new Error());
stepDesc.location = {
fileName: jsError.frames[1].fileName,
lineNumber: jsError.frames[1].lineNumber,
columnNumber: jsError.frames[1].columnNumber,
};
stepDesc.location = core.currentUserCallSite();
stepDesc.level = level + 1;
stepDesc.parent = desc;
stepDesc.rootId = rootId;