Skip to content

Commit

Permalink
Add platform "darwin-arm64" to unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-hung committed Oct 13, 2023
1 parent b3104ce commit 7fb4d93
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
16 changes: 12 additions & 4 deletions src/dev/build/lib/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const setup = async ({
targetAllPlatforms = true,
targetPlatforms = {
darwin: false,
darwinArm: false,
linux: false,
linuxArm: false,
windows: false,
Expand All @@ -60,6 +61,7 @@ const setup = async ({
targetAllPlatforms?: boolean;
targetPlatforms?: {
darwin: boolean;
darwinArm: boolean;
linux: boolean;
linuxArm: boolean;
windows: boolean;
Expand Down Expand Up @@ -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"`);
});
});

Expand All @@ -117,6 +117,7 @@ describe('#hasSpecifiedPlatform', () => {
targetAllPlatforms: false,
targetPlatforms: {
darwin: true,
darwinArm: false,
linux: false,
linuxArm: false,
windows: false,
Expand All @@ -130,6 +131,7 @@ describe('#hasSpecifiedPlatform', () => {
targetAllPlatforms: false,
targetPlatforms: {
darwin: false,
darwinArm: false,
linux: false,
linuxArm: true,
windows: false,
Expand All @@ -143,6 +145,7 @@ describe('#hasSpecifiedPlatform', () => {
targetAllPlatforms: false,
targetPlatforms: {
darwin: false,
darwinArm: false,
linux: true,
linuxArm: false,
windows: false,
Expand Down Expand Up @@ -197,6 +200,7 @@ describe('#getTargetPlatforms()', () => {
.sort()
).toMatchInlineSnapshot(`
Array [
"darwin-arm64",
"darwin-x64",
"linux-arm64",
"linux-x64",
Expand All @@ -210,6 +214,7 @@ describe('#getTargetPlatforms()', () => {
targetAllPlatforms: false,
targetPlatforms: {
darwin: true,
darwinArm: false,
linux: false,
linuxArm: false,
windows: false,
Expand All @@ -233,6 +238,7 @@ describe('#getTargetPlatforms()', () => {
targetAllPlatforms: false,
targetPlatforms: {
darwin: false,
darwinArm: false,
linux: true,
linuxArm: false,
windows: false,
Expand All @@ -256,6 +262,7 @@ describe('#getTargetPlatforms()', () => {
targetAllPlatforms: false,
targetPlatforms: {
darwin: false,
darwinArm: false,
linux: false,
linuxArm: true,
windows: false,
Expand All @@ -279,6 +286,7 @@ describe('#getTargetPlatforms()', () => {
targetAllPlatforms: false,
targetPlatforms: {
darwin: true,
darwinArm: false,
linux: false,
linuxArm: true,
windows: false,
Expand Down Expand Up @@ -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 () => {
Expand Down
3 changes: 2 additions & 1 deletion src/dev/build/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/dev/build/lib/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type PlatformArchitecture = 'x64' | 'arm64';

export interface TargetPlatforms {
darwin: boolean;
darwinArm: boolean;
linuxArm: boolean;
linux: boolean;
windows: boolean;
Expand Down Expand Up @@ -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'),
];

0 comments on commit 7fb4d93

Please sign in to comment.