From bc915fab3d5c765eb869e9ab357a77f257ebff9a Mon Sep 17 00:00:00 2001 From: Tomasz Jozwik Date: Tue, 7 Dec 2021 01:17:31 +0100 Subject: [PATCH] Replace instruments using xctrace --- lib/targets/ios/tasks/list-devices.js | 27 ++++++++++--------- .../targets/ios/tasks/list-devices-test.js | 14 +++++----- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/lib/targets/ios/tasks/list-devices.js b/lib/targets/ios/tasks/list-devices.js index 07f5880a..ff919470 100644 --- a/lib/targets/ios/tasks/list-devices.js +++ b/lib/targets/ios/tasks/list-devices.js @@ -6,25 +6,26 @@ const deserializeDevices = function(stdout) { if (stdout === undefined) { return devices; } let list = stdout.split('\n'); - //First line is always 'known devices' + + //First line is always '== Devices ==' list.shift(); - list.forEach((item) => { - if (item.trim() === '') { return; } - let split = item.split(/[(]|[[]/g); + for (let item of list) { + let line = item.trim(); - if (split[split.length - 1].includes('Simulator')) { - return; - } + if (line === '') { continue; } + if (line === '== Simulators ==') { break; } + + let split = item.split(/[(]|[[]/g); let deviceName = split[0].trim(); - //Cant exclude from instruments + //Cant exclude from device list if (deviceName.includes('MacBook')) { - return; + continue; } let apiVersion = split[1].replace(')', '').trim(); - let uuid = split[split.length - 1].replace(']', '').trim(); + let uuid = split[split.length - 1].replace(')', '').trim(); let device = new Device({ platform: 'ios', @@ -35,15 +36,15 @@ const deserializeDevices = function(stdout) { }); devices.push(device); - }); + } return devices; }; module.exports = function() { let list = [ - '/usr/bin/instruments', - ['-s','devices'] + '/usr/bin/xctrace', + ['list', 'devices'] ]; return spawn(...list).then((output) => { diff --git a/node-tests/unit/targets/ios/tasks/list-devices-test.js b/node-tests/unit/targets/ios/tasks/list-devices-test.js index 31a81466..01a4423a 100644 --- a/node-tests/unit/targets/ios/tasks/list-devices-test.js +++ b/node-tests/unit/targets/ios/tasks/list-devices-test.js @@ -3,15 +3,17 @@ const expect = require('../../../../helpers/expect'); const Device = require('../../../../../lib/objects/device'); const Promise = require('rsvp').Promise; -const spawnArgs = ['/usr/bin/instruments', ['-s', 'devices']]; +const spawnArgs = ['/usr/bin/xctrace', ['list', 'devices']]; //yes - isleofcode.com is my actual device name //(turn on the hotspot and be branding all conference long!) -const deviceList = `Known Devices -Alex’s MacBook Pro (2) [uuid] -isleofcode.com (12.1.2) [uuid] -Apple TV (12.1) [uuid] (Simulator) -iPhone X (12.1) [uuid] (Simulator)` +const deviceList = `== Devices == +MacBook Pro (Tomasz) (uuid) +isleofcode.com (12.1.2) (uuid) + +== Simulators == +Apple TV Simulator (12.1) (uuid) +iPhone X Simulator (12.1) (uuid)` describe('iOS List Emulator Task', () => { let listDevices;