Skip to content

Commit

Permalink
Merge pull request #57 from macacajs/bug-fix
Browse files Browse the repository at this point in the history
bug fix for real devices
  • Loading branch information
SamuelZhaoY committed Aug 13, 2017
2 parents 88d5bf4 + c9cbd6b commit 6fca254
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions lib/macaca-ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ IOS.prototype.startDevice = function *(caps) {
yield this.startSimulator();
}

if (this.xctest) {
this.xctest.stop();
}
yield this.device.uninstall(XCTestWD.XCTestWD.BUNDLE_ID);

const desCaps = _.validateAndFilterDesiredCaps(_.merge({
bundleId: this.bundleId
}, this.args));
Expand All @@ -150,17 +155,13 @@ IOS.prototype.startDevice = function *(caps) {
delete desCaps.app;
}

logger.debug(JSON.stringify(desCaps, null, '\t'));

this.initXCTest();

if (!this.isSafari) {
this.proxy = this.xctest;
}

logger.debug(JSON.stringify(desCaps, null, '\t'));

this.xctest.stop();
yield this.device.uninstall(XCTestWD.XCTestWD.BUNDLE_ID);

const that = this;
yield _.retry(co.wrap(function *() {
logger.debug('Trying to start xctestwd server...');
Expand Down Expand Up @@ -243,12 +244,20 @@ IOS.prototype.startRealDevice = function *() {

if (isInstalled) {
logger.debug(`App "${bundleId}" is already installed.`);
logger.debug(`Adopting app reuse strategy: ${reuse}.`);
switch (reuse) {
case 0:
case 1:
if (app) {
yield this.device.uninstall(bundleId);
logger.debug(`Uninstall app "${bundleId}".`);
try {
yield this.device.uninstall(bundleId);
logger.debug(`Uninstall app "${bundleId}".`);
yield this.device.install(app);
logger.debug(`Install app '${bundleId}' successfully.`);
} catch (err) {
logger.debug(err.message);
throw new errors.UnknownError(`Failed to install app '${bundleId}', please install the app manually.`);
}
}
break;
case 2:
Expand Down

0 comments on commit 6fca254

Please sign in to comment.