Use provided idb path in iOSBridge idb execs

Summary:
We pass the `idbPath` to only the log listener function, when in reality it should be used by all of these functions that call out to idb.

This could result in some bizzare inconsistencies where some idb functions to fail as they are not using the supplied path

Reviewed By: passy

Differential Revision: D33818298

fbshipit-source-id: f0fb7f26579c646a0d5265364d539dfded711c2e
This commit is contained in:
Lawrence Lomax
2022-01-28 00:34:05 -08:00
committed by Facebook GitHub Bot
parent e2abe1c89a
commit 2573462cec
2 changed files with 11 additions and 6 deletions

View File

@@ -36,18 +36,19 @@ export interface IOSBridge {
class IDBBridge implements IOSBridge {
constructor(private idbPath: string) {}
async navigate(serial: string, location: string): Promise<void> {
exec(`idb open --udid ${serial} "${location}"`);
this._execIdb(`open --udid ${serial} "${location}"`);
}
recordVideo(serial: string, outputFile: string): child_process.ChildProcess {
console.log(`Starting screen record via idb to ${outputFile}.`);
return exec(`idb record-video --udid ${serial} ${outputFile}`);
return this._execIdb(`record-video --udid ${serial} ${outputFile}`);
}
async screenshot(serial: string): Promise<Buffer> {
const imagePath = makeTempScreenshotFilePath();
await exec(`idb screenshot --udid ${serial} ${imagePath}`);
await this._execIdb(`screenshot --udid ${serial} ${imagePath}`);
return readScreenshotIntoBuffer(imagePath);
}
@@ -65,6 +66,10 @@ class IDBBridge implements IOSBridge {
},
);
}
_execIdb(command: string): child_process.ChildProcess {
return exec(`${this.idbPath} ${command}`);
}
}
class SimctlBridge implements IOSBridge {

View File

@@ -128,7 +128,7 @@ test.unix('uses idb to take screenshots when available', async () => {
await expect(() => ib.screenshot('deadbeef')).rejects.toThrow();
expect((promisifyChildProcess.exec as any).mock.calls[0][0]).toMatch(
'idb screenshot --udid deadbeef ',
'/usr/local/bin/idb screenshot --udid deadbeef ',
);
});
@@ -148,7 +148,7 @@ test('uses idb to navigate when available', async () => {
await ib.navigate('deadbeef', 'fb://dummy');
expect(promisifyChildProcess.exec).toHaveBeenCalledWith(
'idb open --udid deadbeef "fb://dummy"',
'/usr/local/bin/idb open --udid deadbeef "fb://dummy"',
);
});
@@ -168,6 +168,6 @@ test('uses idb to record when available', async () => {
ib.recordVideo('deadbeef', '/tmo/video.mp4');
expect(promisifyChildProcess.exec).toHaveBeenCalledWith(
'idb record-video --udid deadbeef /tmo/video.mp4',
'/usr/local/bin/idb record-video --udid deadbeef /tmo/video.mp4',
);
});