luffa 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/luffa/ios/ideviceinstaller.rb +112 -69
- data/lib/luffa/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 788f5398ad79dc3be466b7bfacebfebc7ed41845
|
4
|
+
data.tar.gz: f01d3aa2b4ab91cf745021cebf9bc2349262b2e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f11db976ea3fab737dd67457db0290a1673c85fc561e9d46bbae27331d542e3e3ee7f9744e53fde34c64f1a136c39f2a223fa963c16f79c9dc3a7d6f1175fb9e
|
7
|
+
data.tar.gz: b45ed6f7363b9a1d95e789e0508293160da1733bbc846d0f5972d4dbeaca3672beac1f840d1f8584d2c95eca0037b7604f912f24cc8e82a7ef9fdc3e035d921a
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'retriable'
|
2
|
+
require 'open3'
|
2
3
|
|
3
4
|
module Luffa
|
4
5
|
class IDeviceInstaller
|
@@ -11,106 +12,148 @@ module Luffa
|
|
11
12
|
@bundle_id = bundle_id
|
12
13
|
end
|
13
14
|
|
14
|
-
def bin_path
|
15
|
-
@bin_path ||= `which ideviceinstaller`.chomp!
|
16
|
-
end
|
17
|
-
|
18
15
|
def ideviceinstaller_available?
|
19
16
|
path = bin_path
|
20
17
|
path and File.exist? bin_path
|
21
18
|
end
|
22
19
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
20
|
+
def idevice_id_available?
|
21
|
+
path = idevice_id_bin_path
|
22
|
+
path and File.exist? path
|
23
|
+
end
|
24
|
+
|
25
|
+
def install(udid, options={})
|
26
|
+
unless options.is_a? Hash
|
27
|
+
Luffa.log_warn 'API CHANGE: install now takes an options hash as 2nd arg'
|
28
|
+
Luffa.log_warn "API CHANGE: ignoring '#{options}'; will use defaults"
|
29
|
+
merged_options = DEFAULT_OPTIONS
|
30
|
+
else
|
31
|
+
merged_options = DEFAULT_OPTIONS.merge(options)
|
32
|
+
end
|
33
|
+
|
34
|
+
uninstall(udid, merged_options)
|
35
|
+
install_internal(udid, merged_options)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Can only be called when RunLoop is available.
|
39
|
+
def physical_devices_for_testing(xcode_tools)
|
40
|
+
# Xcode 6 + iOS 8 - devices on the same network, whether development or
|
41
|
+
# not, appear when calling $ xcrun instruments -s devices. For the
|
42
|
+
# purposes of testing, we will only try to connect to devices that are
|
43
|
+
# connected via USB.
|
44
|
+
#
|
45
|
+
# Also idevice_id, which ideviceinstaller relies on, will sometimes report
|
46
|
+
# devices 2x which will cause ideviceinstaller to fail.
|
47
|
+
@physical_devices_for_testing ||= lambda {
|
48
|
+
devices = xcode_tools.instruments(:devices)
|
49
|
+
if idevice_id_available?
|
50
|
+
white_list = `#{idevice_id_bin_path} -l`.strip.split("\n")
|
51
|
+
devices.select do | device |
|
52
|
+
white_list.include?(device.udid) && white_list.count(device.udid) == 1
|
36
53
|
end
|
37
54
|
else
|
38
|
-
|
39
|
-
|
40
|
-
|
55
|
+
devices
|
56
|
+
end
|
57
|
+
}.call
|
41
58
|
end
|
42
59
|
|
43
|
-
|
44
|
-
cmd = "#{bin_path} --udid #{udid} --list-apps"
|
45
|
-
Luffa.log_unix_cmd(cmd) if Luffa::Environment.debug?
|
60
|
+
private
|
46
61
|
|
47
|
-
|
48
|
-
err = stderr.read.strip
|
49
|
-
Luffa.log_fail(err) if err && err != ''
|
62
|
+
DEFAULT_OPTIONS = { :timeout => 10.0, :tries => 2 }
|
50
63
|
|
51
|
-
|
52
|
-
|
53
|
-
end
|
64
|
+
def bin_path
|
65
|
+
@bin_path ||= `which ideviceinstaller`.chomp!
|
54
66
|
end
|
55
67
|
|
56
|
-
def
|
57
|
-
|
68
|
+
def run_command_with_args(args, options={})
|
69
|
+
merged_options = DEFAULT_OPTIONS.merge(options)
|
58
70
|
|
59
|
-
cmd = "#{bin_path}
|
71
|
+
cmd = "#{bin_path} #{args.join(' ')}"
|
60
72
|
Luffa.log_unix_cmd(cmd) if Luffa::Environment.debug?
|
61
73
|
|
62
|
-
|
63
|
-
|
64
|
-
|
74
|
+
exit_status = nil
|
75
|
+
out = nil
|
76
|
+
pid = nil
|
77
|
+
err = nil
|
78
|
+
|
79
|
+
tries = merged_options[:tries]
|
80
|
+
timeout = merged_options[:timeout]
|
81
|
+
|
82
|
+
on = [Timeout::Error, RuntimeError]
|
83
|
+
on_retry = Proc.new do |_, try, elapsed_time, next_interval|
|
84
|
+
# Retriable 2.0
|
85
|
+
if elapsed_time && next_interval
|
86
|
+
Luffa.log_info "LLDB: attempt #{try} failed in '#{elapsed_time}'; will retry in '#{next_interval}'"
|
87
|
+
else
|
88
|
+
Luffa.log_info "LLDB: attempt #{try} failed; will retry"
|
89
|
+
end
|
65
90
|
end
|
66
91
|
|
67
|
-
|
68
|
-
|
92
|
+
Retriable.retriable({tries: tries, on: on, on_retry: on_retry} ) do
|
93
|
+
Timeout.timeout(timeout, TimeoutError) do
|
94
|
+
Open3.popen3(bin_path, *args) do |_, stdout, stderr, process_status|
|
95
|
+
err = stderr.read.strip
|
96
|
+
if err && err != ''
|
97
|
+
unless err[/iTunesMetadata.plist/,0] || err[/SC_Info/,0]
|
98
|
+
Luffa.log_fail(err)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
out = stdout.read.strip
|
102
|
+
pid = process_status.pid
|
103
|
+
exit_status = process_status.value.exitstatus
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
if exit_status != 0
|
108
|
+
raise RuntimeError, "Could not execute #{args.join(' ')}"
|
109
|
+
end
|
69
110
|
end
|
70
|
-
|
111
|
+
{
|
112
|
+
:out => out,
|
113
|
+
:err => err,
|
114
|
+
:pid => pid,
|
115
|
+
:exit_status => exit_status
|
116
|
+
}
|
71
117
|
end
|
72
118
|
|
73
|
-
def
|
74
|
-
|
119
|
+
def bundle_installed?(udid, options={})
|
120
|
+
merged_options = DEFAULT_OPTIONS.merge(options)
|
75
121
|
|
76
|
-
|
77
|
-
Luffa.log_unix_cmd(cmd) if Luffa::Environment.debug?
|
122
|
+
args = ['--udid', udid, '--list-apps']
|
78
123
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
124
|
+
hash = run_command_with_args(args, merged_options)
|
125
|
+
out = hash[:out]
|
126
|
+
out.split(/\s/).include? bundle_id
|
127
|
+
end
|
128
|
+
|
129
|
+
def install_internal(udid, options={})
|
130
|
+
merged_options = DEFAULT_OPTIONS.merge(options)
|
83
131
|
|
84
|
-
if bundle_installed?
|
85
|
-
|
132
|
+
return true if bundle_installed?(udid, merged_options)
|
133
|
+
args = ['--udid', udid, '--install', ipa]
|
134
|
+
run_command_with_args(args, merged_options)
|
135
|
+
|
136
|
+
unless bundle_installed?(udid, merged_options)
|
137
|
+
raise "could not install '#{ipa}' on '#{udid}' with '#{bundle_id}'"
|
86
138
|
end
|
87
139
|
true
|
88
140
|
end
|
89
141
|
|
90
|
-
def
|
91
|
-
|
92
|
-
end
|
142
|
+
def uninstall(udid, options={})
|
143
|
+
merged_options = DEFAULT_OPTIONS.merge(options)
|
93
144
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
145
|
+
return true unless bundle_installed?(udid, merged_options)
|
146
|
+
args = ['--udid', udid, '--uninstall', bundle_id]
|
147
|
+
run_command_with_args(args)
|
98
148
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
# connected via USB.
|
104
|
-
@physical_devices_for_testing ||= lambda {
|
105
|
-
devices = xcode_tools.instruments(:devices)
|
106
|
-
if idevice_id_available?
|
107
|
-
white_list = `#{idevice_id_bin_path} -l`.strip.split("\n")
|
108
|
-
devices.select { | device | white_list.include?(device.udid) }
|
109
|
-
else
|
110
|
-
devices
|
111
|
-
end
|
112
|
-
}.call
|
149
|
+
if bundle_installed?(udid, merged_options)
|
150
|
+
raise "Could not uninstall '#{bundle_id}' on '#{udid}'"
|
151
|
+
end
|
152
|
+
true
|
113
153
|
end
|
114
154
|
|
155
|
+
def idevice_id_bin_path
|
156
|
+
@idevice_id_bin_path ||= `which idevice_id`.chomp!
|
157
|
+
end
|
115
158
|
end
|
116
159
|
end
|
data/lib/luffa/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luffa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Maturana Larsen
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-
|
14
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: awesome_print
|