From b44f507c9212b49598fa7aa4d82ad47f0932ebaf Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Fri, 20 Jan 2023 11:47:11 -0500 Subject: [PATCH] [test262] Strip codeframes from Forget errors so results are grouped correctly --- compiler/forget/scripts/test262-preprocessor.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/compiler/forget/scripts/test262-preprocessor.js b/compiler/forget/scripts/test262-preprocessor.js index ef4ed5ac95..86f4b0007b 100644 --- a/compiler/forget/scripts/test262-preprocessor.js +++ b/compiler/forget/scripts/test262-preprocessor.js @@ -13,6 +13,7 @@ module.exports = (test) => { message = message.replace(/^\/.*?:\s/, ""); // babel seems to output filenames message = message.split(/\(\d+:\d+\)/)[0]; // some errors report line numbers and codeframes message = message.trim(); + message = formatReactForgetErrorMessage(message); // For unknown reasons I don't have the energy to dig into some Babel error instances can't be // written to, so we construct a psedudo object here so the correctly formatted error messages @@ -26,3 +27,12 @@ module.exports = (test) => { return test; }; + +function formatReactForgetErrorMessage(message) { + // Strip codeframes so we can group errors + const matches = message.match(/^\[ReactForget\].*\n?/); + if (Array.isArray(matches) && matches.length > 0) { + return matches[0].replace("\n", ""); + } + return message; +}