Skip to content

Commit 1392bf3

Browse files
committed
test(integration): model device-shell commands as discrete words
The provider-scenario fixtures matched a whole command line held in one argv element; the funnel now emits words, and safe paths arrive unquoted.
1 parent 0896fdc commit 1392bf3

6 files changed

Lines changed: 13 additions & 13 deletions

‎test/integration/provider-scenarios/android-lifecycle.test.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,9 +1246,8 @@ function assertAndroidInteractionContract(world: AndroidSettingsWorld): void {
12461246
3,
12471247
);
12481248
assert.equal(
1249-
adbCalls.filter((call) =>
1250-
arrayEqual(call, ['shell', 'settings put global sysui_demo_allowed 1']),
1251-
).length,
1249+
adbCalls.filter((call) => call.join(' ') === 'shell settings put global sysui_demo_allowed 1')
1250+
.length,
12521251
2,
12531252
);
12541253
}

‎test/integration/provider-scenarios/android-recording-provider-fixtures.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test('Android recording provider fixtures reject unmodeled executable commands',
66
const provider = createAndroidRecordingProvider({ calls: [] });
77

88
await assert.rejects(
9-
provider.exec(['shell', 'echo unmodeled-provider-command']),
9+
provider.exec(['shell', 'echo', 'unmodeled-provider-command']),
1010
/Unhandled Android recording provider command: shell echo unmodeled-provider-command/,
1111
);
1212
});

‎test/integration/provider-scenarios/android-recording-provider-fixtures.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ function respondToCommand(
8080
const pull = respondToPull(args, params, state);
8181
if (pull) return pull;
8282
if (args.join(' ') === 'shell getprop sys.boot_completed') return ok('1\n');
83-
const response = args[0] === 'shell' ? respondToShellCommand(args[1] ?? '', state) : undefined;
83+
const response =
84+
args[0] === 'shell' ? respondToShellCommand(args.slice(1).join(' '), state) : undefined;
8485
if (response) return response;
8586
throw new Error(`Unhandled Android recording provider command: ${args.join(' ')}`);
8687
}

‎test/integration/provider-scenarios/android-recording.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ test('Provider-backed integration Android record stop returns fenced completed n
134134
);
135135
});
136136

137-
const ANDROID_MARKER_REMOVAL = "shell rm -f '/sdcard/agent-device-recording-active.json'";
137+
const ANDROID_MARKER_REMOVAL = 'shell rm -f /sdcard/agent-device-recording-active.json';
138138

139139
test('Provider-backed integration Android record start retires completed evidence after the emulator reassigns its recorder pid', async () => {
140140
await withAndroidRecordingScenario(
@@ -177,7 +177,7 @@ test('Provider-backed integration Android record start retires completed evidenc
177177
});
178178
assert.equal(assertRpcOk<{ recording?: unknown }>(started).recording, 'started');
179179
assert.ok(
180-
calls.some((args) => args.join(' ') === `shell rm -f '${remotePath}'`),
180+
calls.some((args) => args.join(' ') === `shell rm -f ${remotePath}`),
181181
'retired the completed chunk artifact',
182182
);
183183
assert.ok(
@@ -225,7 +225,7 @@ test('Provider-backed integration Android record start retires evidence stranded
225225
});
226226
assert.equal(assertRpcOk<{ recording?: unknown }>(started).recording, 'started');
227227
assert.ok(
228-
calls.some((args) => args.join(' ') === `shell rm -f '${remotePath}'`),
228+
calls.some((args) => args.join(' ') === `shell rm -f ${remotePath}`),
229229
'retired the stranded chunk artifact',
230230
);
231231
assert.ok(
@@ -286,7 +286,7 @@ test('Provider-backed integration Android record start retains completed evidenc
286286
/another recorder is writing/,
287287
);
288288
assert.equal(
289-
calls.some((args) => args.join(' ') === `shell rm -f '${remotePath}'`),
289+
calls.some((args) => args.join(' ') === `shell rm -f ${remotePath}`),
290290
false,
291291
'the replacement recorder keeps its artifact',
292292
);
@@ -359,7 +359,7 @@ test('Provider-backed integration Android record start refuses completed evidenc
359359
false,
360360
);
361361
assert.equal(
362-
calls.some((args) => args.join(' ') === `shell rm -f '${remotePath}'`),
362+
calls.some((args) => args.join(' ') === `shell rm -f ${remotePath}`),
363363
false,
364364
);
365365
} finally {

‎test/integration/provider-scenarios/android-world.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ function androidDoctorProbeAdbResult(args: string[]): AndroidAdbResult | undefin
425425
}
426426

427427
function androidScreenshotDemoAdbResult(args: string[]): AndroidAdbResult | undefined {
428-
if (args.length === 2 && ANDROID_SCREENSHOT_DEMO_SHELL_COMMANDS.has(args[1] ?? '')) {
428+
if (args[0] === 'shell' && ANDROID_SCREENSHOT_DEMO_SHELL_COMMANDS.has(args.slice(1).join(' '))) {
429429
return { stdout: '', stderr: '', exitCode: 0 };
430430
}
431431
return undefined;

‎test/integration/provider-scenarios/managed-runtime-automation.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ test.skipIf(process.platform === 'win32')(
170170
).rejects.toThrow('valid PNG header');
171171
expect(sleep).toHaveBeenCalledOnce();
172172
const calls = native.calls();
173-
expect(calls.at(-1)?.at(-1)).toBe(
174-
'am broadcast -a com.android.systemui.demo -e command exit',
173+
expect(calls.at(-1)?.slice(4).join(' ')).toBe(
174+
'shell am broadcast -a com.android.systemui.demo -e command exit',
175175
);
176176
for (const args of calls)
177177
expect(args.slice(0, 4)).toEqual(['-P', '15037', '-s', 'emulator-15037']);

0 commit comments

Comments
 (0)