Skip to content

Commit

Permalink
test: don't clobber RegExp.$_ on startup
Browse files Browse the repository at this point in the history
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: #44840
PR-URL: #44864
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
  • Loading branch information
bnoordhuis authored and juanarbol committed Oct 10, 2022
1 parent 00bdc85 commit 56a68be
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 56a68be

Please sign in to comment.