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:
committed by
Facebook GitHub Bot
parent
cac09d14aa
commit
9e8ec02bf7
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {queryTargetsWithoutXcodeDependency} from '../iOSContainerUtility';
|
import {queryTargetsWithoutXcodeDependency} from '../iOSContainerUtility';
|
||||||
import {idbDescribeTargets} from '../iOSContainerUtility';
|
|
||||||
|
|
||||||
test('uses idbcompanion command for queryTargetsWithoutXcodeDependency', async () => {
|
test('uses idbcompanion command for queryTargetsWithoutXcodeDependency', async () => {
|
||||||
const mockedExec = jest.fn((_) =>
|
const mockedExec = jest.fn((_) =>
|
||||||
@@ -42,31 +41,3 @@ test('do not call idbcompanion if the path does not exist', async () => {
|
|||||||
);
|
);
|
||||||
expect(mockedExec).toHaveBeenCalledTimes(0);
|
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",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
`);
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -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(
|
export async function idbListTargets(
|
||||||
idbPath: string,
|
idbPath: string,
|
||||||
safeExecFunc: (
|
safeExecFunc: (
|
||||||
@@ -184,10 +166,7 @@ async function targets(
|
|||||||
// when installed, use it.
|
// when installed, use it.
|
||||||
// TODO: Move idb availability check up.
|
// TODO: Move idb availability check up.
|
||||||
if (await memoize(isAvailable)(idbPath)) {
|
if (await memoize(isAvailable)(idbPath)) {
|
||||||
// We want to get both `idb describe` and `idb list-targets` outputs
|
return await idbListTargets(idbPath);
|
||||||
// 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));
|
|
||||||
} else {
|
} else {
|
||||||
await killOrphanedInstrumentsProcesses();
|
await killOrphanedInstrumentsProcesses();
|
||||||
return safeExec('instruments -s devices')
|
return safeExec('instruments -s devices')
|
||||||
|
|||||||
Reference in New Issue
Block a user