From 2308b71d09fda988cd14762f7f8ee9fff1fb8118 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 7 Oct 2022 20:39:31 +0200 Subject: [PATCH] test: don't clobber RegExp.$_ on startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some tests expect it to be empty so clear it again after running a regular expression against /proc/cpuinfo. It didn't cause test failures on any of the CI machines, to the best of my knowledge, because most of the time /proc/cpuinfo doesn't contain the string it was looking for. Fixes: https://github.com/nodejs/node/issues/44840 PR-URL: https://github.com/nodejs/node/pull/44864 Reviewed-By: James M Snell Reviewed-By: Richard Lau Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Antoine du Hamel Reviewed-By: Darshan Sen Reviewed-By: Juan José Arboleda --- test/common/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/common/index.js b/test/common/index.js index 310f0c30dc933b..66ffe3cf9b1c59 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -126,7 +126,9 @@ const isPi = (() => { // the contents of `/sys/firmware/devicetree/base/model` but that doesn't // work inside a container. Match the chipset model number instead. const cpuinfo = fs.readFileSync('/proc/cpuinfo', { encoding: 'utf8' }); - return /^Hardware\s*:\s*(.*)$/im.exec(cpuinfo)?.[1] === 'BCM2835'; + const ok = /^Hardware\s*:\s*(.*)$/im.exec(cpuinfo)?.[1] === 'BCM2835'; + /^/.test(''); // Clear RegExp.$_, some tests expect it to be empty. + return ok; } catch { return false; }