fastlane-plugin-instrumented_tests 0.1.4 → 0.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9e9a7c06de1ecb1e2c9e3a49502c732a443d2e7
|
4
|
+
data.tar.gz: 075c09f81e6f2255d43dd940af521298777e7b16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2bebfa09dacfb126242ad06433fa3184181de33cab3b10fb7f4222a59f3333c20da862628e021080916fd157db9ca2cefca2d0891ea7858fbcab061df3101f0
|
7
|
+
data.tar.gz: e929001e275d809ca7fb32edefc98bb3044c84ac5509f0e2fd4230e827a0149f576821291957a72b669860ab9d44608acf640fb664f06baace08096ccca1f659
|
@@ -9,20 +9,23 @@ module Fastlane
|
|
9
9
|
class InstrumentedTestsAction < Action
|
10
10
|
def self.run(params)
|
11
11
|
setup_parameters(params)
|
12
|
+
delete_old_emulators(params)
|
12
13
|
begin
|
13
|
-
delete_old_emulators(params)
|
14
|
-
create_emulator(params)
|
15
|
-
start_emulator(params)
|
16
|
-
|
17
14
|
begin
|
15
|
+
create_emulator(params)
|
16
|
+
start_emulator(params)
|
17
|
+
|
18
18
|
wait_emulator_boot(params)
|
19
19
|
execute_gradle(params)
|
20
20
|
ensure
|
21
21
|
stop_emulator(params)
|
22
22
|
end
|
23
|
+
|
24
|
+
rescue Exception => e
|
25
|
+
print_emulator_output(params)
|
26
|
+
raise e
|
23
27
|
ensure
|
24
|
-
|
25
|
-
@emulator_output.unlink
|
28
|
+
close_emulator_streams(params)
|
26
29
|
end
|
27
30
|
end
|
28
31
|
|
@@ -36,8 +39,6 @@ module Fastlane
|
|
36
39
|
params[:avd_hide]=Helper.is_ci? if params[:avd_hide].nil?
|
37
40
|
|
38
41
|
@android_serial="emulator-#{params[:avd_port]}"
|
39
|
-
# maybe create this in a way that the creation and destruction are in the same method
|
40
|
-
@emulator_output = Tempfile.new('emulator_output')
|
41
42
|
end
|
42
43
|
|
43
44
|
def self.delete_old_emulators(params)
|
@@ -55,7 +56,6 @@ module Fastlane
|
|
55
56
|
avd_abi = "--abi #{params[:avd_abi]}" unless params[:avd_abi].nil?
|
56
57
|
avd_tag = "--tag #{params[:avd_tag]}" unless params[:avd_tag].nil?
|
57
58
|
create_avd = ["#{params[:sdk_path]}/tools/android", "create avd", avd_name, target_id, avd_abi, avd_tag, avd_options].join(" ")
|
58
|
-
|
59
59
|
UI.important("Creating AVD...")
|
60
60
|
Action.sh(create_avd)
|
61
61
|
end
|
@@ -63,18 +63,35 @@ module Fastlane
|
|
63
63
|
def self.start_emulator(params)
|
64
64
|
UI.important("Starting AVD...")
|
65
65
|
ui_args="-gpu on"
|
66
|
-
ui_args="-no-
|
67
|
-
|
68
|
-
|
66
|
+
ui_args="-no-window" if params[:avd_hide]
|
67
|
+
ui_args=params[:avd_emulator_options] if params[:avd_emulator_options] != nil
|
68
|
+
start_avd = ["#{params[:sdk_path]}/tools/emulator", "-avd #{params[:avd_name]}", "#{ui_args}", "-port #{params[:avd_port]}" ].join(" ")
|
69
|
+
|
70
|
+
UI.command(start_avd)
|
71
|
+
stdin, @emulator_output, @emulator_thread = Open3.popen2e(start_avd)
|
72
|
+
stdin.close
|
69
73
|
end
|
70
74
|
|
71
75
|
def self.wait_emulator_boot(params)
|
76
|
+
timeout = Time.now + params[:boot_timeout]
|
72
77
|
UI.important("Waiting for emulator to finish booting... May take a few minutes...")
|
73
|
-
|
78
|
+
|
79
|
+
adb_path = "#{params[:sdk_path]}/platform-tools/adb"
|
80
|
+
raise "Unable to find adb in #{adb_path}" unless File.file?(adb_path)
|
74
81
|
loop do
|
75
|
-
boot_complete_cmd = "ANDROID_SERIAL=#{@android_serial} #{
|
82
|
+
boot_complete_cmd = "ANDROID_SERIAL=#{@android_serial} #{adb_path} shell getprop sys.boot_completed"
|
76
83
|
stdout, _stdeerr, _status = Open3.capture3(boot_complete_cmd)
|
77
84
|
|
85
|
+
if @emulator_thread != nil && (@emulator_thread.status == false || @emulator_thread.status == true)
|
86
|
+
UI.error("Emulator unexpectedly quit!")
|
87
|
+
raise "Emulator unexpectedly quit"
|
88
|
+
end
|
89
|
+
|
90
|
+
if (Time.now > timeout)
|
91
|
+
UI.error("Waited #{params[:boot_timeout]} seconds for emulator to boot without success")
|
92
|
+
raise "Emulator didn't boot"
|
93
|
+
end
|
94
|
+
|
78
95
|
if stdout.strip == "1"
|
79
96
|
UI.success("Emulator Booted!")
|
80
97
|
break
|
@@ -83,20 +100,42 @@ module Fastlane
|
|
83
100
|
end
|
84
101
|
end
|
85
102
|
|
86
|
-
def self.execute_gradle(params)
|
87
|
-
Fastlane::Actions::GradleAction.run(task: params[:task], flags: params[:flags], project_dir: params[:project_dir],
|
88
|
-
serial: @android_serial, print_command: true, print_command_output: true)
|
89
|
-
end
|
90
|
-
|
91
103
|
def self.stop_emulator(params)
|
92
|
-
|
93
|
-
|
94
|
-
|
104
|
+
begin
|
105
|
+
UI.important("Shutting down emulator...")
|
106
|
+
adb = Helper::AdbHelper.new(adb_path: "#{params[:sdk_path]}/platform-tools/adb")
|
107
|
+
adb.trigger(command: "emu kill", serial: @android_serial)
|
108
|
+
rescue
|
109
|
+
UI.message("Emulator is not listening for our commands...")
|
110
|
+
UI.message("Current status of emulator process is: #{@emulator_thread.status}")
|
111
|
+
|
112
|
+
if @emulator_thread != nil && @emulator_thread.status != true && @emulator_thread.status != false
|
113
|
+
UI.important("Emulator still running... Killing PID #{@emulator_thread.pid}!")
|
114
|
+
Process.kill("KILL", @emulator_thread.pid)
|
115
|
+
end
|
95
116
|
|
96
|
-
|
117
|
+
end
|
118
|
+
|
119
|
+
UI.important("Deleting emulator...")
|
97
120
|
Action.sh("#{params[:sdk_path]}/tools/android delete avd -n #{params[:avd_name]}")
|
98
121
|
end
|
99
122
|
|
123
|
+
def self.print_emulator_output(params)
|
124
|
+
UI.error("Error while trying to execute instrumentation tests. Output from emulator:")
|
125
|
+
@emulator_output.readlines.each do |line|
|
126
|
+
UI.error(line.gsub(/\r|\n/, " "))
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def self.close_emulator_streams(params)
|
131
|
+
@emulator_output.close
|
132
|
+
end
|
133
|
+
|
134
|
+
def self.execute_gradle(params)
|
135
|
+
Fastlane::Actions::GradleAction.run(task: params[:task], flags: params[:flags], project_dir: params[:project_dir],
|
136
|
+
serial: @android_serial, print_command: true, print_command_output: true)
|
137
|
+
end
|
138
|
+
|
100
139
|
def self.description
|
101
140
|
"Run android instrumented tests via a gradle command againts a newly created avd"
|
102
141
|
end
|
@@ -123,7 +162,7 @@ module Fastlane
|
|
123
162
|
optional: false),
|
124
163
|
FastlaneCore::ConfigItem.new(key: :avd_options,
|
125
164
|
env_name: "AVD_OPTIONS",
|
126
|
-
description: "Other avd options
|
165
|
+
description: "Other avd command line options passed to 'android create avd ...'. i.e. \"--scale 96dpi --dpi-device 160\"",
|
127
166
|
is_string: true,
|
128
167
|
optional: true),
|
129
168
|
FastlaneCore::ConfigItem.new(key: :avd_abi,
|
@@ -141,11 +180,24 @@ module Fastlane
|
|
141
180
|
description: "The port used for communication with the emulator. If not set it is randomly selected",
|
142
181
|
is_string: false,
|
143
182
|
optional: true),
|
183
|
+
FastlaneCore::ConfigItem.new(key: :boot_timeout,
|
184
|
+
env_name: "BOOT_TIMEOUT",
|
185
|
+
description: "Number of seconds to wait for the emulator to boot",
|
186
|
+
is_string: false,
|
187
|
+
optional: true,
|
188
|
+
default_value: 500),
|
144
189
|
FastlaneCore::ConfigItem.new(key: :avd_hide,
|
145
190
|
env_name: "AVD_HIDE",
|
146
191
|
description: "Hide the avd interface, required for CI. Default true if on CI, false if not on CI",
|
147
192
|
is_string: false,
|
148
193
|
optional: true),
|
194
|
+
FastlaneCore::ConfigItem.new(key: :avd_emulator_options,
|
195
|
+
env_name: "AVD_EMULATOR_OPTIONS",
|
196
|
+
description: "Other options passed to the emulator command ('emulator -avd AVD_NAME ...')." +
|
197
|
+
"Defaults are '-gpu on' when AVD_HIDE is false and '-no-window' otherwise. " +
|
198
|
+
"For macs running the CI you might want to use '-no-audio -no-window'",
|
199
|
+
is_string: true,
|
200
|
+
optional: true),
|
149
201
|
FastlaneCore::ConfigItem.new(key: :sdk_path,
|
150
202
|
env_name: "ANDROID_HOME",
|
151
203
|
description: "The path to your android sdk directory",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-instrumented_tests
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Silviu Paragina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -126,11 +126,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
128
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
129
|
+
rubygems_version: 2.6.7
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
|
-
summary: New action to run instrumented tests for android. This
|
133
|
-
|
132
|
+
summary: New action to run instrumented tests for android. This plugin creates and
|
133
|
+
boots an emulator before running a gradle command so that you can run instrumented
|
134
134
|
tests against that emulator. After the gradle command is executed, the avd gets
|
135
135
|
shut down and deleted. This is really helpful on CI services, keeping them clean
|
136
136
|
and always having a fresh avd for testing.
|