Skip to content

Commit

Permalink
Merge pull request #698 from tjozwik/master
Browse files Browse the repository at this point in the history
Replace instruments using xctrace
  • Loading branch information
alexblom authored Jan 6, 2022
2 parents 62d40c7 + bc915fa commit af9e79d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
27 changes: 14 additions & 13 deletions lib/targets/ios/tasks/list-devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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) => {
Expand Down
14 changes: 8 additions & 6 deletions node-tests/unit/targets/ios/tasks/list-devices-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit af9e79d

Please sign in to comment.