@react-native-harness/platform-android 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/adb-id.test.d.ts +2 -0
- package/dist/__tests__/adb-id.test.d.ts.map +1 -0
- package/dist/__tests__/adb-id.test.js +41 -0
- package/dist/__tests__/adb.test.js +148 -13
- package/dist/__tests__/app-monitor.test.js +52 -75
- package/dist/__tests__/emulator-startup.test.js +1 -0
- package/dist/__tests__/instance.test.js +97 -36
- package/dist/adb-errors.d.ts +16 -0
- package/dist/adb-errors.d.ts.map +1 -0
- package/dist/adb-errors.js +35 -0
- package/dist/adb-id.d.ts.map +1 -1
- package/dist/adb-id.js +3 -0
- package/dist/adb.d.ts +4 -0
- package/dist/adb.d.ts.map +1 -1
- package/dist/adb.js +124 -1
- package/dist/app-monitor.d.ts.map +1 -1
- package/dist/app-monitor.js +2 -5
- package/dist/emulator-startup.d.ts.map +1 -1
- package/dist/emulator-startup.js +0 -2
- package/dist/instance.d.ts.map +1 -1
- package/dist/instance.js +25 -2
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/eslint.config.mjs +1 -0
- package/package.json +5 -4
- package/src/__tests__/adb-id.test.ts +51 -0
- package/src/__tests__/emulator-startup.test.ts +3 -0
- package/src/__tests__/instance.test.ts +143 -51
- package/src/adb-errors.ts +47 -0
- package/src/adb-id.ts +4 -0
- package/src/adb.ts +174 -1
- package/src/app-monitor.ts +3 -8
- package/src/emulator-startup.ts +0 -2
- package/src/instance.ts +30 -2
- package/test/setup.ts +68 -0
- package/vite.config.ts +19 -0
- package/src/__tests__/adb.test.ts +0 -598
- package/src/__tests__/app-monitor.test.ts +0 -273
- package/src/__tests__/environment.test.ts +0 -212
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { tmpdir } from 'node:os';
|
|
5
|
-
import { createAndroidAppMonitor, createAndroidLogEvent } from '../app-monitor.js';
|
|
6
|
-
import * as tools from '@react-native-harness/tools';
|
|
7
|
-
import { createCrashArtifactWriter } from '@react-native-harness/tools';
|
|
8
|
-
|
|
9
|
-
const createMockSubprocess = (): tools.Subprocess =>
|
|
10
|
-
({
|
|
11
|
-
nodeChildProcess: Promise.resolve({
|
|
12
|
-
kill: vi.fn(),
|
|
13
|
-
}),
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
15
|
-
[Symbol.asyncIterator]: async function* () {},
|
|
16
|
-
}) as unknown as tools.Subprocess;
|
|
17
|
-
|
|
18
|
-
const createStreamingSubprocess = (
|
|
19
|
-
chunks: Array<{ line: string; delayMs?: number }>
|
|
20
|
-
): tools.Subprocess =>
|
|
21
|
-
({
|
|
22
|
-
nodeChildProcess: Promise.resolve({
|
|
23
|
-
kill: vi.fn(),
|
|
24
|
-
}),
|
|
25
|
-
[Symbol.asyncIterator]: async function* () {
|
|
26
|
-
for (const { line, delayMs = 0 } of chunks) {
|
|
27
|
-
if (delayMs > 0) {
|
|
28
|
-
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
yield line;
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
}) as unknown as tools.Subprocess;
|
|
35
|
-
|
|
36
|
-
const artifactRoot = fs.mkdtempSync(
|
|
37
|
-
path.join(tmpdir(), 'rn-harness-android-monitor-artifacts-')
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
afterEach(() => {
|
|
41
|
-
fs.rmSync(artifactRoot, { recursive: true, force: true });
|
|
42
|
-
fs.mkdirSync(artifactRoot, { recursive: true });
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
describe('createAndroidLogEvent', () => {
|
|
46
|
-
it('extracts crash details from fatal signal log lines', () => {
|
|
47
|
-
const event = createAndroidLogEvent(
|
|
48
|
-
'03-12 11:35:08.000 1234 1234 F libc : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR) in tid 1234 (com.harnessplayground), pid 1234 (com.harnessplayground)',
|
|
49
|
-
'com.harnessplayground'
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
expect(event).toMatchObject({
|
|
53
|
-
type: 'possible_crash',
|
|
54
|
-
source: 'logs',
|
|
55
|
-
crashDetails: {
|
|
56
|
-
source: 'logs',
|
|
57
|
-
signal: 'SIGSEGV',
|
|
58
|
-
summary:
|
|
59
|
-
'03-12 11:35:08.000 1234 1234 F libc : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR) in tid 1234 (com.harnessplayground), pid 1234 (com.harnessplayground)',
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('extracts process and pid when AndroidRuntime reports a crash', () => {
|
|
65
|
-
const event = createAndroidLogEvent(
|
|
66
|
-
'03-12 11:35:09.000 1234 1234 E AndroidRuntime: Process: com.harnessplayground, PID: 1234',
|
|
67
|
-
'com.harnessplayground'
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
expect(event).toMatchObject({
|
|
71
|
-
type: 'possible_crash',
|
|
72
|
-
pid: 1234,
|
|
73
|
-
crashDetails: {
|
|
74
|
-
processName: 'com.harnessplayground',
|
|
75
|
-
pid: 1234,
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('starts logcat from the current device timestamp', async () => {
|
|
81
|
-
const spawnSpy = vi.spyOn(tools, 'spawn');
|
|
82
|
-
|
|
83
|
-
spawnSpy.mockImplementation(
|
|
84
|
-
((file: string, args?: readonly string[]) => {
|
|
85
|
-
if (file === 'adb' && args?.includes('date')) {
|
|
86
|
-
return {
|
|
87
|
-
stdout: '03-12 11:35:08.000\n',
|
|
88
|
-
} as Awaited<ReturnType<typeof tools.spawn>>;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return createMockSubprocess();
|
|
92
|
-
}) as typeof tools.spawn
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
const monitor = createAndroidAppMonitor({
|
|
96
|
-
adbId: 'emulator-5554',
|
|
97
|
-
bundleId: 'com.harnessplayground',
|
|
98
|
-
appUid: 10234,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
await monitor.start();
|
|
102
|
-
await monitor.stop();
|
|
103
|
-
|
|
104
|
-
expect(spawnSpy).toHaveBeenNthCalledWith(2, 'adb', [
|
|
105
|
-
'-s',
|
|
106
|
-
'emulator-5554',
|
|
107
|
-
'logcat',
|
|
108
|
-
'-v',
|
|
109
|
-
'threadtime',
|
|
110
|
-
'-b',
|
|
111
|
-
'crash',
|
|
112
|
-
'--uid=10234',
|
|
113
|
-
'-T',
|
|
114
|
-
'03-12 11:35:08.000',
|
|
115
|
-
], {
|
|
116
|
-
stdout: 'pipe',
|
|
117
|
-
stderr: 'pipe',
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('hydrates crash details with stack lines that arrive after the first crash event', async () => {
|
|
122
|
-
const spawnSpy = vi.spyOn(tools, 'spawn');
|
|
123
|
-
|
|
124
|
-
spawnSpy.mockImplementation(
|
|
125
|
-
((file: string, args?: readonly string[]) => {
|
|
126
|
-
if (file === 'adb' && args?.includes('date')) {
|
|
127
|
-
return {
|
|
128
|
-
stdout: '03-12 10:44:40.000\n',
|
|
129
|
-
} as Awaited<ReturnType<typeof tools.spawn>>;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return createStreamingSubprocess([
|
|
133
|
-
{ line: '--------- beginning of crash' },
|
|
134
|
-
{
|
|
135
|
-
line: '03-12 10:44:40.420 13861 13861 E AndroidRuntime: Process: com.harnessplayground, PID: 13861',
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
line: '03-12 10:44:40.421 13861 13861 E AndroidRuntime: java.lang.RuntimeException: boom',
|
|
139
|
-
delayMs: 25,
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
line: '03-12 10:44:40.422 13861 13861 E AndroidRuntime: at com.harnessplayground.MainActivity.onCreate(MainActivity.kt:42)',
|
|
143
|
-
delayMs: 25,
|
|
144
|
-
},
|
|
145
|
-
]);
|
|
146
|
-
}) as typeof tools.spawn
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
const monitor = createAndroidAppMonitor({
|
|
150
|
-
adbId: 'emulator-5554',
|
|
151
|
-
bundleId: 'com.harnessplayground',
|
|
152
|
-
appUid: 10234,
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
await monitor.start();
|
|
156
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
157
|
-
|
|
158
|
-
const details = await monitor.getCrashDetails({
|
|
159
|
-
pid: 13861,
|
|
160
|
-
occurredAt: Date.now(),
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
await monitor.stop();
|
|
164
|
-
|
|
165
|
-
expect(details?.rawLines).toEqual([
|
|
166
|
-
'--------- beginning of crash',
|
|
167
|
-
'03-12 10:44:40.420 13861 13861 E AndroidRuntime: Process: com.harnessplayground, PID: 13861',
|
|
168
|
-
'03-12 10:44:40.421 13861 13861 E AndroidRuntime: java.lang.RuntimeException: boom',
|
|
169
|
-
'03-12 10:44:40.422 13861 13861 E AndroidRuntime: at com.harnessplayground.MainActivity.onCreate(MainActivity.kt:42)',
|
|
170
|
-
]);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('persists resolved Android crash blocks into .harness', async () => {
|
|
174
|
-
const spawnSpy = vi.spyOn(tools, 'spawn');
|
|
175
|
-
|
|
176
|
-
spawnSpy.mockImplementation(
|
|
177
|
-
((file: string, args?: readonly string[]) => {
|
|
178
|
-
if (file === 'adb' && args?.includes('date')) {
|
|
179
|
-
return {
|
|
180
|
-
stdout: '03-12 10:44:40.000\n',
|
|
181
|
-
} as Awaited<ReturnType<typeof tools.spawn>>;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return createStreamingSubprocess([
|
|
185
|
-
{ line: '--------- beginning of crash' },
|
|
186
|
-
{
|
|
187
|
-
line: '03-12 10:44:40.420 13861 13861 E AndroidRuntime: Process: com.harnessplayground, PID: 13861',
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
line: '03-12 10:44:40.421 13861 13861 E AndroidRuntime: java.lang.RuntimeException: boom',
|
|
191
|
-
delayMs: 20,
|
|
192
|
-
},
|
|
193
|
-
]);
|
|
194
|
-
}) as typeof tools.spawn
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
const monitor = createAndroidAppMonitor({
|
|
198
|
-
adbId: 'emulator-5554',
|
|
199
|
-
bundleId: 'com.harnessplayground',
|
|
200
|
-
appUid: 10234,
|
|
201
|
-
crashArtifactWriter: createCrashArtifactWriter({
|
|
202
|
-
runnerName: 'android',
|
|
203
|
-
platformId: 'android',
|
|
204
|
-
rootDir: path.join(artifactRoot, '.harness', 'crash-reports'),
|
|
205
|
-
runTimestamp: '2026-03-12T11-35-08-000Z',
|
|
206
|
-
}),
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
await monitor.start();
|
|
210
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
211
|
-
|
|
212
|
-
const details = await monitor.getCrashDetails({
|
|
213
|
-
pid: 13861,
|
|
214
|
-
occurredAt: Date.now(),
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
await monitor.stop();
|
|
218
|
-
|
|
219
|
-
expect(details?.artifactPath).toContain('/.harness/crash-reports/');
|
|
220
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
221
|
-
expect(fs.readFileSync(details!.artifactPath!, 'utf8')).toContain(
|
|
222
|
-
'RuntimeException: boom'
|
|
223
|
-
);
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it('can be started again after timestamp lookup fails', async () => {
|
|
227
|
-
const spawnSpy = vi.spyOn(tools, 'spawn');
|
|
228
|
-
const timestampError = new Error('date failed');
|
|
229
|
-
|
|
230
|
-
spawnSpy.mockImplementation(
|
|
231
|
-
((file: string, args?: readonly string[]) => {
|
|
232
|
-
if (file === 'adb' && args?.includes('date')) {
|
|
233
|
-
if (
|
|
234
|
-
spawnSpy.mock.calls.filter(
|
|
235
|
-
([calledFile, calledArgs]) =>
|
|
236
|
-
calledFile === 'adb' &&
|
|
237
|
-
Array.isArray(calledArgs) &&
|
|
238
|
-
calledArgs.includes('date')
|
|
239
|
-
).length === 1
|
|
240
|
-
) {
|
|
241
|
-
throw timestampError;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return {
|
|
245
|
-
stdout: '03-12 11:35:08.000\n',
|
|
246
|
-
} as Awaited<ReturnType<typeof tools.spawn>>;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return createMockSubprocess();
|
|
250
|
-
}) as typeof tools.spawn
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
const monitor = createAndroidAppMonitor({
|
|
254
|
-
adbId: 'emulator-5554',
|
|
255
|
-
bundleId: 'com.harnessplayground',
|
|
256
|
-
appUid: 10234,
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
await expect(monitor.start()).rejects.toThrow(timestampError);
|
|
260
|
-
await expect(monitor.start()).resolves.toBeUndefined();
|
|
261
|
-
await monitor.stop();
|
|
262
|
-
|
|
263
|
-
expect(
|
|
264
|
-
spawnSpy.mock.calls.some(
|
|
265
|
-
([file, args]) =>
|
|
266
|
-
file === 'adb' &&
|
|
267
|
-
Array.isArray(args) &&
|
|
268
|
-
args.includes('logcat') &&
|
|
269
|
-
args.includes('--uid=10234')
|
|
270
|
-
)
|
|
271
|
-
).toBe(true);
|
|
272
|
-
});
|
|
273
|
-
});
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import os from 'node:os';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import {
|
|
6
|
-
ensureAndroidAdbAvailable,
|
|
7
|
-
ensureAndroidEmulatorAvailable,
|
|
8
|
-
getAndroidSdkRoot,
|
|
9
|
-
getAndroidSystemImagePackage,
|
|
10
|
-
getDefaultUnixAndroidSdkRoot,
|
|
11
|
-
getHostAndroidSystemImageArch,
|
|
12
|
-
getRequiredAndroidSdkPackages,
|
|
13
|
-
} from '../environment.js';
|
|
14
|
-
import * as tools from '@react-native-harness/tools';
|
|
15
|
-
|
|
16
|
-
describe('Android environment', () => {
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
vi.restoreAllMocks();
|
|
19
|
-
vi.unstubAllEnvs();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('skips bootstrapping command-line tools when adb is already installed', async () => {
|
|
23
|
-
const sdkRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'android-sdk-'));
|
|
24
|
-
const adbPath = path.join(sdkRoot, 'platform-tools', 'adb');
|
|
25
|
-
|
|
26
|
-
fs.mkdirSync(path.dirname(adbPath), { recursive: true });
|
|
27
|
-
fs.writeFileSync(adbPath, '');
|
|
28
|
-
|
|
29
|
-
const spawnSpy = vi.spyOn(tools, 'spawn');
|
|
30
|
-
|
|
31
|
-
await expect(
|
|
32
|
-
ensureAndroidAdbAvailable({
|
|
33
|
-
env: { ANDROID_HOME: sdkRoot },
|
|
34
|
-
}),
|
|
35
|
-
).resolves.toBe(sdkRoot);
|
|
36
|
-
|
|
37
|
-
expect(spawnSpy).not.toHaveBeenCalled();
|
|
38
|
-
|
|
39
|
-
fs.rmSync(sdkRoot, { force: true, recursive: true });
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('installs only platform-tools when adb is missing', async () => {
|
|
43
|
-
const sdkRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'android-sdk-'));
|
|
44
|
-
const sdkManagerDirectory = path.join(
|
|
45
|
-
sdkRoot,
|
|
46
|
-
'cmdline-tools',
|
|
47
|
-
'latest',
|
|
48
|
-
'bin',
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
fs.mkdirSync(sdkManagerDirectory, { recursive: true });
|
|
52
|
-
fs.writeFileSync(path.join(sdkManagerDirectory, 'sdkmanager'), '');
|
|
53
|
-
fs.writeFileSync(path.join(sdkManagerDirectory, 'avdmanager'), '');
|
|
54
|
-
|
|
55
|
-
const spawnSpy = vi.spyOn(tools, 'spawn').mockImplementation((async (
|
|
56
|
-
command: string,
|
|
57
|
-
args?: readonly string[],
|
|
58
|
-
) => {
|
|
59
|
-
if (command === 'bash' && typeof args?.[1] === 'string') {
|
|
60
|
-
const commandString = args[1];
|
|
61
|
-
|
|
62
|
-
if (commandString.includes('platform-tools')) {
|
|
63
|
-
const adbPath = path.join(sdkRoot, 'platform-tools', 'adb');
|
|
64
|
-
fs.mkdirSync(path.dirname(adbPath), { recursive: true });
|
|
65
|
-
fs.writeFileSync(adbPath, '');
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return {} as Awaited<ReturnType<typeof tools.spawn>>;
|
|
70
|
-
}) as typeof tools.spawn);
|
|
71
|
-
|
|
72
|
-
await expect(
|
|
73
|
-
ensureAndroidAdbAvailable({
|
|
74
|
-
env: { ANDROID_HOME: sdkRoot },
|
|
75
|
-
}),
|
|
76
|
-
).resolves.toBe(sdkRoot);
|
|
77
|
-
|
|
78
|
-
expect(spawnSpy).toHaveBeenCalledWith(
|
|
79
|
-
'bash',
|
|
80
|
-
['-lc', expect.stringContaining('platform-tools')],
|
|
81
|
-
expect.any(Object),
|
|
82
|
-
);
|
|
83
|
-
expect(
|
|
84
|
-
spawnSpy.mock.calls.some(
|
|
85
|
-
([command, args]) =>
|
|
86
|
-
command === 'bash' &&
|
|
87
|
-
typeof args?.[1] === 'string' &&
|
|
88
|
-
args[1].includes('platform-tools') &&
|
|
89
|
-
args[1].includes('emulator'),
|
|
90
|
-
),
|
|
91
|
-
).toBe(false);
|
|
92
|
-
|
|
93
|
-
fs.rmSync(sdkRoot, { force: true, recursive: true });
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('installs emulator only when emulator is missing', async () => {
|
|
97
|
-
const sdkRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'android-sdk-'));
|
|
98
|
-
const sdkManagerDirectory = path.join(
|
|
99
|
-
sdkRoot,
|
|
100
|
-
'cmdline-tools',
|
|
101
|
-
'latest',
|
|
102
|
-
'bin',
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
fs.mkdirSync(sdkManagerDirectory, { recursive: true });
|
|
106
|
-
fs.writeFileSync(path.join(sdkManagerDirectory, 'sdkmanager'), '');
|
|
107
|
-
fs.writeFileSync(path.join(sdkManagerDirectory, 'avdmanager'), '');
|
|
108
|
-
|
|
109
|
-
const spawnSpy = vi.spyOn(tools, 'spawn').mockImplementation((async (
|
|
110
|
-
command: string,
|
|
111
|
-
args?: readonly string[],
|
|
112
|
-
) => {
|
|
113
|
-
if (command === 'bash' && typeof args?.[1] === 'string') {
|
|
114
|
-
const commandString = args[1];
|
|
115
|
-
|
|
116
|
-
if (commandString.includes('emulator')) {
|
|
117
|
-
const emulatorPath = path.join(sdkRoot, 'emulator', 'emulator');
|
|
118
|
-
fs.mkdirSync(path.dirname(emulatorPath), { recursive: true });
|
|
119
|
-
fs.writeFileSync(emulatorPath, '');
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return {} as Awaited<ReturnType<typeof tools.spawn>>;
|
|
124
|
-
}) as typeof tools.spawn);
|
|
125
|
-
|
|
126
|
-
await expect(
|
|
127
|
-
ensureAndroidEmulatorAvailable({
|
|
128
|
-
env: { ANDROID_HOME: sdkRoot },
|
|
129
|
-
}),
|
|
130
|
-
).resolves.toBe(sdkRoot);
|
|
131
|
-
|
|
132
|
-
expect(spawnSpy).toHaveBeenCalledWith(
|
|
133
|
-
'bash',
|
|
134
|
-
['-lc', expect.stringContaining('emulator')],
|
|
135
|
-
expect.any(Object),
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
fs.rmSync(sdkRoot, { force: true, recursive: true });
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('uses the default Unix SDK root when env vars are missing', () => {
|
|
142
|
-
expect(
|
|
143
|
-
getDefaultUnixAndroidSdkRoot({
|
|
144
|
-
platform: 'darwin',
|
|
145
|
-
homeDirectory: '/Users/tester',
|
|
146
|
-
}),
|
|
147
|
-
).toBe('/Users/tester/Library/Android/sdk');
|
|
148
|
-
|
|
149
|
-
expect(
|
|
150
|
-
getAndroidSdkRoot(
|
|
151
|
-
{},
|
|
152
|
-
{
|
|
153
|
-
platform: 'linux',
|
|
154
|
-
homeDirectory: '/home/tester',
|
|
155
|
-
},
|
|
156
|
-
),
|
|
157
|
-
).toBe('/home/tester/Android/Sdk');
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('prefers ANDROID_HOME and ANDROID_SDK_ROOT over default paths', () => {
|
|
161
|
-
expect(
|
|
162
|
-
getAndroidSdkRoot(
|
|
163
|
-
{
|
|
164
|
-
ANDROID_HOME: '/env/android-home',
|
|
165
|
-
ANDROID_SDK_ROOT: '/env/android-sdk-root',
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
platform: 'darwin',
|
|
169
|
-
homeDirectory: '/Users/tester',
|
|
170
|
-
},
|
|
171
|
-
),
|
|
172
|
-
).toBe('/env/android-home');
|
|
173
|
-
|
|
174
|
-
expect(
|
|
175
|
-
getAndroidSdkRoot(
|
|
176
|
-
{
|
|
177
|
-
ANDROID_SDK_ROOT: '/env/android-sdk-root',
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
platform: 'linux',
|
|
181
|
-
homeDirectory: '/home/tester',
|
|
182
|
-
},
|
|
183
|
-
),
|
|
184
|
-
).toBe('/env/android-sdk-root');
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('selects Android packages using the host architecture', () => {
|
|
188
|
-
expect(getHostAndroidSystemImageArch('x64')).toBe('x86_64');
|
|
189
|
-
expect(getHostAndroidSystemImageArch('arm64')).toBe('arm64-v8a');
|
|
190
|
-
expect(getAndroidSystemImagePackage(35, 'x86_64')).toBe(
|
|
191
|
-
'system-images;android-35;default;x86_64',
|
|
192
|
-
);
|
|
193
|
-
expect(getAndroidSystemImagePackage(35, 'arm64-v8a')).toBe(
|
|
194
|
-
'system-images;android-35;default;arm64-v8a',
|
|
195
|
-
);
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it('derives emulator package requirements from runner config fields', () => {
|
|
199
|
-
expect(
|
|
200
|
-
getRequiredAndroidSdkPackages({
|
|
201
|
-
apiLevel: 34,
|
|
202
|
-
includeEmulator: true,
|
|
203
|
-
architecture: 'x86_64',
|
|
204
|
-
}),
|
|
205
|
-
).toEqual([
|
|
206
|
-
'platform-tools',
|
|
207
|
-
'emulator',
|
|
208
|
-
'platforms;android-34',
|
|
209
|
-
'system-images;android-34;default;x86_64',
|
|
210
|
-
]);
|
|
211
|
-
});
|
|
212
|
-
});
|