From 250e0cbf26300f25dcd9f8e3909e8b0e4f9cb5a2 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Sun, 14 May 2023 14:36:30 +1000 Subject: [PATCH] [cli] Fix running definition tests locally on MacOS (#4440) * fix tests running on macos * remove extra log --- cli/src/commands/runTests.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/cli/src/commands/runTests.js b/cli/src/commands/runTests.js index 824f5ba0fd..c5b3aea762 100644 --- a/cli/src/commands/runTests.js +++ b/cli/src/commands/runTests.js @@ -23,12 +23,28 @@ export type Args = { ... }; -// Used to decide which binary to fetch for each version of Flow -const BIN_PLATFORM = (_ => { +/** + * Used to decide which binary to fetch for each version of Flow. + * + * Return type matches the binaries returned by flow releases + * https://github.com/facebook/flow/releases + * + * eg: If the binary for the OS is `flow-linux-arm64-v0.206.0.zip` + * we will return `linux-arm64` + */ +const BIN_PLATFORM = (() => { + const arch = os.arch(); + switch (os.type()) { case 'Linux': + if (arch === 'arm') { + return 'linux-arm64'; + } return 'linux64'; case 'Darwin': + if (arch === 'arm') { + return 'osx-arm64'; + } return 'osx'; case 'Windows_NT': return 'win64'; @@ -37,6 +53,7 @@ const BIN_PLATFORM = (_ => { throw new Error('Unsupported os.type()! ' + os.type()); } })(); + const PKG_ROOT_DIR = path.join(__dirname, '..', '..'); const TEST_DIR = path.join(PKG_ROOT_DIR, '.test-dir'); const BIN_DIR = path.join(PKG_ROOT_DIR, '.flow-bins-cache'); @@ -132,7 +149,7 @@ async function getOrderedFlowBinVersions( const GH_CLIENT = gitHubClient(); // We only test against the latest numberOfReleases Versions const QUERY_PAGE_SIZE = numberOfReleases; - const OS_ARCH_FILTER_RE = new RegExp(`flow-${BIN_PLATFORM}`); + const OS_ARCH_FILTER_RE = new RegExp(`flow-${BIN_PLATFORM}-v`); let page = 0; const apiPayload = await GH_CLIENT.repos.listReleases({