@react-native-harness/platform-android 1.4.0-rc.1 → 1.4.1

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.
Files changed (78) hide show
  1. package/dist/adb.d.ts +3 -1
  2. package/dist/adb.d.ts.map +1 -1
  3. package/dist/adb.js +30 -21
  4. package/dist/app-session.d.ts +11 -2
  5. package/dist/app-session.d.ts.map +1 -1
  6. package/dist/app-session.js +17 -12
  7. package/dist/avd-config.d.ts +1 -0
  8. package/dist/avd-config.d.ts.map +1 -1
  9. package/dist/avd-config.js +11 -0
  10. package/dist/emulator-startup.d.ts +23 -0
  11. package/dist/emulator-startup.d.ts.map +1 -1
  12. package/dist/emulator-startup.js +58 -0
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -0
  16. package/dist/instance.d.ts.map +1 -1
  17. package/dist/instance.js +21 -15
  18. package/dist/runner.d.ts +2 -2
  19. package/dist/runner.d.ts.map +1 -1
  20. package/package.json +4 -4
  21. package/src/adb.ts +72 -65
  22. package/src/app-session.ts +28 -12
  23. package/src/avd-config.ts +17 -0
  24. package/src/emulator-startup.ts +74 -0
  25. package/src/index.ts +1 -0
  26. package/src/instance.ts +30 -16
  27. package/src/runner.ts +5 -9
  28. package/dist/__tests__/adb-id.test.d.ts +0 -2
  29. package/dist/__tests__/adb-id.test.d.ts.map +0 -1
  30. package/dist/__tests__/adb-id.test.js +0 -41
  31. package/dist/__tests__/adb.test.d.ts +0 -2
  32. package/dist/__tests__/adb.test.d.ts.map +0 -1
  33. package/dist/__tests__/adb.test.js +0 -552
  34. package/dist/__tests__/app-monitor.test.d.ts +0 -2
  35. package/dist/__tests__/app-monitor.test.d.ts.map +0 -1
  36. package/dist/__tests__/app-monitor.test.js +0 -257
  37. package/dist/__tests__/avd-config.test.d.ts +0 -2
  38. package/dist/__tests__/avd-config.test.d.ts.map +0 -1
  39. package/dist/__tests__/avd-config.test.js +0 -174
  40. package/dist/__tests__/ci-action.test.d.ts +0 -2
  41. package/dist/__tests__/ci-action.test.d.ts.map +0 -1
  42. package/dist/__tests__/ci-action.test.js +0 -46
  43. package/dist/__tests__/crash-diagnostics.test.d.ts +0 -2
  44. package/dist/__tests__/crash-diagnostics.test.d.ts.map +0 -1
  45. package/dist/__tests__/crash-diagnostics.test.js +0 -119
  46. package/dist/__tests__/crash-parser.test.d.ts +0 -2
  47. package/dist/__tests__/crash-parser.test.d.ts.map +0 -1
  48. package/dist/__tests__/crash-parser.test.js +0 -45
  49. package/dist/__tests__/crash-reporter.test.d.ts +0 -2
  50. package/dist/__tests__/crash-reporter.test.d.ts.map +0 -1
  51. package/dist/__tests__/crash-reporter.test.js +0 -150
  52. package/dist/__tests__/emulator-startup.test.d.ts +0 -2
  53. package/dist/__tests__/emulator-startup.test.d.ts.map +0 -1
  54. package/dist/__tests__/emulator-startup.test.js +0 -20
  55. package/dist/__tests__/environment.test.d.ts +0 -2
  56. package/dist/__tests__/environment.test.d.ts.map +0 -1
  57. package/dist/__tests__/environment.test.js +0 -117
  58. package/dist/__tests__/instance.test.d.ts +0 -2
  59. package/dist/__tests__/instance.test.d.ts.map +0 -1
  60. package/dist/__tests__/instance.test.js +0 -593
  61. package/dist/__tests__/shared-prefs.test.d.ts +0 -2
  62. package/dist/__tests__/shared-prefs.test.d.ts.map +0 -1
  63. package/dist/__tests__/shared-prefs.test.js +0 -87
  64. package/dist/__tests__/targets.test.d.ts +0 -2
  65. package/dist/__tests__/targets.test.d.ts.map +0 -1
  66. package/dist/__tests__/targets.test.js +0 -49
  67. package/dist/tsconfig.lib.tsbuildinfo +0 -1
  68. package/src/__tests__/adb-id.test.ts +0 -51
  69. package/src/__tests__/avd-config.test.ts +0 -206
  70. package/src/__tests__/ci-action.test.ts +0 -81
  71. package/src/__tests__/crash-diagnostics.test.ts +0 -144
  72. package/src/__tests__/crash-parser.test.ts +0 -52
  73. package/src/__tests__/crash-reporter.test.ts +0 -167
  74. package/src/__tests__/emulator-startup.test.ts +0 -35
  75. package/src/__tests__/instance.test.ts +0 -845
  76. package/src/__tests__/shared-prefs.test.ts +0 -144
  77. package/src/__tests__/targets.test.ts +0 -53
  78. package/tsconfig.tsbuildinfo +0 -1
