From 7fb4d9332fb641e250340a1d67e0f48036db0e10 Mon Sep 17 00:00:00 2001 From: Willie Hung Date: Fri, 13 Oct 2023 00:01:50 -0500 Subject: [PATCH] Add platform "darwin-arm64" to unit test --- src/dev/build/lib/config.test.ts | 16 ++++++++++++---- src/dev/build/lib/config.ts | 3 ++- src/dev/build/lib/platform.ts | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/dev/build/lib/config.test.ts b/src/dev/build/lib/config.test.ts index 145954c1fb40..51c7f66be893 100644 --- a/src/dev/build/lib/config.test.ts +++ b/src/dev/build/lib/config.test.ts @@ -52,6 +52,7 @@ const setup = async ({ targetAllPlatforms = true, targetPlatforms = { darwin: false, + darwinArm: false, linux: false, linuxArm: false, windows: false, @@ -60,6 +61,7 @@ const setup = async ({ targetAllPlatforms?: boolean; targetPlatforms?: { darwin: boolean; + darwinArm: boolean; linux: boolean; linuxArm: boolean; windows: boolean; @@ -89,9 +91,7 @@ describe('#getNodeRange()', () => { describe('#getRepoRelativePath()', () => { it('converts an absolute path to relative path, from the root of the repo', async () => { const config = await setup(); - expect(config.getRepoRelativePath(__dirname)).toMatchInlineSnapshot( - `"${standardize('src/dev/build/lib', false, true)}"` - ); + expect(config.getRepoRelativePath(__dirname)).toMatchInlineSnapshot(`"src/dev/build/lib"`); }); }); @@ -117,6 +117,7 @@ describe('#hasSpecifiedPlatform', () => { targetAllPlatforms: false, targetPlatforms: { darwin: true, + darwinArm: false, linux: false, linuxArm: false, windows: false, @@ -130,6 +131,7 @@ describe('#hasSpecifiedPlatform', () => { targetAllPlatforms: false, targetPlatforms: { darwin: false, + darwinArm: false, linux: false, linuxArm: true, windows: false, @@ -143,6 +145,7 @@ describe('#hasSpecifiedPlatform', () => { targetAllPlatforms: false, targetPlatforms: { darwin: false, + darwinArm: false, linux: true, linuxArm: false, windows: false, @@ -197,6 +200,7 @@ describe('#getTargetPlatforms()', () => { .sort() ).toMatchInlineSnapshot(` Array [ + "darwin-arm64", "darwin-x64", "linux-arm64", "linux-x64", @@ -210,6 +214,7 @@ describe('#getTargetPlatforms()', () => { targetAllPlatforms: false, targetPlatforms: { darwin: true, + darwinArm: false, linux: false, linuxArm: false, windows: false, @@ -233,6 +238,7 @@ describe('#getTargetPlatforms()', () => { targetAllPlatforms: false, targetPlatforms: { darwin: false, + darwinArm: false, linux: true, linuxArm: false, windows: false, @@ -256,6 +262,7 @@ describe('#getTargetPlatforms()', () => { targetAllPlatforms: false, targetPlatforms: { darwin: false, + darwinArm: false, linux: false, linuxArm: true, windows: false, @@ -279,6 +286,7 @@ describe('#getTargetPlatforms()', () => { targetAllPlatforms: false, targetPlatforms: { darwin: true, + darwinArm: false, linux: false, linuxArm: true, windows: false, @@ -315,7 +323,7 @@ describe('#getNodePlatforms()', () => { .getTargetPlatforms() .map((p) => p.getNodeArch()) .sort() - ).toEqual(['darwin-x64', 'linux-arm64', 'linux-x64', 'win32-x64']); + ).toEqual(['darwin-arm64', 'darwin-x64', 'linux-arm64', 'linux-x64', 'win32-x64']); }); it('returns this platform and linux, when targetAllPlatforms = false', async () => { diff --git a/src/dev/build/lib/config.ts b/src/dev/build/lib/config.ts index 6af5b8e6901a..c8750e9234b3 100644 --- a/src/dev/build/lib/config.ts +++ b/src/dev/build/lib/config.ts @@ -155,9 +155,10 @@ export class Config { const platforms: Platform[] = []; if (this.targetPlatforms.darwin) platforms.push(this.getPlatform('darwin', 'x64')); + if (this.targetPlatforms.darwinArm) platforms.push(this.getPlatform('darwin', 'arm64')); if (this.targetPlatforms.linux) platforms.push(this.getPlatform('linux', 'x64')); - if (this.targetPlatforms.windows) platforms.push(this.getPlatform('win32', 'x64')); if (this.targetPlatforms.linuxArm) platforms.push(this.getPlatform('linux', 'arm64')); + if (this.targetPlatforms.windows) platforms.push(this.getPlatform('win32', 'x64')); if (platforms.length > 0) return platforms; diff --git a/src/dev/build/lib/platform.ts b/src/dev/build/lib/platform.ts index 673356ec6205..f83107f73734 100644 --- a/src/dev/build/lib/platform.ts +++ b/src/dev/build/lib/platform.ts @@ -33,6 +33,7 @@ export type PlatformArchitecture = 'x64' | 'arm64'; export interface TargetPlatforms { darwin: boolean; + darwinArm: boolean; linuxArm: boolean; linux: boolean; windows: boolean; @@ -78,5 +79,6 @@ export const ALL_PLATFORMS = [ new Platform('linux', 'x64', 'linux-x64'), new Platform('linux', 'arm64', 'linux-arm64'), new Platform('darwin', 'x64', 'darwin-x64'), + new Platform('darwin', 'arm64', 'darwin-arm64'), new Platform('win32', 'x64', 'windows-x64'), ];