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
This commit is contained in:
Pascal Hartig
2021-08-26 09:09:16 -07:00
committed by Facebook GitHub Bot
parent cac09d14aa
commit 9e8ec02bf7
2 changed files with 1 additions and 51 deletions

View File

@@ -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",
},
]
`);
});

View File

@@ -119,24 +119,6 @@ function parseIdbTargets(lines: string): Array<DeviceTarget> {
}));
}
export async function idbDescribeTargets(
idbPath: string,
safeExecFunc: (
command: string,
) => Promise<{stdout: string; stderr: string} | Output> = safeExec,
): Promise<Array<DeviceTarget>> {
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')