simctl 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +23 -130
- data/lib/simctl/command.rb +2 -0
- data/lib/simctl/command/create.rb +0 -20
- data/lib/simctl/command/reset.rb +26 -0
- data/lib/simctl/device.rb +13 -4
- data/lib/simctl/version.rb +1 -1
- data/test/simctl/command/crud_test.rb +13 -15
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd28b66b86819a39b9b4c3255d8a43da5a396aa4
|
4
|
+
data.tar.gz: 6701555feb0245c7829b3d19164cf6104aca4091
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c97dd6ebdc1afef17375c02f98aab4c139767607295a1423ae725e0c461e815020002afe7c5cbfc9f7219457db71acf8d684920451b6f4d04a51b915eea335a6
|
7
|
+
data.tar.gz: 92c109f84dbcae8beb6af57a1561d56f2c239458d80d42581ae906b13e2aaa497c9e37e04c34b1c76376c8ea0981e5851eab3bd5d0743fc3f8a50951730a7f25
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,151 +2,44 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/plu/simctl.svg?branch=master)](https://travis-ci.org/plu/simctl) [![Gem Version](https://badge.fury.io/rb/simctl.svg)](https://badge.fury.io/rb/simctl) [![Coverage Status](https://coveralls.io/repos/plu/simctl/badge.svg?branch=master&service=github)](https://coveralls.io/github/plu/simctl?branch=master)
|
4
4
|
|
5
|
-
Ruby interface to xcrun simctl.
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Via [bundler](http://getbundler.com)
|
10
|
-
|
11
|
-
```sh
|
12
|
-
# in your Gemfile
|
13
|
-
gem 'simctl'
|
14
|
-
```
|
5
|
+
Ruby interface to xcrun simctl. Manage your iOS Simulators directly from a ruby script. This can be helpful for testing on different Simulators, see example project here: [plu/parallel_ios_tests](https://github.com/plu/parallel_ios_tests)
|
15
6
|
|
16
7
|
## Usage
|
17
8
|
|
18
|
-
### boot_device
|
19
|
-
|
20
|
-
```ruby
|
21
|
-
device = SimCtl.device(name: 'my iphone 5', state: 'Shutdown')
|
22
|
-
SimCtl.boot_device(device)
|
23
|
-
|
24
|
-
# or:
|
25
|
-
|
26
|
-
SimCtl.device(name: 'my iphone 5', state: 'Shutdown').boot!
|
27
|
-
```
|
28
|
-
|
29
|
-
### create_device
|
30
|
-
|
31
|
-
```ruby
|
32
|
-
SimCtl.create_device 'my iphone 5', SimCtl.devicetype(name: 'iPhone 5'), SimCtl.runtime(name: 'iOS 9.2')
|
33
|
-
|
34
|
-
#<SimCtl::Device:0x007fbce48afd88 @state="Creating", @availability="(available)", @name="my iphone 5", @udid="6F7269E0-6375-4B72-8451-F2728BF6DA82", @os="iOS 9.2">
|
35
|
-
```
|
36
|
-
|
37
|
-
### delete_device
|
38
|
-
|
39
|
-
```ruby
|
40
|
-
device = SimCtl.device(name: 'my iphone 5', state: 'Booted')
|
41
|
-
SimCtl.delete_device(device)
|
42
|
-
|
43
|
-
# or:
|
44
|
-
|
45
|
-
SimCtl.device(name: 'my iphone 5', state: 'Booted').delete!
|
46
|
-
```
|
47
|
-
|
48
|
-
### devicetype
|
49
|
-
|
50
|
-
```ruby
|
51
|
-
SimCtl.devicetype(name: 'iPhone 5')
|
52
|
-
|
53
|
-
#<SimCtl::DeviceType:0x007fd90dd9f2e0 @name="iPhone 5", @identifier="com.apple.CoreSimulator.SimDeviceType.iPhone-5">
|
54
|
-
```
|
55
|
-
|
56
|
-
### device
|
57
|
-
|
58
9
|
```ruby
|
59
|
-
|
10
|
+
require 'simctl'
|
60
11
|
|
61
|
-
|
62
|
-
|
12
|
+
# Select the iOS 9.2 runtime
|
13
|
+
runtime = SimCtl.runtime(name: 'iOS 9.2')
|
63
14
|
|
64
|
-
|
15
|
+
# Select the iPhone 5 device type
|
16
|
+
devicetype = SimCtl.devicetype(name: 'iPhone 5')
|
65
17
|
|
66
|
-
|
67
|
-
device = SimCtl.
|
68
|
-
SimCtl.erase_device(device)
|
18
|
+
# Create a new device
|
19
|
+
device = SimCtl.create_device 'Unit Tests @ iPhone 5 9.2', devicetype, runtime
|
69
20
|
|
70
|
-
#
|
21
|
+
# Launch a new Simulator.app instance
|
22
|
+
device.launch!
|
71
23
|
|
72
|
-
|
73
|
-
|
24
|
+
# Wait for the device to be booted
|
25
|
+
device.wait! {|d| d.state == :booted}
|
74
26
|
|
75
|
-
|
27
|
+
# Kill the Simulator.app instance again
|
28
|
+
device.kill!
|
76
29
|
|
77
|
-
|
78
|
-
|
79
|
-
puts device.inspect
|
80
|
-
end
|
30
|
+
# Wait until it did shutdown
|
31
|
+
device.wait! {|d| d.state == :shutdown}
|
81
32
|
|
82
|
-
|
83
|
-
|
33
|
+
# Delete the device
|
34
|
+
device.delete!
|
84
35
|
```
|
85
36
|
|
86
|
-
|
37
|
+
## License (MIT)
|
87
38
|
|
88
|
-
|
89
|
-
SimCtl.list_devicetypes.each do |devicetype|
|
90
|
-
puts devicetype.inspect
|
91
|
-
end
|
92
|
-
|
93
|
-
#<SimCtl::DeviceType:0x007fbce48f5270 @name="iPhone 4s", @identifier="com.apple.CoreSimulator.SimDeviceType.iPhone-4s">
|
94
|
-
#<SimCtl::DeviceType:0x007fbce48f51f8 @name="iPhone 5", @identifier="com.apple.CoreSimulator.SimDeviceType.iPhone-5">
|
95
|
-
#<SimCtl::DeviceType:0x007fbce48f5180 @name="iPhone 5s", @identifier="com.apple.CoreSimulator.SimDeviceType.iPhone-5s">
|
96
|
-
#<SimCtl::DeviceType:0x007fbce48f5108 @name="iPhone 6", @identifier="com.apple.CoreSimulator.SimDeviceType.iPhone-6">
|
97
|
-
#<SimCtl::DeviceType:0x007fbce48f5090 @name="iPhone 6 Plus", @identifier="com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus">
|
98
|
-
#<SimCtl::DeviceType:0x007fbce48f5018 @name="iPhone 6s", @identifier="com.apple.CoreSimulator.SimDeviceType.iPhone-6s">
|
99
|
-
#<SimCtl::DeviceType:0x007fbce48f4fa0 @name="iPhone 6s Plus", @identifier="com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus">
|
100
|
-
#<SimCtl::DeviceType:0x007fbce48f4f28 @name="iPad 2", @identifier="com.apple.CoreSimulator.SimDeviceType.iPad-2">
|
101
|
-
#<SimCtl::DeviceType:0x007fbce48f4eb0 @name="iPad Retina", @identifier="com.apple.CoreSimulator.SimDeviceType.iPad-Retina">
|
102
|
-
#<SimCtl::DeviceType:0x007fbce48f4e38 @name="iPad Air", @identifier="com.apple.CoreSimulator.SimDeviceType.iPad-Air">
|
103
|
-
#<SimCtl::DeviceType:0x007fbce48f4dc0 @name="iPad Air 2", @identifier="com.apple.CoreSimulator.SimDeviceType.iPad-Air-2">
|
104
|
-
#<SimCtl::DeviceType:0x007fbce48f4d48 @name="iPad Pro", @identifier="com.apple.CoreSimulator.SimDeviceType.iPad-Pro">
|
105
|
-
#<SimCtl::DeviceType:0x007fbce48f4cd0 @name="Apple TV 1080p", @identifier="com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p">
|
106
|
-
#<SimCtl::DeviceType:0x007fbce48f4c58 @name="Apple Watch - 38mm", @identifier="com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm">
|
107
|
-
#<SimCtl::DeviceType:0x007fbce48f4be0 @name="Apple Watch - 42mm", @identifier="com.apple.CoreSimulator.SimDeviceType.Apple-Watch-42mm">
|
108
|
-
```
|
109
|
-
|
110
|
-
### list_runtimes
|
111
|
-
|
112
|
-
```ruby
|
113
|
-
SimCtl.list_runtimes.each do |runtime|
|
114
|
-
puts runtime.inspect
|
115
|
-
end
|
116
|
-
|
117
|
-
#<SimCtl::Runtime:0x007fbce48cd6d0 @buildversion="12B411", @availability="(available)", @name="iOS 8.1", @identifier="com.apple.CoreSimulator.SimRuntime.iOS-8-1", @version="8.1">
|
118
|
-
#<SimCtl::Runtime:0x007fbce48cd5e0 @buildversion="12D508", @availability="(available)", @name="iOS 8.2", @identifier="com.apple.CoreSimulator.SimRuntime.iOS-8-2", @version="8.2">
|
119
|
-
#<SimCtl::Runtime:0x007fbce48cd4f0 @buildversion="12F70", @availability="(available)", @name="iOS 8.3", @identifier="com.apple.CoreSimulator.SimRuntime.iOS-8-3", @version="8.3">
|
120
|
-
#<SimCtl::Runtime:0x007fbce48cd400 @buildversion="12H141", @availability="(available)", @name="iOS 8.4", @identifier="com.apple.CoreSimulator.SimRuntime.iOS-8-4", @version="8.4">
|
121
|
-
#<SimCtl::Runtime:0x007fbce48cd310 @buildversion="13A344", @availability="(available)", @name="iOS 9.0", @identifier="com.apple.CoreSimulator.SimRuntime.iOS-9-0", @version="9.0">
|
122
|
-
#<SimCtl::Runtime:0x007fbce48cd220 @buildversion="13C75", @availability="(available)", @name="iOS 9.2", @identifier="com.apple.CoreSimulator.SimRuntime.iOS-9-2", @version="9.2">
|
123
|
-
#<SimCtl::Runtime:0x007fbce48cd130 @buildversion="13U78", @availability="(available)", @name="tvOS 9.1", @identifier="com.apple.CoreSimulator.SimRuntime.tvOS-9-1", @version="9.1">
|
124
|
-
#<SimCtl::Runtime:0x007fbce48cd040 @buildversion="13S660", @availability="(available)", @name="watchOS 2.1", @identifier="com.apple.CoreSimulator.SimRuntime.watchOS-2-1", @version="2.1">
|
125
|
-
```
|
39
|
+
Copyright (C) 2016 Johannes Plunien
|
126
40
|
|
127
|
-
|
41
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
128
42
|
|
129
|
-
|
130
|
-
SimCtl.reset_device 'my iphone 5', SimCtl.devicetype(name: 'iPhone 5'), SimCtl.runtime(name: 'iOS 9.2')
|
43
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
131
44
|
|
132
|
-
|
133
|
-
```
|
134
|
-
|
135
|
-
### runtime
|
136
|
-
|
137
|
-
```ruby
|
138
|
-
SimCtl.runtime(name: 'iOS 9.2')
|
139
|
-
|
140
|
-
#<SimCtl::Runtime:0x007fd90dd2da28 @buildversion="13C75", @availability="(available)", @name="iOS 9.2", @identifier="com.apple.CoreSimulator.SimRuntime.iOS-9-2", @version="9.2">
|
141
|
-
```
|
142
|
-
|
143
|
-
### shutdown_device
|
144
|
-
|
145
|
-
```ruby
|
146
|
-
device = SimCtl.device(name: 'my iphone 5', state: 'Booted')
|
147
|
-
SimCtl.shutdown_device(device)
|
148
|
-
|
149
|
-
# or:
|
150
|
-
|
151
|
-
SimCtl.device(name: 'my iphone 5', state: 'Booted').shutdown!
|
152
|
-
```
|
45
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/simctl/command.rb
CHANGED
@@ -5,6 +5,7 @@ require 'simctl/command/erase'
|
|
5
5
|
require 'simctl/command/kill'
|
6
6
|
require 'simctl/command/launch'
|
7
7
|
require 'simctl/command/list'
|
8
|
+
require 'simctl/command/reset'
|
8
9
|
require 'simctl/command/shutdown'
|
9
10
|
require 'simctl/executor'
|
10
11
|
|
@@ -17,6 +18,7 @@ module SimCtl
|
|
17
18
|
include SimCtl::Command::Kill
|
18
19
|
include SimCtl::Command::Launch
|
19
20
|
include SimCtl::Command::List
|
21
|
+
include SimCtl::Command::Reset
|
20
22
|
include SimCtl::Command::Shutdown
|
21
23
|
end
|
22
24
|
end
|
@@ -14,26 +14,6 @@ module SimCtl
|
|
14
14
|
device(udid: identifier)
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
18
|
-
# Shutdown, delete and create a device
|
19
|
-
#
|
20
|
-
# @param name [String] name of the new device
|
21
|
-
# @param device_type [SimCtl::DeviceType] device type of the new device
|
22
|
-
# @param runtime [SimCtl::Runtime] runtime of the new device
|
23
|
-
# @return [SimCtl::Device] the device that was created
|
24
|
-
# @yield [exception] an exception that might happen during shutdown/delete of the old device
|
25
|
-
def reset_device(name, device_type, runtime)
|
26
|
-
begin
|
27
|
-
list_devices.where(name: name, os: runtime.name).each do |device|
|
28
|
-
device.kill!
|
29
|
-
device.shutdown! if device.state != 'Shutdown'
|
30
|
-
device.delete!
|
31
|
-
end
|
32
|
-
rescue Exception => exception
|
33
|
-
yield exception if block_given?
|
34
|
-
end
|
35
|
-
create_device name, device_type, runtime
|
36
|
-
end
|
37
17
|
end
|
38
18
|
end
|
39
19
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module SimCtl
|
2
|
+
class Command
|
3
|
+
module Reset
|
4
|
+
# Kill, shutdown, delete and create a device
|
5
|
+
#
|
6
|
+
# @param name [String] name of the new device
|
7
|
+
# @param device_type [SimCtl::DeviceType] device type of the new device
|
8
|
+
# @param runtime [SimCtl::Runtime] runtime of the new device
|
9
|
+
# @return [SimCtl::Device] the device that was created
|
10
|
+
# @yield [exception] an exception that might happen during shutdown/delete of the old device
|
11
|
+
def reset_device(name, device_type, runtime)
|
12
|
+
begin
|
13
|
+
list_devices.where(name: name, os: runtime.name).each do |device|
|
14
|
+
device.kill!
|
15
|
+
device.shutdown! if device.state != :shutdown
|
16
|
+
device.wait! {|d| d.state == :shutdown}
|
17
|
+
device.delete!
|
18
|
+
end
|
19
|
+
rescue Exception => exception
|
20
|
+
yield exception if block_given?
|
21
|
+
end
|
22
|
+
create_device name, device_type, runtime
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/simctl/device.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
require 'simctl/object'
|
2
|
+
require 'timeout'
|
2
3
|
|
3
4
|
module SimCtl
|
4
5
|
class Device < Object
|
5
6
|
attr_reader :availability, :name, :os, :state, :udid
|
6
7
|
|
7
|
-
# Boot the device
|
8
8
|
def boot!
|
9
9
|
SimCtl.boot_device(self)
|
10
10
|
end
|
11
11
|
|
12
|
-
# Delete the device
|
13
12
|
def delete!
|
14
13
|
SimCtl.delete_device(self)
|
15
14
|
end
|
16
15
|
|
17
|
-
# Erase the device
|
18
16
|
def erase!
|
19
17
|
SimCtl.erase_device(self)
|
20
18
|
end
|
@@ -27,9 +25,20 @@ module SimCtl
|
|
27
25
|
SimCtl.launch_device(self)
|
28
26
|
end
|
29
27
|
|
30
|
-
# Shutdown the device
|
31
28
|
def shutdown!
|
32
29
|
SimCtl.shutdown_device(self)
|
33
30
|
end
|
31
|
+
|
32
|
+
def state
|
33
|
+
@state.downcase.to_sym
|
34
|
+
end
|
35
|
+
|
36
|
+
def wait!(timeout=15)
|
37
|
+
Timeout::timeout(timeout) do
|
38
|
+
loop do
|
39
|
+
break if yield SimCtl.device(udid: udid)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
34
43
|
end
|
35
44
|
end
|
data/lib/simctl/version.rb
CHANGED
@@ -1,31 +1,22 @@
|
|
1
1
|
require 'securerandom'
|
2
2
|
require 'test_helper'
|
3
|
-
require 'timeout'
|
4
3
|
|
5
4
|
class SimCtl::Command::CRUDTest < Minitest::Test
|
6
5
|
def setup
|
7
6
|
@devicetype = SimCtl.list_devicetypes.select {|devicetype| devicetype.name =~ %r[iPhone]}.first
|
8
7
|
@runtime = SimCtl.list_runtimes.select {|runtime| runtime.name =~ %r[iOS.*9]}.first
|
9
8
|
@device = SimCtl.create_device SecureRandom.hex, @devicetype, @runtime
|
10
|
-
|
9
|
+
@device.wait! {|device| device.state != :creating}
|
11
10
|
end
|
12
11
|
|
13
12
|
def teardown
|
14
13
|
device = SimCtl.device(udid: @device.udid)
|
15
14
|
return unless device
|
16
|
-
device.
|
15
|
+
device.kill!
|
16
|
+
device.shutdown! if device.state != :shutdown
|
17
17
|
device.delete!
|
18
18
|
end
|
19
19
|
|
20
|
-
def wait_for
|
21
|
-
Timeout::timeout(30) do
|
22
|
-
loop do
|
23
|
-
device = SimCtl.device(udid: @device.udid)
|
24
|
-
break if yield device
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
20
|
should 'find the device created in setup' do
|
30
21
|
device = SimCtl.device(udid: @device.udid)
|
31
22
|
assert_kind_of SimCtl::Device, device
|
@@ -36,6 +27,13 @@ class SimCtl::Command::CRUDTest < Minitest::Test
|
|
36
27
|
assert device.udid != nil
|
37
28
|
end
|
38
29
|
|
30
|
+
should 'launch and kill the device created in setup' do
|
31
|
+
device = SimCtl.device(udid: @device.udid)
|
32
|
+
assert device.launch!
|
33
|
+
device.wait!{|device| device.state == :booted}
|
34
|
+
assert device.kill!
|
35
|
+
end
|
36
|
+
|
39
37
|
should 'erase the device created in setup' do
|
40
38
|
device = SimCtl.device(udid: @device.udid)
|
41
39
|
SimCtl.erase_device device
|
@@ -44,9 +42,9 @@ class SimCtl::Command::CRUDTest < Minitest::Test
|
|
44
42
|
should 'boot/shutdown the device created in setup' do
|
45
43
|
device = SimCtl.device(udid: @device.udid)
|
46
44
|
SimCtl.boot_device device
|
47
|
-
|
45
|
+
device.wait! {|device| device.state == :booted}
|
48
46
|
SimCtl.shutdown_device device
|
49
|
-
|
47
|
+
device.wait! {|device| device.state == :shutdown}
|
50
48
|
end
|
51
49
|
|
52
50
|
should 'delete the device created in setup' do
|
@@ -60,6 +58,6 @@ class SimCtl::Command::CRUDTest < Minitest::Test
|
|
60
58
|
assert_kind_of SimCtl::Device, device
|
61
59
|
assert_nil SimCtl.device(udid: @device.udid)
|
62
60
|
@device = device # teardown cleanup
|
63
|
-
|
61
|
+
device.wait! {|device| device.state != :creating}
|
64
62
|
end
|
65
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simctl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johannes Plunien
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/simctl/command/kill.rb
|
91
91
|
- lib/simctl/command/launch.rb
|
92
92
|
- lib/simctl/command/list.rb
|
93
|
+
- lib/simctl/command/reset.rb
|
93
94
|
- lib/simctl/command/shutdown.rb
|
94
95
|
- lib/simctl/device.rb
|
95
96
|
- lib/simctl/device_type.rb
|