Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switched to booting the device directly (related to https://github.co… #184

Merged
merged 3 commits into from
Jul 4, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions detox/src/devices/Fbsimctl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const fs = require('fs');
const _ = require('lodash');
const log = require('npmlog');
const exec = require('../utils/exec');
const retry = require('../utils/retry');

// FBSimulatorControl command line docs
// https://github.com/facebook/FBSimulatorControl/issues/250
Expand Down Expand Up @@ -39,13 +40,37 @@ class Fbsimctl {
}

async boot(udid) {
const statusLogs = {
trying: `trying to boot device...`,
successful: `device ${udid} booted`
};
let initialState;
await retry({retries: 10, interval: 1000}, async() => {
const initialStateCmdResult = await this._execFbsimctlCommand({args: `${udid} list`}, undefined, 1);
initialState = _.get(initialStateCmdResult, 'stdout', '') === '' ? undefined : _.get(JSON.parse(_.get(initialStateCmdResult, 'stdout')), 'subject.state');
if(initialState === 'Shutting Down') {
log.info(`Waiting until the device ${udid} shuts down`);
throw `The device is in 'Shutting Down' state`;
}
});

if(initialState === 'Booted') {
log.info(`The device ${udid} is already booted`);
return;
}

if(initialState === 'Booting') {
log.info(`The device ${udid} is already booting`);
} else {
const launchBin = "bash -c '`xcode-select -p`/Applications/Simulator.app/Contents/MacOS/Simulator " +
"--args -CurrentDeviceUDID EB9B3A90-621B-4F6E-815C-1E5C17ED5ABE -ConnectHardwareKeyboard 0 " +
"-DeviceSetPath /Users/sergeyi/Library/Developer/CoreSimulator/Devices > /dev/null 2>&1 < /dev/null &'";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like you forgot to use a relative path

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and CurrentDeviceUDID

await exec.execWithRetriesAndLogs(launchBin, undefined, {
trying: `launching the simulator ${udid}...`,
successful: 'the device launch initiated'
}, 1);
}

const options = {args: `--state=shutdown --state=shutting-down ${udid} boot`};
return await this._execFbsimctlCommand(options, statusLogs);
return await this._execFbsimctlCommand({args: `--state booted ${udid} list`}, {
trying: `waiting for the device to boot...`,
successful: `device ${udid} booted`
});
}

async install(udid, absPath) {
Expand Down