-
-
Notifications
You must be signed in to change notification settings - Fork 424
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
fix: uninstall wda with '.xctrunner' suffix for real device #1052
Changes from 14 commits
56595d4
d2c5fb1
e16a362
6588ae0
5b18d3e
9ab2c3e
9186503
7c5e41d
24078cd
6c8523b
0142675
c7beac7
ba1c56d
fa771f9
df279bd
cbd3745
91c31b2
74c0314
cc866f9
7e8150e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import B from 'bluebird'; | ||
import path from 'path'; | ||
import { getSimulator } from 'appium-ios-simulator'; | ||
import { createDevice, getDevices, terminate, shutdown } from 'node-simctl'; | ||
|
@@ -214,5 +215,15 @@ async function shutdownOtherSimulators (currentDevice) { | |
} | ||
} | ||
|
||
async function getInstalledBundleIds (device, candidateBundleIds) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we actually change this in appium-ios-simulator that we get a similar api like what the real devices have? This would help us get rid of having a list of potential bundle ids There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can either add this call to ios simulator or we can attach it to the object dynamically right in this module:
Then There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm talking about something else. I'm talking about making this method similar as the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since this is an oneliner then we could simply move it to |
||
const bundleIds = []; | ||
mykola-mokhnach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await B.filter(candidateBundleIds, async (bundleId) => { | ||
if (await device.isAppInstalled(bundleId)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not really - the filter condition should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and the result could be returned immediately. There is no need for the intermediate accumulator |
||
bundleIds.push(bundleId); | ||
} | ||
}); | ||
return bundleIds; | ||
} | ||
|
||
export { createSim, getExistingSim, runSimulatorReset, installToSimulator, | ||
shutdownSimulator, shutdownOtherSimulators }; | ||
shutdownSimulator, shutdownOtherSimulators, getInstalledBundleIds }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import B from 'bluebird'; | ||
import _ from 'lodash'; | ||
import path from 'path'; | ||
import url from 'url'; | ||
|
@@ -12,11 +13,14 @@ import iProxy from './iproxy'; | |
import { exec } from 'teen_process'; | ||
import AsyncLock from 'async-lock'; | ||
import { BOOTSTRAP_PATH, WDA_BUNDLE_ID, WDA_RUNNER_BUNDLE_ID, checkForDependencies } from 'appium-webdriveragent'; | ||
|
||
import { getBundleIdsByBundleName } from '../real-device-management'; | ||
import { getInstalledBundleIds } from '../simulator-management'; | ||
|
||
const WDA_LAUNCH_TIMEOUT = 60 * 1000; | ||
const WDA_AGENT_PORT = 8100; | ||
const WDA_BASE_URL = 'http://localhost'; | ||
const WDA_CF_BUNDLE_NAME = 'WebDriverAgentRunner-Runner'; | ||
const WDA_BUNDLE_ID_XCODE11 = 'com.facebook.WebDriverAgentRunner.xctrunner'; // FIXME: Move to appium-webdriveragent | ||
|
||
const SHARED_RESOURCES_GUARD = new AsyncLock(); | ||
|
||
|
@@ -32,7 +36,7 @@ class WebDriverAgent { | |
this.platformName = args.platformName; | ||
this.iosSdkVersion = args.iosSdkVersion; | ||
this.host = args.host; | ||
this.realDevice = !!args.realDevice; | ||
this.isRealDevice = !!args.realDevice; | ||
|
||
this.setWDAPaths(args.bootstrapPath, args.agentPath); | ||
|
||
|
@@ -53,13 +57,15 @@ class WebDriverAgent { | |
this.usePrebuiltWDA = args.usePrebuiltWDA; | ||
this.derivedDataPath = args.derivedDataPath; | ||
|
||
this.updatedWDABundleId = args.updatedWDABundleId; | ||
|
||
this.xcodebuild = new XcodeBuild(this.xcodeVersion, this.device, { | ||
platformVersion: this.platformVersion, | ||
platformName: this.platformName, | ||
iosSdkVersion: this.iosSdkVersion, | ||
agentPath: this.agentPath, | ||
bootstrapPath: this.bootstrapPath, | ||
realDevice: this.realDevice, | ||
realDevice: this.isRealDevice, | ||
showXcodeLog: args.showXcodeLog, | ||
xcodeConfigFile: args.xcodeConfigFile, | ||
xcodeOrgId: args.xcodeOrgId, | ||
|
@@ -68,9 +74,9 @@ class WebDriverAgent { | |
keychainPassword: args.keychainPassword, | ||
useSimpleBuildTest: args.useSimpleBuildTest, | ||
usePrebuiltWDA: args.usePrebuiltWDA, | ||
updatedWDABundleId: args.updatedWDABundleId, | ||
updatedWDABundleId: this.updatedWDABundleId, | ||
launchTimeout: args.wdaLaunchTimeout || WDA_LAUNCH_TIMEOUT, | ||
wdaRemotePort: this.realDevice ? WDA_AGENT_PORT : (this.wdaLocalPort || WDA_AGENT_PORT), | ||
wdaRemotePort: this.isRealDevice ? WDA_AGENT_PORT : (this.wdaLocalPort || WDA_AGENT_PORT), | ||
useXctestrunFile: this.useXctestrunFile, | ||
derivedDataPath: args.derivedDataPath, | ||
mjpegServerPort: args.mjpegServerPort, | ||
|
@@ -155,10 +161,23 @@ class WebDriverAgent { | |
} | ||
} | ||
|
||
/** | ||
* Uninstall WDAs from the test device. | ||
* Over Xcode 11, multiple WDA can be in the device since Xcode 11 generates different WDA. | ||
* Appium does not expect multiple WDAs are running on a device. | ||
*/ | ||
async uninstall () { | ||
log.debug(`Removing WDA application from device`); | ||
try { | ||
await this.device.removeApp(WDA_BUNDLE_ID); | ||
const bundleIds = await this.getInstalledWDBundleId(); | ||
if (_.isEmpty(bundleIds)) { | ||
log.debug('No WDAs on the device.'); | ||
return; | ||
} | ||
|
||
log.debug(`Uninstalling WDAs: '${bundleIds}'`); | ||
await B.each(bundleIds, async (bundleId) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here I would revert back to |
||
await this.device.removeApp(bundleId); | ||
}); | ||
} catch (e) { | ||
log.warn(`WebDriverAgent uninstall failed. Perhaps, it is already uninstalled? Original error: ${JSON.stringify(e)}`); | ||
} | ||
|
@@ -221,7 +240,7 @@ class WebDriverAgent { | |
}); | ||
} | ||
// We need to provide WDA local port, because it might be occupied with | ||
await resetXCTestProcesses(this.device.udid, !this.realDevice); | ||
await resetXCTestProcesses(this.device.udid, !this.isRealDevice); | ||
|
||
await this.ensureConnection(); | ||
|
||
|
@@ -278,7 +297,7 @@ class WebDriverAgent { | |
} | ||
|
||
async ensureConnection () { | ||
if (!this.realDevice || this.webDriverAgentUrl || this.iproxy) { | ||
if (!this.isRealDevice || this.webDriverAgentUrl || this.iproxy) { | ||
return; | ||
} | ||
if (isLocalHost(this.wdaBaseUrl)) { | ||
|
@@ -349,7 +368,7 @@ class WebDriverAgent { | |
* | ||
* @param {string} updatedWDABundleId BundleId you'd like to use | ||
*/ | ||
async setupCaching (updatedWDABundleId) { | ||
async setupCaching () { | ||
const status = await this.getStatus(); | ||
if (!status || !status.build) { | ||
log.debug('WDA is currently not running. There is nothing to cache'); | ||
|
@@ -360,11 +379,13 @@ class WebDriverAgent { | |
productBundleIdentifier, | ||
upgradedAt, | ||
} = status.build; | ||
if (util.hasValue(productBundleIdentifier) && util.hasValue(updatedWDABundleId) && updatedWDABundleId !== productBundleIdentifier) { | ||
// for real device | ||
if (util.hasValue(productBundleIdentifier) && util.hasValue(this.updatedWDABundleId) && this.updatedWDABundleId !== productBundleIdentifier) { | ||
log.info(`Will uninstall running WDA since it has different bundle id. The actual value is '${productBundleIdentifier}'.`); | ||
return await this.uninstall(); | ||
} | ||
if (util.hasValue(productBundleIdentifier) && !util.hasValue(updatedWDABundleId) && WDA_RUNNER_BUNDLE_ID !== productBundleIdentifier) { | ||
// for simulator | ||
if (util.hasValue(productBundleIdentifier) && !util.hasValue(this.updatedWDABundleId) && WDA_RUNNER_BUNDLE_ID !== productBundleIdentifier) { | ||
log.info(`Will uninstall running WDA since its bundle id is not equal to the default value ${WDA_RUNNER_BUNDLE_ID}`); | ||
return await this.uninstall(); | ||
} | ||
|
@@ -385,10 +406,26 @@ class WebDriverAgent { | |
this.webDriverAgentUrl = this.url.href; | ||
} | ||
|
||
/** | ||
* Quit and uninstall running WDA. | ||
*/ | ||
async quitAndUninstall () { | ||
await this.quit(); | ||
await this.uninstall(); | ||
} | ||
|
||
/** | ||
* Get WDA bundleIds installed in the target device. | ||
* Over Xcode 11, multiple WDA can be in a device since Xcode 11 | ||
* set their bundleIds as 'xxxxxx.xctrunner'. | ||
* | ||
* @returns {Array<string>} A list of User level apps' bundle ids. | ||
*/ | ||
async getInstalledWDBundleId () { | ||
return this.isRealDevice | ||
? await getBundleIdsByBundleName(this.device, WDA_CF_BUNDLE_NAME) | ||
: await getInstalledBundleIds(this.device, [WDA_BUNDLE_ID, WDA_BUNDLE_ID_XCODE11]); | ||
} | ||
} | ||
|
||
export default WebDriverAgent; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, lets move this method into IOSDeploy class