-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Support parallel test execution #609
Changes from 12 commits
ae9c471
57ef873
c54109e
f5cd1b9
3c26649
bdf4eb8
fb96349
bf31acb
5c5d923
f18c34c
5004898
74849ae
4251edc
3bc6518
f839c3d
fa268cd
d5e7dab
06b917e
d3dcdfb
caa6fc8
a26e200
08abe3f
70cb9d5
4c72215
406740e
04b6243
dc7f70a
ddbdd06
7d12cd9
712e6de
9b0c50a
bc79553
a080a4b
7de97ac
00c40d3
3630f5a
646168c
73c27e1
f40373f
5dd5d27
56f208d
9a388b2
c48d49d
320113c
ffc4e20
688a31b
1f21ca4
0f9007f
52d0f86
5b11bc9
d088827
8eea0a7
cdd18b0
920faba
6931a0e
7547c99
0f64ffa
6267fe2
a4484dd
57a7b38
efb39a6
a3c9e1e
c9c4089
9b51f72
3a082bc
d76a43a
3f14a38
f1d8b48
c0393b0
86b1b8a
1084c20
87c357f
e6743da
0c73826
00cd14b
dd79249
d91bd9c
f7923af
c6c90f4
5830c96
c6357ae
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 |
---|---|---|
|
@@ -20,22 +20,27 @@ class AppleSimUtils { | |
} | ||
|
||
async findDeviceUDID(query) { | ||
const udids = await this.findDevicesUDID(query); | ||
return udids[0]; | ||
} | ||
|
||
async findDevicesUDID(query) { | ||
const statusLogs = { | ||
trying: `Searching for device matching ${query}...` | ||
}; | ||
let correctQuery = this._correctQueryWithOS(query); | ||
const response = await this._execAppleSimUtils({ args: `--list "${correctQuery}" --maxResults=1` }, statusLogs, 1); | ||
const response = await this._execAppleSimUtils({ args: `--list "${correctQuery}"` }, statusLogs, 1); | ||
const parsed = this._parseResponseFromAppleSimUtils(response); | ||
const udid = _.get(parsed, [0, 'udid']); | ||
if (!udid) { | ||
const udids = _.map(parsed, 'udid'); | ||
if (!udids || !udids.length || !udids[0]) { | ||
throw new Error(`Can't find a simulator to match with "${query}", run 'xcrun simctl list' to list your supported devices. | ||
It is advised to only state a device type, and not to state iOS version, e.g. "iPhone 7"`); | ||
} | ||
return udid; | ||
return udids; | ||
} | ||
|
||
async findDeviceByUDID(udid) { | ||
const response = await this._execAppleSimUtils({ args: `--list` }, undefined, 1); | ||
const response = await this._execAppleSimUtils({args: `--list --byId "${udid}"`}, undefined, 1); | ||
const parsed = this._parseResponseFromAppleSimUtils(response); | ||
const device = _.find(parsed, (device) => _.isEqual(device.udid, udid)); | ||
if (!device) { | ||
|
@@ -44,25 +49,27 @@ class AppleSimUtils { | |
return device; | ||
} | ||
|
||
async waitForDeviceState(udid, state) { | ||
let device; | ||
await retry({ retries: 10, interval: 1000 }, async () => { | ||
device = await this.findDeviceByUDID(udid); | ||
if (!_.isEqual(device.state, state)) { | ||
throw new Error(`device is in state '${device.state}'`); | ||
} | ||
}); | ||
return device; | ||
async boot(udid) { | ||
if (!await this.isBooted(udid)) { | ||
await this._bootDeviceByXcodeVersion(udid); | ||
} | ||
} | ||
|
||
async boot(udid) { | ||
async isBooted(udid) { | ||
const device = await this.findDeviceByUDID(udid); | ||
if (_.isEqual(device.state, 'Booted') || _.isEqual(device.state, 'Booting')) { | ||
return false; | ||
return (_.isEqual(device.state, 'Booted') || _.isEqual(device.state, 'Booting')); | ||
} | ||
|
||
async create(type) { | ||
const result = await this._execSimctl({ cmd: `list runtimes -j` }); | ||
const stdout = _.get(result, 'stdout'); | ||
const runtimes = JSON.parse(stdout); | ||
const newestRuntime = _.maxBy(runtimes.runtimes, r => Number(r.version)); | ||
if (newestRuntime) { | ||
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. What happens if there no 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. good catch. added handling |
||
console.log('Creating simulator', `create "${type}" "${type}" "${newestRuntime.identifier}"`) | ||
await this._execSimctl({cmd: `create "${type}" "${type}" "${newestRuntime.identifier}"`}); | ||
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. name should not be the type: const name = `detox_${type}_${count}`
await this._execSimctl({cmd: `create "${name}" "${type}" "${newestRuntime.identifier}"`}); Now, when you change the name, you won't be able to query |
||
return true; | ||
} | ||
await this.waitForDeviceState(udid, 'Shutdown'); | ||
await this._bootDeviceByXcodeVersion(udid); | ||
await this.waitForDeviceState(udid, 'Booted'); | ||
} | ||
|
||
async install(udid, absPath) { | ||
|
@@ -200,6 +207,7 @@ class AppleSimUtils { | |
} else { | ||
await this._bootDeviceMagically(udid); | ||
} | ||
await this._execSimctl({ cmd: `bootstatus ${udid}`, retries: 1 }); | ||
} | ||
|
||
async _bootDeviceMagically(udid) { | ||
|
@@ -245,4 +253,4 @@ class LogsInfo { | |
} | ||
} | ||
|
||
module.exports = AppleSimUtils; | ||
module.exports = AppleSimUtils; |
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.
Please use the same way to get configuration on all variables, either move all to
_.get
, usegetConfigFor
, or "vanilla"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.
done