From 4481a79de33e06321da5b2a7316e5ee04b61cf18 Mon Sep 17 00:00:00 2001 From: Justin Grant Date: Fri, 19 Jun 2020 15:45:30 -0700 Subject: [PATCH] Fix Test262 on MacOS / Node14 Fixes #687 which prevented Test262 tests from running in my MacOS/Node14 environment. - if MacOS, use sysctl instead of nproc in ci_test.sh - defend against undefined `globalThis.__coverage__` --- polyfill/ci_test.sh | 6 +++++- polyfill/test/transform.test262.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/polyfill/ci_test.sh b/polyfill/ci_test.sh index c8490641b4..df81484b01 100755 --- a/polyfill/ci_test.sh +++ b/polyfill/ci_test.sh @@ -23,7 +23,11 @@ fi cd test/ -threads=$(nproc --ignore 1) +if [ "$(uname)" = 'Darwin' ]; then + threads=$(sysctl -n hw.logicalcpu) +else + threads=$(nproc --ignore 1) +fi if [ $threads -gt 2 ]; then threads=2; fi test262-harness \ diff --git a/polyfill/test/transform.test262.js b/polyfill/test/transform.test262.js index 2060bcca54..9d87d7d55a 100644 --- a/polyfill/test/transform.test262.js +++ b/polyfill/test/transform.test262.js @@ -4,6 +4,6 @@ const fs = require('fs'); const {v4: uuid} = require('uuid'); const filename = '../coverage/tmp/transformer/' + uuid() + '.json'; fs.mkdirSync('../coverage/tmp/transformer/', { recursive: true }); -fs.writeFileSync(filename, JSON.stringify(globalThis.__coverage__), 'utf-8'); +fs.writeFileSync(filename, JSON.stringify(globalThis.__coverage__ || {}), 'utf-8'); `; };