Skip to content

Commit 7b3a9f6

Browse files
[Fix] Add platform "darwin-arm64" to unit test (#5290)
* Add platform "darwin-arm64" to unit test * Update related snapshots --------- Signed-off-by: Willie Hung <willie880201044@gmail.com> Signed-off-by: Josh Romero <rmerqg@amazon.com> Co-authored-by: Josh Romero <rmerqg@amazon.com>
1 parent 286cc38 commit 7b3a9f6

File tree

7 files changed

+74
-5
lines changed

7 files changed

+74
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
7070
- [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))
7171
- [Data Explorer] Remove the `X` icon in data source selection field ([#5238](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5238))
7272
- [BUG][Fuctional Test] Make setDefaultAbsoluteRange more robust and update doc views tests ([#5242](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5242))
73+
- [BUG] Add platform "darwin-arm64" to unit test ([#5290](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5290))
7374
- [BUG][Dev Tool] Add dev tool documentation link to dev tool's help menu [#5166](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5166)
7475

7576
### 🚞 Infrastructure

src/dev/build/lib/config.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const setup = async ({
5252
targetAllPlatforms = true,
5353
targetPlatforms = {
5454
darwin: false,
55+
darwinArm: false,
5556
linux: false,
5657
linuxArm: false,
5758
windows: false,
@@ -60,6 +61,7 @@ const setup = async ({
6061
targetAllPlatforms?: boolean;
6162
targetPlatforms?: {
6263
darwin: boolean;
64+
darwinArm: boolean;
6365
linux: boolean;
6466
linuxArm: boolean;
6567
windows: boolean;
@@ -89,9 +91,7 @@ describe('#getNodeRange()', () => {
8991
describe('#getRepoRelativePath()', () => {
9092
it('converts an absolute path to relative path, from the root of the repo', async () => {
9193
const config = await setup();
92-
expect(config.getRepoRelativePath(__dirname)).toMatchInlineSnapshot(
93-
`"${standardize('src/dev/build/lib', false, true)}"`
94-
);
94+
expect(config.getRepoRelativePath(__dirname)).toMatchInlineSnapshot(`"src/dev/build/lib"`);
9595
});
9696
});
9797

@@ -117,6 +117,7 @@ describe('#hasSpecifiedPlatform', () => {
117117
targetAllPlatforms: false,
118118
targetPlatforms: {
119119
darwin: true,
120+
darwinArm: false,
120121
linux: false,
121122
linuxArm: false,
122123
windows: false,
@@ -130,6 +131,7 @@ describe('#hasSpecifiedPlatform', () => {
130131
targetAllPlatforms: false,
131132
targetPlatforms: {
132133
darwin: false,
134+
darwinArm: false,
133135
linux: false,
134136
linuxArm: true,
135137
windows: false,
@@ -143,6 +145,7 @@ describe('#hasSpecifiedPlatform', () => {
143145
targetAllPlatforms: false,
144146
targetPlatforms: {
145147
darwin: false,
148+
darwinArm: false,
146149
linux: true,
147150
linuxArm: false,
148151
windows: false,
@@ -197,6 +200,7 @@ describe('#getTargetPlatforms()', () => {
197200
.sort()
198201
).toMatchInlineSnapshot(`
199202
Array [
203+
"darwin-arm64",
200204
"darwin-x64",
201205
"linux-arm64",
202206
"linux-x64",
@@ -210,6 +214,7 @@ describe('#getTargetPlatforms()', () => {
210214
targetAllPlatforms: false,
211215
targetPlatforms: {
212216
darwin: true,
217+
darwinArm: false,
213218
linux: false,
214219
linuxArm: false,
215220
windows: false,
@@ -233,6 +238,7 @@ describe('#getTargetPlatforms()', () => {
233238
targetAllPlatforms: false,
234239
targetPlatforms: {
235240
darwin: false,
241+
darwinArm: false,
236242
linux: true,
237243
linuxArm: false,
238244
windows: false,
@@ -256,6 +262,7 @@ describe('#getTargetPlatforms()', () => {
256262
targetAllPlatforms: false,
257263
targetPlatforms: {
258264
darwin: false,
265+
darwinArm: false,
259266
linux: false,
260267
linuxArm: true,
261268
windows: false,
@@ -279,6 +286,7 @@ describe('#getTargetPlatforms()', () => {
279286
targetAllPlatforms: false,
280287
targetPlatforms: {
281288
darwin: true,
289+
darwinArm: false,
282290
linux: false,
283291
linuxArm: true,
284292
windows: false,
@@ -315,7 +323,7 @@ describe('#getNodePlatforms()', () => {
315323
.getTargetPlatforms()
316324
.map((p) => p.getNodeArch())
317325
.sort()
318-
).toEqual(['darwin-x64', 'linux-arm64', 'linux-x64', 'win32-x64']);
326+
).toEqual(['darwin-arm64', 'darwin-x64', 'linux-arm64', 'linux-x64', 'win32-x64']);
319327
});
320328

321329
it('returns this platform and linux, when targetAllPlatforms = false', async () => {

src/dev/build/lib/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,10 @@ export class Config {
155155

156156
const platforms: Platform[] = [];
157157
if (this.targetPlatforms.darwin) platforms.push(this.getPlatform('darwin', 'x64'));
158+
if (this.targetPlatforms.darwinArm) platforms.push(this.getPlatform('darwin', 'arm64'));
158159
if (this.targetPlatforms.linux) platforms.push(this.getPlatform('linux', 'x64'));
159-
if (this.targetPlatforms.windows) platforms.push(this.getPlatform('win32', 'x64'));
160160
if (this.targetPlatforms.linuxArm) platforms.push(this.getPlatform('linux', 'arm64'));
161+
if (this.targetPlatforms.windows) platforms.push(this.getPlatform('win32', 'x64'));
161162

162163
if (platforms.length > 0) return platforms;
163164

src/dev/build/lib/platform.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export type PlatformArchitecture = 'x64' | 'arm64';
3333

3434
export interface TargetPlatforms {
3535
darwin: boolean;
36+
darwinArm: boolean;
3637
linuxArm: boolean;
3738
linux: boolean;
3839
windows: boolean;
@@ -78,5 +79,6 @@ export const ALL_PLATFORMS = [
7879
new Platform('linux', 'x64', 'linux-x64'),
7980
new Platform('linux', 'arm64', 'linux-arm64'),
8081
new Platform('darwin', 'x64', 'darwin-x64'),
82+
new Platform('darwin', 'arm64', 'darwin-arm64'),
8183
new Platform('win32', 'x64', 'windows-x64'),
8284
];

src/dev/build/tasks/nodejs/download_node_builds_task.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ it('downloads node builds for each platform', async () => {
137137
"url": "darwin:url",
138138
},
139139
],
140+
Array [
141+
Object {
142+
"destination": "darwin:downloadPath",
143+
"log": <ToolingLog>,
144+
"retries": 3,
145+
"sha256": "darwin:sha256",
146+
"url": "darwin:url",
147+
},
148+
],
140149
Array [
141150
Object {
142151
"destination": "win32:downloadPath",
@@ -173,6 +182,15 @@ it('downloads node builds for each platform', async () => {
173182
"url": "https://mirrors.nodejs.org/dist/v14.21.3/node-v14.21.3-darwin-x64.tar.gz",
174183
},
175184
],
185+
Array [
186+
Object {
187+
"destination": "/mocked/path/.node_binaries/14.21.3/node-v14.21.3-darwin-arm64.tar.gz",
188+
"log": <ToolingLog>,
189+
"retries": 3,
190+
"sha256": undefined,
191+
"url": "https://mirrors.nodejs.org/dist/v14.21.3/node-v14.21.3-darwin-arm64.tar.gz",
192+
},
193+
],
176194
Array [
177195
Object {
178196
"destination": "/mocked/path/.node_binaries/14.21.3/node-v14.21.3-win32-x64.tar.gz",

src/dev/build/tasks/nodejs/extract_node_builds_task.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ it('runs expected fs operations', async () => {
123123
"strip": 1,
124124
},
125125
],
126+
Array [
127+
<absolute path>/.node_binaries/<node version>/node-v<node version>-darwin-arm64.tar.gz,
128+
<absolute path>/.node_binaries/<node version>/darwin-arm64,
129+
Object {
130+
"strip": 1,
131+
},
132+
],
126133
Array [
127134
<absolute path>/.node_binaries/14.21.3/node-v14.21.3-linux-x64.tar.gz,
128135
<absolute path>/.node_binaries/14.21.3/linux-x64,
@@ -144,6 +151,13 @@ it('runs expected fs operations', async () => {
144151
"strip": 1,
145152
},
146153
],
154+
Array [
155+
<absolute path>/.node_binaries/14.21.3/node-v14.21.3-darwin-arm64.tar.gz,
156+
<absolute path>/.node_binaries/14.21.3/darwin-arm64,
157+
Object {
158+
"strip": 1,
159+
},
160+
],
147161
],
148162
"unzip": Array [
149163
Array [

src/dev/build/tasks/nodejs/verify_existing_node_builds_task.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ it('checks shasums for each downloaded node build', async () => {
120120
Object {
121121
"type": "return",
122122
"value": Object {
123+
"darwin:darwin-arm64:downloadName": "valid shasum",
123124
"darwin:darwin-x64:downloadName": "valid shasum",
124125
"linux:linux-arm64:downloadName": "valid shasum",
125126
"linux:linux-x64:downloadName": "valid shasum",
@@ -156,6 +157,14 @@ it('checks shasums for each downloaded node build', async () => {
156157
"name": "darwin",
157158
},
158159
],
160+
Array [
161+
<Config>,
162+
Platform {
163+
"architecture": "arm64",
164+
"buildName": "darwin-arm64",
165+
"name": "darwin",
166+
},
167+
],
159168
Array [
160169
<Config>,
161170
Platform {
@@ -190,6 +199,14 @@ it('checks shasums for each downloaded node build', async () => {
190199
"version": "<node version>",
191200
},
192201
},
202+
Object {
203+
"type": "return",
204+
"value": Object {
205+
"downloadName": "darwin:darwin-arm64:downloadName",
206+
"downloadPath": "darwin:darwin-arm64:downloadPath",
207+
"version": "<node version>",
208+
},
209+
},
193210
Object {
194211
"type": "return",
195212
"value": Object {
@@ -216,6 +233,10 @@ it('checks shasums for each downloaded node build', async () => {
216233
"darwin:darwin-x64:downloadPath",
217234
"sha256",
218235
],
236+
Array [
237+
"darwin:darwin-arm64:downloadPath",
238+
"sha256",
239+
],
219240
Array [
220241
"win32:win32-x64:downloadPath",
221242
"sha256",
@@ -238,6 +259,10 @@ it('checks shasums for each downloaded node build', async () => {
238259
"type": "return",
239260
"value": "valid shasum",
240261
},
262+
Object {
263+
"type": "return",
264+
"value": "valid shasum",
265+
},
241266
],
242267
}
243268
`);

0 commit comments

Comments
 (0)