From 26f431fd14e96cb631042aa3feaf4267cb235f38 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Tue, 26 Sep 2023 10:01:56 +0900 Subject: perf(test): use core.currentUserCallSite (#20669) Speeds up `Deno.test` calls by a bit. --- cli/js/40_testing.js | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) (limited to 'cli/js') diff --git a/cli/js/40_testing.js b/cli/js/40_testing.js index 2702dccf1..cf779ee07 100644 --- a/cli/js/40_testing.js +++ b/cli/js/40_testing.js @@ -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; -- cgit v1.2.3