From 9e8ec02bf722aa06de61a7845a80c1d60e86c671 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Thu, 26 Aug 2021 09:09:16 -0700 Subject: [PATCH] Remove idb describe querying Summary: This can cause a lot of spam in the logs (locally, doesn't log as errors) and we've now found that `idb connect` is a better way to support remote devices. See https://docs.google.com/document/d/1Ih5eCyisMIzgKSJV6xichUBJMiioSJltcJCh6LCLecg/edit#bookmark=id.zhwvc6wk2bbz for more information. Reviewed By: fabiomassimo Differential Revision: D30546664 fbshipit-source-id: 066ea7f2eef6f82d8d6ce70db44313472b637768 --- .../__tests__/iOSContainerUtility.node.tsx | 29 ------------------- .../devices/ios/iOSContainerUtility.tsx | 23 +-------------- 2 files changed, 1 insertion(+), 51 deletions(-) diff --git a/desktop/app/src/server/devices/ios/__tests__/iOSContainerUtility.node.tsx b/desktop/app/src/server/devices/ios/__tests__/iOSContainerUtility.node.tsx index 88b0fedde..1f38b7c30 100644 --- a/desktop/app/src/server/devices/ios/__tests__/iOSContainerUtility.node.tsx +++ b/desktop/app/src/server/devices/ios/__tests__/iOSContainerUtility.node.tsx @@ -8,7 +8,6 @@ */ import {queryTargetsWithoutXcodeDependency} from '../iOSContainerUtility'; -import {idbDescribeTargets} from '../iOSContainerUtility'; test('uses idbcompanion command for queryTargetsWithoutXcodeDependency', async () => { const mockedExec = jest.fn((_) => @@ -42,31 +41,3 @@ test('do not call idbcompanion if the path does not exist', async () => { ); expect(mockedExec).toHaveBeenCalledTimes(0); }); - -test('parses idb describe output', async () => { - const mockedExec = jest.fn((_) => - Promise.resolve({ - stdout: `{"udid": "deafbeed", "type": "simulator", "name": "name", "state": "Booted"} - {"udid": "f4ceb00c", "type": "physical", "name": "ponzicoin-miner", "state": "Booted"} - {"udid": "ded", "type": "physical", "name": "350ppm", "state": "Shutdown"} - `, - stderr: '', - }), - ); - const targets = await idbDescribeTargets('/usr/bin/idb', mockedExec); - expect(mockedExec).toBeCalledWith('/usr/bin/idb describe --json'); - expect(targets).toMatchInlineSnapshot(` - Array [ - Object { - "name": "name", - "type": "emulator", - "udid": "deafbeed", - }, - Object { - "name": "ponzicoin-miner", - "type": "physical", - "udid": "f4ceb00c", - }, - ] - `); -}); diff --git a/desktop/app/src/server/devices/ios/iOSContainerUtility.tsx b/desktop/app/src/server/devices/ios/iOSContainerUtility.tsx index fdc9d831f..3839a90a6 100644 --- a/desktop/app/src/server/devices/ios/iOSContainerUtility.tsx +++ b/desktop/app/src/server/devices/ios/iOSContainerUtility.tsx @@ -119,24 +119,6 @@ function parseIdbTargets(lines: string): Array { })); } -export async function idbDescribeTargets( - idbPath: string, - safeExecFunc: ( - command: string, - ) => Promise<{stdout: string; stderr: string} | Output> = safeExec, -): Promise> { - return safeExecFunc(`${idbPath} describe --json`) - .then(({stdout}) => parseIdbTargets(stdout!.toString())) - .catch((e: Error) => { - // idb describe doesn't work when multiple devices are available. - // That's expected behavior and we can skip the log. - if (!e.message.includes('multiple companions')) { - console.warn('Failed to query idb for targets:', e); - } - return []; - }); -} - export async function idbListTargets( idbPath: string, safeExecFunc: ( @@ -184,10 +166,7 @@ async function targets( // when installed, use it. // TODO: Move idb availability check up. if (await memoize(isAvailable)(idbPath)) { - // We want to get both `idb describe` and `idb list-targets` outputs - // as in certain setups devices may not show up on one but the other. - const targets = await idbDescribeTargets(idbPath); - return targets.concat(await idbListTargets(idbPath)); + return await idbListTargets(idbPath); } else { await killOrphanedInstrumentsProcesses(); return safeExec('instruments -s devices')