@@ -1,257 +0,0 @@
1
- import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
- import { NativeCrashError } from '@react-native-harness/platforms';
3
- import { createAndroidAppMonitor, createAndroidLogEvent } from '../app-monitor.js';
4
- import * as adb from '../adb.js';
5
- const createStreamingSubprocess = (chunks) => ({
6
- nodeChildProcess: Promise.resolve({
7
- kill: vi.fn(),
8
- }),
9
- [Symbol.asyncIterator]: async function* () {
10
- for (const { line, delayMs = 0 } of chunks) {
11
- if (delayMs > 0) {
12
- await new Promise((resolve) => setTimeout(resolve, delayMs));
13
- }
14
- yield line;
15
- }
16
- },
17
- });
18
- describe('createAndroidLogEvent', () => {
19
- it('detects confirmation-grade am_crash events', () => {
20
- const event = createAndroidLogEvent('05-20 12:00:00.200 1000 1000 I am_crash: [0,1234,com.harnessplayground,123,java.lang.IllegalStateException,boom]', 'com.harnessplayground');
21
- expect(event).toMatchObject({
22
- type: 'crash_confirmed',
23
- crashDetails: {
24
- platform: 'android',
25
- kind: 'java-exception',
26
- confidence: 'high',
27
- source: 'logs',
28
- },
29
- });
30
- });
31
- });
32
- describe('createAndroidAppMonitor', () => {
33
- beforeEach(() => {
34
- vi.restoreAllMocks();
35
- vi.useFakeTimers();
36
- vi.spyOn(adb, 'getLogcatTimestamp').mockResolvedValue('05-20 12:00:00.000');
37
- });
38
- afterEach(() => {
39
- vi.useRealTimers();
40
- });
41
- it('starts logcat with crash, main, system, and events buffers', async () => {
42
- const startLogcat = vi
43
- .spyOn(adb, 'startLogcat')
44
- .mockReturnValue(createStreamingSubprocess([]));
45
- const monitor = createAndroidAppMonitor({
46
- adbId: 'emulator-5554',
47
- bundleId: 'com.harnessplayground',
48
- appUid: 10234,
49
- isAppRunning: async () => true,
50
- });
51
- await monitor.start();
52
- await monitor.stop();
53
- expect(startLogcat).toHaveBeenCalledWith('emulator-5554', [
54
- 'logcat',
55
- '-b',
56
- 'crash',
57
- '-b',
58
- 'main',
59
- '-b',
60
- 'system',
61
- '-b',
62
- 'events',
63
- '-v',
64
- 'threadtime',
65
- '-T',
66
- '05-20 12:00:00.000',
67
- ]);
68
- });
69
- it('reports app lifecycle and crash events through the reporter', async () => {
70
- vi.spyOn(adb, 'startLogcat').mockReturnValue(createStreamingSubprocess([
71
- {
72
- line: '05-20 12:00:00.000 1234 1234 I ActivityManager: Start proc 1234:com.harnessplayground/u0a123 for activity',
73
- },
74
- {
75
- line: '05-20 12:00:00.100 1234 1234 E AndroidRuntime: Process: com.harnessplayground, PID: 1234',
76
- },
77
- {
78
- line: '05-20 12:00:00.200 1000 1000 I am_crash: [0,1234,com.harnessplayground,123,java.lang.IllegalStateException,boom]',
79
- },
80
- ]));
81
- const eventReporter = vi.fn();
82
- const monitor = createAndroidAppMonitor({
83
- adbId: 'emulator-5554',
84
- bundleId: 'com.harnessplayground',
85
- appUid: 10234,
86
- isAppRunning: async () => true,
87
- eventReporter,
88
- });
89
- const crashWatch = monitor.watch('example.test.ts', 'startup');
90
- crashWatch.promise.catch(() => undefined);
91
- monitor.launchRequested({
92
- type: 'launch_requested',
93
- launchId: 'launch-1',
94
- at: Date.now(),
95
- reason: 'start',
96
- });
97
- await monitor.start();
98
- await vi.advanceTimersByTimeAsync(100);
99
- expect(eventReporter).toHaveBeenCalledWith(expect.objectContaining({
100
- type: 'app:started',
101
- appPlatform: 'android',
102
- targetIdentifier: 'emulator-5554',
103
- launchId: 'launch-1',
104
- }));
105
- expect(eventReporter).toHaveBeenCalledWith(expect.objectContaining({
106
- type: 'app:crash-suspected',
107
- appPlatform: 'android',
108
- processName: 'com.harnessplayground',
109
- }));
110
- expect(eventReporter).toHaveBeenCalledWith(expect.objectContaining({
111
- type: 'app:crash-confirmed',
112
- appPlatform: 'android',
113
- processName: 'com.harnessplayground',
114
- }));
115
- await monitor.stop();
116
- });
117
- it('rejects the watch for Java crashes when am_crash arrives even if the process still looks alive', async () => {
118
- vi.spyOn(adb, 'startLogcat').mockReturnValue(createStreamingSubprocess([
119
- {
120
- line: '05-20 12:00:00.000 1234 1234 I ActivityManager: Start proc 1234:com.harnessplayground/u0a123 for activity',
121
- },
122
- {
123
- line: '05-20 12:00:00.100 1234 1234 E AndroidRuntime: FATAL EXCEPTION: main',
124
- },
125
- {
126
- line: '05-20 12:00:00.101 1234 1234 E AndroidRuntime: Process: com.harnessplayground, PID: 1234',
127
- },
128
- {
129
- line: '05-20 12:00:00.102 1234 1234 E AndroidRuntime: java.lang.IllegalStateException: Intentional pre-RN startup crash',
130
- },
131
- {
132
- line: '05-20 12:00:00.103 1234 1234 E AndroidRuntime: at com.harnessplayground.MainActivity.onCreate(MainActivity.kt:42)',
133
- },
134
- {
135
- line: '05-20 12:00:00.200 1000 1000 I am_crash: [0,1234,com.harnessplayground,123,java.lang.IllegalStateException,Intentional pre-RN startup crash]',
136
- },
137
- ]));
138
- const monitor = createAndroidAppMonitor({
139
- adbId: 'emulator-5554',
140
- bundleId: 'com.harnessplayground',
141
- appUid: 10234,
142
- isAppRunning: async () => true,
143
- });
144
- const crashWatch = monitor.watch('example.test.ts', 'startup');
145
- crashWatch.promise.catch(() => undefined);
146
- await monitor.start();
147
- await vi.advanceTimersByTimeAsync(100);
148
- await expect(crashWatch.promise).rejects.toMatchObject({
149
- testFilePath: 'example.test.ts',
150
- details: {
151
- phase: 'startup',
152
- platform: 'android',
153
- kind: 'java-exception',
154
- confidence: 'high',
155
- processName: 'com.harnessplayground',
156
- pid: 1234,
157
- exceptionType: 'java.lang.IllegalStateException: Intentional pre-RN startup crash',
158
- },
159
- });
160
- await expect(crashWatch.promise).rejects.toBeInstanceOf(NativeCrashError);
161
- await monitor.stop();
162
- });
163
- it('rejects the watch when a suspected crash is followed by process exit', async () => {
164
- vi.spyOn(adb, 'startLogcat').mockReturnValue(createStreamingSubprocess([
165
- {
166
- line: '05-20 12:00:00.101 1234 1234 E AndroidRuntime: Process: com.harnessplayground, PID: 1234',
167
- },
168
- {
169
- line: '05-20 12:00:00.102 1234 1234 E AndroidRuntime: java.lang.IllegalStateException: Intentional delayed startup crash',
170
- },
171
- ]));
172
- const isAppRunning = vi
173
- .fn()
174
- .mockResolvedValueOnce(true)
175
- .mockResolvedValueOnce(false)
176
- .mockResolvedValue(false);
177
- const monitor = createAndroidAppMonitor({
178
- adbId: 'emulator-5554',
179
- bundleId: 'com.harnessplayground',
180
- appUid: 10234,
181
- isAppRunning,
182
- });
183
- const crashWatch = monitor.watch('example.test.ts', 'execution');
184
- crashWatch.promise.catch(() => undefined);
185
- await monitor.start();
186
- await vi.advanceTimersByTimeAsync(350);
187
- await expect(crashWatch.promise).rejects.toMatchObject({
188
- details: {
189
- phase: 'execution',
190
- platform: 'android',
191
- kind: 'java-exception',
192
- processName: 'com.harnessplayground',
193
- pid: 1234,
194
- },
195
- });
196
- await monitor.stop();
197
- });
198
- it('does not reject the watch when the process exits without a recent crash signal', async () => {
199
- vi.spyOn(adb, 'startLogcat').mockReturnValue(createStreamingSubprocess([]));
200
- const isAppRunning = vi
201
- .fn()
202
- .mockResolvedValueOnce(true)
203
- .mockResolvedValueOnce(false)
204
- .mockResolvedValue(false);
205
- const monitor = createAndroidAppMonitor({
206
- adbId: 'emulator-5554',
207
- bundleId: 'com.harnessplayground',
208
- appUid: 10234,
209
- isAppRunning,
210
- });
211
- const crashWatch = monitor.watch('example.test.ts', 'execution');
212
- let settled = false;
213
- const watchHandled = crashWatch.promise.catch(() => {
214
- settled = true;
215
- });
216
- await monitor.start();
217
- await vi.advanceTimersByTimeAsync(600);
218
- expect(settled).toBe(false);
219
- crashWatch.cancel();
220
- await monitor.stop();
221
- await watchHandled;
222
- });
223
- it('suppresses process-exit confirmation during a controlled stop window', async () => {
224
- vi.spyOn(adb, 'startLogcat').mockReturnValue(createStreamingSubprocess([
225
- {
226
- line: '05-20 12:00:00.101 1234 1234 E AndroidRuntime: Process: com.harnessplayground, PID: 1234',
227
- },
228
- ]));
229
- const isAppRunning = vi
230
- .fn()
231
- .mockResolvedValueOnce(true)
232
- .mockResolvedValueOnce(false)
233
- .mockResolvedValue(false);
234
- const monitor = createAndroidAppMonitor({
235
- adbId: 'emulator-5554',
236
- bundleId: 'com.harnessplayground',
237
- appUid: 10234,
238
- isAppRunning,
239
- });
240
- const crashWatch = monitor.watch('example.test.ts', 'execution');
241
- let settled = false;
242
- const watchHandled = crashWatch.promise.catch(() => {
243
- settled = true;
244
- });
245
- await monitor.start();
246
- monitor.stopRequested({
247
- type: 'stop_requested',
248
- at: Date.now(),
249
- reason: 'manual',
250
- });
251
- await vi.advanceTimersByTimeAsync(400);
252
- expect(settled).toBe(false);
253
- crashWatch.cancel();
254
- await monitor.stop();
255
- await watchHandled;
256
- });
257
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=avd-config.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"avd-config.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/avd-config.test.ts"],"names":[],"mappings":""}
@@ -1,174 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { getNormalizedAvdCacheConfig, isAvdCompatible, parseAvdConfig, resolveAvdCachingEnabled, } from '../avd-config.js';
3
- import { AndroidPlatformConfigSchema } from '../config.js';
4
- describe('AVD config helpers', () => {
5
- it('parses snapshot config from Android schema', () => {
6
- const config = AndroidPlatformConfigSchema.parse({
7
- name: 'android',
8
- bundleId: 'com.example.app',
9
- device: {
10
- type: 'emulator',
11
- name: 'Pixel_8_API_35',
12
- avd: {
13
- apiLevel: 35,
14
- profile: 'pixel_8',
15
- diskSize: '1G',
16
- heapSize: '512M',
17
- snapshot: {
18
- enabled: true,
19
- },
20
- },
21
- },
22
- });
23
- expect(config.device.type).toBe('emulator');
24
- if (config.device.type === 'emulator') {
25
- expect(config.device.avd?.snapshot?.enabled).toBe(true);
26
- }
27
- });
28
- it('lets HARNESS_AVD_CACHING override config before interactive gating', () => {
29
- expect(resolveAvdCachingEnabled({
30
- avd: {
31
- apiLevel: 35,
32
- profile: 'pixel_8',
33
- diskSize: '1G',
34
- heapSize: '1G',
35
- snapshot: { enabled: false },
36
- },
37
- isInteractive: false,
38
- env: {
39
- HARNESS_AVD_CACHING: 'true',
40
- },
41
- })).toBe(true);
42
- });
43
- it('disables caching for interactive sessions even when requested', () => {
44
- expect(resolveAvdCachingEnabled({
45
- avd: {
46
- apiLevel: 35,
47
- profile: 'pixel_8',
48
- diskSize: '1G',
49
- heapSize: '1G',
50
- snapshot: { enabled: true },
51
- },
52
- isInteractive: true,
53
- })).toBe(false);
54
- });
55
- it('parses config.ini and matches compatible AVD metadata', () => {
56
- const avdConfig = parseAvdConfig(`
57
- image.sysdir.1=system-images/android-35/default/x86_64/
58
- abi.type=x86_64
59
- hw.device.name=pixel_8
60
- disk.dataPartition.size=1G
61
- vm.heapSize=512M
62
- `);
63
- expect(isAvdCompatible({
64
- emulator: {
65
- type: 'emulator',
66
- name: 'Pixel_8_API_35',
67
- avd: {
68
- apiLevel: 35,
69
- profile: 'pixel_8',
70
- diskSize: '1G',
71
- heapSize: '512M',
72
- },
73
- },
74
- avdConfig,
75
- hostArch: 'x86_64',
76
- })).toEqual({ compatible: true });
77
- });
78
- it('accepts disk partition sizes rewritten to bytes', () => {
79
- const avdConfig = parseAvdConfig(`
80
- image.sysdir.1=system-images/android-35/default/x86_64/
81
- abi.type=x86_64
82
- hw.device.name=pixel_8
83
- disk.dataPartition.size=6442450944
84
- vm.heapSize=512M
85
- `);
86
- expect(isAvdCompatible({
87
- emulator: {
88
- type: 'emulator',
89
- name: 'Pixel_8_API_35',
90
- avd: {
91
- apiLevel: 35,
92
- profile: 'pixel_8',
93
- diskSize: '1G',
94
- heapSize: '512M',
95
- },
96
- },
97
- avdConfig,
98
- hostArch: 'x86_64',
99
- })).toEqual({ compatible: true });
100
- });
101
- it('rejects smaller disk partitions even when sizes are normalized', () => {
102
- const avdConfig = parseAvdConfig(`
103
- image.sysdir.1=system-images/android-35/default/x86_64/
104
- abi.type=x86_64
105
- hw.device.name=pixel_8
106
- disk.dataPartition.size=536870912
107
- vm.heapSize=512M
108
- `);
109
- expect(isAvdCompatible({
110
- emulator: {
111
- type: 'emulator',
112
- name: 'Pixel_8_API_35',
113
- avd: {
114
- apiLevel: 35,
115
- profile: 'pixel_8',
116
- diskSize: '1G',
117
- heapSize: '512M',
118
- },
119
- },
120
- avdConfig,
121
- hostArch: 'x86_64',
122
- })).toMatchObject({
123
- compatible: false,
124
- reason: 'Disk size mismatch: expected 1G, got 536870912.',
125
- });
126
- });
127
- it('reports incompatibility when AVD metadata differs', () => {
128
- const avdConfig = parseAvdConfig(`
129
- image.sysdir.1=system-images/android-34/default/x86_64/
130
- abi.type=x86_64
131
- hw.device.name=pixel_7
132
- disk.dataPartition.size=2G
133
- vm.heapSize=1G
134
- `);
135
- expect(isAvdCompatible({
136
- emulator: {
137
- type: 'emulator',
138
- name: 'Pixel_8_API_35',
139
- avd: {
140
- apiLevel: 35,
141
- profile: 'pixel_8',
142
- diskSize: '1G',
143
- heapSize: '512M',
144
- },
145
- },
146
- avdConfig,
147
- hostArch: 'x86_64',
148
- })).toMatchObject({
149
- compatible: false,
150
- });
151
- });
152
- it('normalizes AVD cache key input with name and host arch', () => {
153
- expect(getNormalizedAvdCacheConfig({
154
- emulator: {
155
- type: 'emulator',
156
- name: 'Pixel_8_API_35',
157
- avd: {
158
- apiLevel: 35,
159
- profile: ' Pixel_8 ',
160
- diskSize: '1G',
161
- heapSize: '512M',
162
- },
163
- },
164
- hostArch: 'arm64-v8a',
165
- })).toEqual({
166
- name: 'Pixel_8_API_35',
167
- apiLevel: 35,
168
- arch: 'arm64-v8a',
169
- profile: 'pixel_8',
170
- diskSize: '1g',
171
- heapSize: '512m',
172
- });
173
- });
174
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ci-action.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ci-action.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/ci-action.test.ts"],"names":[],"mappings":""}
@@ -1,46 +0,0 @@
1
- import { readFile } from 'node:fs/promises';
2
- import path from 'node:path';
3
- import { describe, expect, it } from 'vitest';
4
- const workspaceRoot = path.resolve(import.meta.dirname, '../../../..');
5
- describe('Android GitHub action config', () => {
6
- it('does not duplicate Android SDK verification in the action YAML', async () => {
7
- const [rootAction, packageAction] = await Promise.all([
8
- readFile(path.join(workspaceRoot, 'action.yml'), 'utf8'),
9
- readFile(path.join(workspaceRoot, 'packages/github-action/src/action.yml'), 'utf8'),
10
- ]);
11
- for (const actionYaml of [rootAction, packageAction]) {
12
- expect(actionYaml).not.toContain('Verify Android SDK packages');
13
- expect(actionYaml).toContain("steps.avd-cache.outputs.cache-hit != 'true'");
14
- }
15
- });
16
- it('removes the third-party emulator runner and maps cacheAvd to HARNESS_AVD_CACHING', async () => {
17
- const [rootAction, packageAction] = await Promise.all([
18
- readFile(path.join(workspaceRoot, 'action.yml'), 'utf8'),
19
- readFile(path.join(workspaceRoot, 'packages/github-action/src/action.yml'), 'utf8'),
20
- ]);
21
- for (const actionYaml of [rootAction, packageAction]) {
22
- expect(actionYaml).not.toContain('reactivecircus/android-emulator-runner');
23
- expect(actionYaml).toContain('HARNESS_AVD_CACHING: ${{ inputs.cacheAvd }}');
24
- expect(actionYaml).toContain('fromJson(steps.load-config.outputs.config).action.avdCachingEnabled');
25
- }
26
- });
27
- it('saves the AVD cache after the Harness run step', async () => {
28
- const [rootAction, packageAction] = await Promise.all([
29
- readFile(path.join(workspaceRoot, 'action.yml'), 'utf8'),
30
- readFile(path.join(workspaceRoot, 'packages/github-action/src/action.yml'), 'utf8'),
31
- ]);
32
- for (const actionYaml of [rootAction, packageAction]) {
33
- expect(actionYaml.indexOf('- name: Run E2E tests')).toBeLessThan(actionYaml.indexOf('- name: Save AVD cache'));
34
- }
35
- });
36
- it('uses a cache key that includes the emulator name', async () => {
37
- const [rootAction, packageAction] = await Promise.all([
38
- readFile(path.join(workspaceRoot, 'action.yml'), 'utf8'),
39
- readFile(path.join(workspaceRoot, 'packages/github-action/src/action.yml'), 'utf8'),
40
- ]);
41
- for (const actionYaml of [rootAction, packageAction]) {
42
- expect(actionYaml).toContain("AVD_NAME='${{ fromJson(steps.load-config.outputs.config).config.device.name }}'");
43
- expect(actionYaml).toContain('CACHE_KEY="avd-$AVD_NAME-$ARCH-$AVD_CONFIG_HASH"');
44
- }
45
- });
46
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=crash-diagnostics.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crash-diagnostics.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/crash-diagnostics.test.ts"],"names":[],"mappings":""}
@@ -1,119 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { collectDropboxArtifacts, filterExitInfo, getBestDropboxArtifact, parseDropboxOutput, } from '../crash-diagnostics.js';
3
- const javaCrashDropbox = `
4
- Drop box contents: 1 entries
5
- Max entries: 1000
6
- ========================================
7
- 2026-03-12 10:30:45.123 data_app_crash (text, 500 bytes)
8
- Process: com.harnessplayground
9
- PID: 7777
10
- Package: com.harnessplayground v1 (1.0)
11
- java.lang.RuntimeException: boom
12
- \tat com.harnessplayground.MainActivity.onCreate(MainActivity.kt:38)
13
- `;
14
- const nativeCrashDropbox = `
15
- ========================================
16
- 2026-03-12 10:31:10.456 data_app_native_crash (text, 800 bytes)
17
- Process: com.harnessplayground
18
- PID: 8888
19
- signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xdeadbeef
20
- Abort message: 'JNI DETECTED ERROR IN APPLICATION'
21
- backtrace:
22
- #00 pc 00001234 /data/app/lib/libapp.so
23
- `;
24
- const deviceJavaCrashDropbox = `
25
- Drop box contents: 8 entries
26
- Searching for: data_app_crash
27
-
28
- ========================================
29
- 2026-05-29 10:22:34 data_app_crash (text, 1328 bytes)
30
- SystemUptimeMs: 79467172
31
- Process: com.harnessplayground
32
- PID: 586
33
- Package: com.harnessplayground v1 (1.0)
34
- java.lang.RuntimeException: Intentional asynchronous Kotlin crash
35
- \tat com.harnessplayground.PlaygroundCrashModule.crashFromKotlinAsync(PlaygroundCrashModule.kt:44)
36
- `;
37
- describe('collectDropboxArtifacts', () => {
38
- it('matches harness playground crashes from merged per-tag dropbox output', async () => {
39
- const artifacts = await collectDropboxArtifacts({
40
- bundleId: 'com.harnessplayground',
41
- getDropboxOutput: async () => deviceJavaCrashDropbox,
42
- occurredAt: Date.now(),
43
- pid: 586,
44
- });
45
- expect(artifacts).toHaveLength(1);
46
- expect(artifacts[0]).toMatchObject({
47
- artifactType: 'dropbox-crash',
48
- pid: 586,
49
- processName: 'com.harnessplayground',
50
- });
51
- });
52
- it('ignores Dropbox entries older than the session start time', async () => {
53
- const artifacts = await collectDropboxArtifacts({
54
- bundleId: 'com.harnessplayground',
55
- getDropboxOutput: async () => deviceJavaCrashDropbox,
56
- minOccurredAt: Date.parse('2026-05-29T10:22:35.000Z'),
57
- occurredAt: Date.parse('2026-05-29T10:22:36.000Z'),
58
- });
59
- expect(artifacts).toHaveLength(0);
60
- });
61
- });
62
- describe('parseDropboxOutput', () => {
63
- it('parses java and native dropbox entries', () => {
64
- const entries = parseDropboxOutput(`${javaCrashDropbox}\n${nativeCrashDropbox}`);
65
- expect(entries).toHaveLength(2);
66
- expect(entries[0]).toMatchObject({
67
- tag: 'data_app_crash',
68
- pid: 7777,
69
- });
70
- expect(entries[1]).toMatchObject({
71
- tag: 'data_app_native_crash',
72
- pid: 8888,
73
- });
74
- expect(entries[1]?.content).toContain('SIGSEGV');
75
- });
76
- });
77
- describe('getBestDropboxArtifact', () => {
78
- it('prefers the highest-scored artifact', () => {
79
- const entries = parseDropboxOutput(`${javaCrashDropbox}\n${nativeCrashDropbox}`);
80
- const artifacts = entries.map((entry, index) => ({
81
- artifactType: entry.tag === 'data_app_native_crash'
82
- ? 'dropbox-native-crash'
83
- : 'dropbox-crash',
84
- dropboxTag: entry.tag,
85
- occurredAt: Date.now(),
86
- score: index === 0 ? 100 : 300,
87
- summary: entry.content,
88
- pid: entry.pid,
89
- processName: 'com.harnessplayground',
90
- }));
91
- expect(getBestDropboxArtifact(artifacts)?.dropboxTag).toBe('data_app_native_crash');
92
- });
93
- });
94
- describe('filterExitInfo', () => {
95
- it('returns matching exit-info records for the target package and pid', () => {
96
- const output = `
97
- ApplicationExitInfo #0:
98
- package=com.harnessplayground pid=7777 realUid=10123
99
- reason=4 (APP CRASH(NATIVE))
100
- timestamp=2026-03-12 10:31:10.456
101
- ApplicationExitInfo #1:
102
- package=com.other.app pid=9999 realUid=10199
103
- reason=10 (USER REQUESTED)
104
- `;
105
- const filtered = filterExitInfo({
106
- output,
107
- bundleId: 'com.harnessplayground',
108
- pid: 7777,
109
- });
110
- expect(filtered).toContain('com.harnessplayground pid=7777');
111
- expect(filtered).not.toContain('com.other.app');
112
- });
113
- it('returns null when no exit-info records exist', () => {
114
- expect(filterExitInfo({
115
- output: 'No exit info records for com.harnessplayground',
116
- bundleId: 'com.harnessplayground',
117
- })).toBeNull();
118
- });
119
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=crash-parser.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crash-parser.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/crash-parser.test.ts"],"names":[],"mappings":""}
@@ -1,45 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { androidCrashParser } from '../crash-parser.js';
3
- describe('androidCrashParser.parse', () => {
4
- it('parses an AndroidRuntime crash block into a crash details object', () => {
5
- expect(androidCrashParser.parse({
6
- contents: [
7
- '--------- beginning of crash',
8
- '03-12 11:35:09.000 1234 1234 E AndroidRuntime: Process: com.harnessplayground, PID: 1234',
9
- '03-12 11:35:09.001 1234 1234 E AndroidRuntime: java.lang.RuntimeException: boom',
10
- '03-12 11:35:09.002 1234 1234 E AndroidRuntime: at com.harnessplayground.MainActivity.onCreate(MainActivity.kt:42)',
11
- ].join('\n'),
12
- bundleId: 'com.harnessplayground',
13
- })).toEqual({
14
- source: 'logs',
15
- summary: [
16
- '--------- beginning of crash',
17
- '03-12 11:35:09.000 1234 1234 E AndroidRuntime: Process: com.harnessplayground, PID: 1234',
18
- '03-12 11:35:09.001 1234 1234 E AndroidRuntime: java.lang.RuntimeException: boom',
19
- '03-12 11:35:09.002 1234 1234 E AndroidRuntime: at com.harnessplayground.MainActivity.onCreate(MainActivity.kt:42)',
20
- ].join('\n'),
21
- signal: undefined,
22
- exceptionType: 'java.lang.RuntimeException: boom',
23
- processName: 'com.harnessplayground',
24
- pid: 1234,
25
- rawLines: [
26
- '--------- beginning of crash',
27
- '03-12 11:35:09.000 1234 1234 E AndroidRuntime: Process: com.harnessplayground, PID: 1234',
28
- '03-12 11:35:09.001 1234 1234 E AndroidRuntime: java.lang.RuntimeException: boom',
29
- '03-12 11:35:09.002 1234 1234 E AndroidRuntime: at com.harnessplayground.MainActivity.onCreate(MainActivity.kt:42)',
30
- ],
31
- stackTrace: [
32
- '03-12 11:35:09.002 1234 1234 E AndroidRuntime: at com.harnessplayground.MainActivity.onCreate(MainActivity.kt:42)',
33
- ],
34
- });
35
- });
36
- it('extracts fatal signals from a native crash block', () => {
37
- expect(androidCrashParser.parse({
38
- contents: '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)',
39
- bundleId: 'com.harnessplayground',
40
- })).toMatchObject({
41
- signal: 'SIGSEGV',
42
- processName: 'com.harnessplayground',
43
- });
44
- });
45
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=crash-reporter.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crash-reporter.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/crash-reporter.test.ts"],"names":[],"mappings":""}