Skip to content

Commit 1c7f3cd

Browse files
committed
fix(android): keep adb failure details on a parsed helper result with a nonzero exit
- dispatch-disclosure fixture: the mixed-refusal row now feeds `error: device offline\nKilled` through the real tap executor and expects unknown. Mutation: ignoring non-trailer lines in classifyHostRefusal (trailer.every -> true) makes the row report no. - touch-helper: the parsed-final/nonzero error goes through attachAdbFailureHint before disclosure. Test: a nonzero exit with `adb: device offline` keeps adbFailure, hint, retriable. Mutation: dropping attachAdbFailureHint from that branch fails the new test (verified). - adb-failure.test: the device_offline hint is a literal string instead of a value derived from the classifier. Mutation: editing the hint text in adb-failure.ts fails the assertion.
1 parent df909a1 commit 1c7f3cd

5 files changed

Lines changed: 37 additions & 8 deletions

File tree

‎contracts/fixtures/dispatch-disclosure.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@
346346
{
347347
"id": "android-adb.input-tap.refusal-text-beside-other-output",
348348
"producer": "android-adb",
349-
"trigger": "adb input tap failed with refusal-like stderr that is not the whole output (server restart line, then a device-side exit); only a refusal that is the entire output makes it no",
349+
"trigger": "adb input tap failed with a recognized refusal line followed by a non-trailer line (error: device offline, then Killed); only a refusal that is the entire output makes it no",
350350
"dispatched": "unknown"
351351
},
352352
{

‎packages/platform-android/src/__tests__/dispatch-disclosure.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ const DRIVERS: Record<string, { drive: () => Promise<unknown>; dispatchedSteps?:
203203
'android-adb.input-tap.refusal-text-beside-other-output': {
204204
drive: () =>
205205
tapWithAdbAnswer({
206-
exitCode: 137,
207-
stderr: "adb server version (40) doesn't match this client (41); killing...\nKilled",
206+
exitCode: 1,
207+
stderr: 'error: device offline\nKilled',
208208
}),
209209
},
210210
...Object.fromEntries(

‎packages/platform-android/src/__tests__/touch-helper.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,33 @@ test('unparseable output with a non-zero exit code reports a helper failure', as
376376
);
377377
});
378378

379+
test('a parsed helper result with a non-zero exit keeps the recognized adb failure details', async () => {
380+
const device = makeIsolatedDevice();
381+
await assert.rejects(
382+
withAndroidAdbProvider(
383+
{
384+
exec: currentVersionAdb(async () => ({
385+
exitCode: 1,
386+
stdout: [resultRecord({ ok: 'true', kind: 'swipe' }), 'INSTRUMENTATION_CODE: 0'].join(
387+
'\n',
388+
),
389+
stderr: 'adb: device offline',
390+
})),
391+
},
392+
{ serial: device.id },
393+
async () => await executeAndroidTouchHelperPlan(device, lowerAndroidTouchPlan(flingPlan())),
394+
),
395+
(error: unknown) => {
396+
assert.ok(error instanceof AppError);
397+
assert.equal(error.message, 'Android automation helper failed');
398+
assert.equal(error.details?.adbFailure, 'device_offline');
399+
assert.equal(typeof error.details?.hint, 'string');
400+
assert.equal(error.details?.retriable, true);
401+
return true;
402+
},
403+
);
404+
});
405+
379406
test('one-shot viewport instruments the snapshot-helper runner and validates bounds', async () => {
380407
const device = makeIsolatedDevice();
381408
let capturedArgs: readonly string[] | undefined;

‎packages/platform-android/src/adb-failure.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test('only the bare host adb device-offline refusal is classified as a host refu
2727
for (const stderr of ['adb: device offline\n', "error: device 'emulator-5554' offline"]) {
2828
assert.deepEqual(classifyAndroidAdbFailure(stderr), {
2929
reason: 'device_offline',
30-
hint: classifyAndroidAdbFailure('device offline')?.hint,
30+
hint: 'The device is connected but offline — wait for it to finish booting or run adb reconnect, then retry.',
3131
retriable: true,
3232
hostRefusal: true,
3333
});

‎packages/platform-android/src/touch-helper.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,12 @@ async function runOneShotTouchHelper<Result>(options: {
311311
if (result.exitCode !== 0) {
312312
throw discloseHelperTouchDispatch(
313313
options.action,
314-
new AppError(
315-
'COMMAND_FAILED',
316-
'Android automation helper failed',
317-
execFailureDetails(result, { helper: finalRecord }),
314+
attachAdbFailureHint(
315+
new AppError(
316+
'COMMAND_FAILED',
317+
'Android automation helper failed',
318+
execFailureDetails(result, { helper: finalRecord }),
319+
),
318320
),
319321
);
320322
}

0 commit comments

Comments
 (0)