Skip to content

Commit

Permalink
[Fix] Add platform "darwin-arm64" to unit test (opensearch-project#5290)
Browse files Browse the repository at this point in the history
* Add platform "darwin-arm64" to unit test
* Update related snapshots

---------

Signed-off-by: Willie Hung <[email protected]>
Signed-off-by: Josh Romero <[email protected]>
Co-authored-by: Josh Romero <[email protected]>
  • Loading branch information
willie-hung and joshuarrrr authored Oct 18, 2023
1 parent 286cc38 commit 7b3a9f6
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [BUG][Data Explorer][Discover] Allow filter and query persist when refresh page or paste url to a new tab ([#5206](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5206))
- [Data Explorer] Remove the `X` icon in data source selection field ([#5238](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5238))
- [BUG][Fuctional Test] Make setDefaultAbsoluteRange more robust and update doc views tests ([#5242](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5242))
- [BUG] Add platform "darwin-arm64" to unit test ([#5290](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5290))
- [BUG][Dev Tool] Add dev tool documentation link to dev tool's help menu [#5166](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5166)

### 🚞 Infrastructure
Expand Down
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'),
];
18 changes: 18 additions & 0 deletions src/dev/build/tasks/nodejs/download_node_builds_task.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ it('downloads node builds for each platform', async () => {
"url": "darwin:url",
},
],
Array [
Object {
"destination": "darwin:downloadPath",
"log": <ToolingLog>,
"retries": 3,
"sha256": "darwin:sha256",
"url": "darwin:url",
},
],
Array [
Object {
"destination": "win32:downloadPath",
Expand Down Expand Up @@ -173,6 +182,15 @@ it('downloads node builds for each platform', async () => {
"url": "https://mirrors.nodejs.org/dist/v14.21.3/node-v14.21.3-darwin-x64.tar.gz",
},
],
Array [
Object {
"destination": "/mocked/path/.node_binaries/14.21.3/node-v14.21.3-darwin-arm64.tar.gz",
"log": <ToolingLog>,
"retries": 3,
"sha256": undefined,
"url": "https://mirrors.nodejs.org/dist/v14.21.3/node-v14.21.3-darwin-arm64.tar.gz",
},
],
Array [
Object {
"destination": "/mocked/path/.node_binaries/14.21.3/node-v14.21.3-win32-x64.tar.gz",
Expand Down
14 changes: 14 additions & 0 deletions src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ it('runs expected fs operations', async () => {
"strip": 1,
},
],
Array [
<absolute path>/.node_binaries/<node version>/node-v<node version>-darwin-arm64.tar.gz,
<absolute path>/.node_binaries/<node version>/darwin-arm64,
Object {
"strip": 1,
},
],
Array [
<absolute path>/.node_binaries/14.21.3/node-v14.21.3-linux-x64.tar.gz,
<absolute path>/.node_binaries/14.21.3/linux-x64,
Expand All @@ -144,6 +151,13 @@ it('runs expected fs operations', async () => {
"strip": 1,
},
],
Array [
<absolute path>/.node_binaries/14.21.3/node-v14.21.3-darwin-arm64.tar.gz,
<absolute path>/.node_binaries/14.21.3/darwin-arm64,
Object {
"strip": 1,
},
],
],
"unzip": Array [
Array [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ it('checks shasums for each downloaded node build', async () => {
Object {
"type": "return",
"value": Object {
"darwin:darwin-arm64:downloadName": "valid shasum",
"darwin:darwin-x64:downloadName": "valid shasum",
"linux:linux-arm64:downloadName": "valid shasum",
"linux:linux-x64:downloadName": "valid shasum",
Expand Down Expand Up @@ -156,6 +157,14 @@ it('checks shasums for each downloaded node build', async () => {
"name": "darwin",
},
],
Array [
<Config>,
Platform {
"architecture": "arm64",
"buildName": "darwin-arm64",
"name": "darwin",
},
],
Array [
<Config>,
Platform {
Expand Down Expand Up @@ -190,6 +199,14 @@ it('checks shasums for each downloaded node build', async () => {
"version": "<node version>",
},
},
Object {
"type": "return",
"value": Object {
"downloadName": "darwin:darwin-arm64:downloadName",
"downloadPath": "darwin:darwin-arm64:downloadPath",
"version": "<node version>",
},
},
Object {
"type": "return",
"value": Object {
Expand All @@ -216,6 +233,10 @@ it('checks shasums for each downloaded node build', async () => {
"darwin:darwin-x64:downloadPath",
"sha256",
],
Array [
"darwin:darwin-arm64:downloadPath",
"sha256",
],
Array [
"win32:win32-x64:downloadPath",
"sha256",
Expand All @@ -238,6 +259,10 @@ it('checks shasums for each downloaded node build', async () => {
"type": "return",
"value": "valid shasum",
},
Object {
"type": "return",
"value": "valid shasum",
},
],
}
`);
Expand Down

0 comments on commit 7b3a9f6

Please sign in to comment.