Skip to content

Commit

Permalink
[cli] Fix running definition tests locally on MacOS (#4440)
Browse files Browse the repository at this point in the history
* fix tests running on macos

* remove extra log
  • Loading branch information
Brianzchen committed May 14, 2023
1 parent a28ae95 commit 250e0cb
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions cli/src/commands/runTests.js
Expand Up @@ -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';
Expand All @@ -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');
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 250e0cb

Please sign in to comment.