From 2573462cec776456304eca3d7db614b27b5e44e3 Mon Sep 17 00:00:00 2001 From: Lawrence Lomax Date: Fri, 28 Jan 2022 00:34:05 -0800 Subject: [PATCH] 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 --- .../flipper-server-core/src/devices/ios/IOSBridge.tsx | 11 ++++++++--- .../src/devices/ios/__tests__/IOSBridge.node.tsx | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx b/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx index 85d809636..69a28eaf0 100644 --- a/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx +++ b/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx @@ -36,18 +36,19 @@ export interface IOSBridge { class IDBBridge implements IOSBridge { constructor(private idbPath: string) {} + async navigate(serial: string, location: string): Promise { - 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 { 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 { diff --git a/desktop/flipper-server-core/src/devices/ios/__tests__/IOSBridge.node.tsx b/desktop/flipper-server-core/src/devices/ios/__tests__/IOSBridge.node.tsx index ad0cc8a66..fa386921c 100644 --- a/desktop/flipper-server-core/src/devices/ios/__tests__/IOSBridge.node.tsx +++ b/desktop/flipper-server-core/src/devices/ios/__tests__/IOSBridge.node.tsx @@ -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', ); });