Skip to content

Commit

Permalink
fix: handle wda launch being called multiple times (appium#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
umutuzgur authored Jul 2, 2019
1 parent f771e95 commit efeb9cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
9 changes: 1 addition & 8 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,9 @@ async function killAppUsingPattern (pgrepPattern) {
*
* @param {string} udid - The device UDID.
* @param {boolean} isSimulator - Equals to true if the current device is a Simulator
* @param {object} opts - Additional options mapping. Possible keys are:
* - {string|number} wdaLocalPort: The number of local port WDA is listening on.
*/
async function resetXCTestProcesses (udid, isSimulator, opts = {}) {
async function resetXCTestProcesses (udid, isSimulator) {
const processPatterns = [`xcodebuild.*${udid}`];
if (opts.wdaLocalPort) {
processPatterns.push(`iproxy ${opts.wdaLocalPort}`);
} else if (!isSimulator) {
processPatterns.push(`iproxy.*${udid}`);
}
if (isSimulator) {
processPatterns.push(`${udid}.*XCTRunner`);
}
Expand Down
5 changes: 4 additions & 1 deletion lib/wda/webdriveragent.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class WebDriverAgent {
});
}
// We need to provide WDA local port, because it might be occupied with
await resetXCTestProcesses(this.device.udid, !this.realDevice, {wdaLocalPort: this.url.port});
await resetXCTestProcesses(this.device.udid, !this.realDevice);

if (this.realDevice) {
if (isLocalHost(this.wdaBaseUrl)) {
Expand All @@ -241,6 +241,9 @@ class WebDriverAgent {
}

createIProxy () {
if (this.iproxy) {
return this.iproxy;
}
const iproxy = new iProxy(this.device.udid, this.url.port, WDA_AGENT_PORT);
try {
iproxy.start();
Expand Down

0 comments on commit efeb9cf

Please sign in to comment.