fastlane-plugin-instrumented_tests 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44fb638f00eb58f13471775fe1efa67db839e815
|
4
|
+
data.tar.gz: a2f1a28d771d8f431cedea9f0fa203ef0af45bfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53daa02770fb89b387444ce37be34f0fa145b30dde20507e857b44fd9d6ace9b894fa73871a298f58ddb241bfeb5069c775ad055bf733b6a189d3240f4e47178
|
7
|
+
data.tar.gz: 480a0bfcfef42cef95b847a4249bbefaac5ddf6a76130968e2f174c867bfe1658ffa124af681330d51c83f97b627fadbe2f82a43dac59498a5a594d9e13ec425
|
@@ -8,71 +8,90 @@ module Fastlane
|
|
8
8
|
|
9
9
|
class InstrumentedTestsAction < Action
|
10
10
|
def self.run(params)
|
11
|
-
|
11
|
+
setup_parameters(params)
|
12
|
+
begin
|
13
|
+
delete_old_emulators(params)
|
14
|
+
create_emulator(params)
|
15
|
+
start_emulator(params)
|
16
|
+
|
17
|
+
begin
|
18
|
+
wait_emulator_boot(params)
|
19
|
+
execute_gradle(params)
|
20
|
+
ensure
|
21
|
+
stop_emulator(params)
|
22
|
+
end
|
23
|
+
ensure
|
24
|
+
@emulator_output.close
|
25
|
+
@emulator_output.unlink
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.setup_parameters(params)
|
30
|
+
# port must be an even integer number between 5554 and 5680
|
31
|
+
params[:avd_port]=Random.rand(50)*2+5580 if params[:avd_port].nil?
|
32
|
+
raise ":avd_port must be at least 5554" if params[:avd_port]<5554
|
33
|
+
raise ":avd_port must be lower than 5680" if params[:avd_port]>5680
|
34
|
+
raise ":avd_port must be an even number" if params[:avd_port]%2 != 0
|
35
|
+
|
36
|
+
params[:avd_hide]=Helper.is_ci? if params[:avd_hide].nil?
|
12
37
|
|
13
|
-
|
38
|
+
@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
|
+
end
|
42
|
+
|
43
|
+
def self.delete_old_emulators(params)
|
44
|
+
devices = `#{params[:sdk_path]}/tools/android list avd`.chomp
|
45
|
+
|
46
|
+
unless devices.match(/#{params[:avd_name]}/).nil?
|
47
|
+
Action.sh("#{params[:sdk_path]}/tools/android delete avd -n #{params[:avd_name]}")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.create_emulator(params)
|
14
52
|
avd_name = "--name \"#{params[:avd_name]}\""
|
15
53
|
target_id = "--target #{params[:target_id]}"
|
16
54
|
avd_options = params[:avd_options] unless params[:avd_options].nil?
|
17
55
|
avd_abi = "--abi #{params[:avd_abi]}" unless params[:avd_abi].nil?
|
18
56
|
avd_tag = "--tag #{params[:avd_tag]}" unless params[:avd_tag].nil?
|
19
57
|
create_avd = ["#{params[:sdk_path]}/tools/android", "create avd", avd_name, target_id, avd_abi, avd_tag, avd_options].join(" ")
|
20
|
-
start_avd = ["#{params[:sdk_path]}/tools/emulator", "-avd #{params[:avd_name]}", "-gpu on -no-boot-anim &>#{file.path} &"]
|
21
|
-
devices = `#{params[:sdk_path]}/tools/android list avd`.chomp
|
22
|
-
|
23
|
-
# Delete avd if one already exists for clean state.
|
24
|
-
unless devices.match(/#{params[:avd_name]}/).nil?
|
25
|
-
Action.sh("#{params[:sdk_path]}/tools/android delete avd -n #{params[:avd_name]}")
|
26
|
-
end
|
27
58
|
|
28
59
|
UI.important("Creating AVD...")
|
29
60
|
Action.sh(create_avd)
|
61
|
+
end
|
30
62
|
|
63
|
+
def self.start_emulator(params)
|
31
64
|
UI.important("Starting AVD...")
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
boot_emulator(params)
|
37
|
-
|
38
|
-
begin
|
39
|
-
Fastlane::Actions::GradleAction.run(task: params[:task], flags: params[:flags], project_dir: params[:project_dir],
|
40
|
-
print_command: true, print_command_output: true)
|
41
|
-
ensure
|
42
|
-
stop_emulator(params, file)
|
43
|
-
end
|
44
|
-
ensure
|
45
|
-
file.close
|
46
|
-
file.unlink
|
47
|
-
end
|
65
|
+
ui_args="-gpu on"
|
66
|
+
ui_args="-gpu on -no-audio -no-window" if params[:avd_hide]
|
67
|
+
start_avd = ["#{params[:sdk_path]}/tools/emulator", "-avd #{params[:avd_name]}", "#{ui_args}", "-port #{params[:avd_port]} &>#{@emulator_output.path} &"]
|
68
|
+
Action.sh(start_avd)
|
48
69
|
end
|
49
70
|
|
50
|
-
def self.
|
71
|
+
def self.wait_emulator_boot(params)
|
51
72
|
UI.important("Waiting for emulator to finish booting... May take a few minutes...")
|
73
|
+
adb = Helper::AdbHelper.new(adb_path: "#{params[:sdk_path]}/platform-tools/adb")
|
52
74
|
loop do
|
53
|
-
|
54
|
-
stdout, _stdeerr, _status = Open3.capture3(
|
75
|
+
boot_complete_cmd = "ANDROID_SERIAL=#{@android_serial} #{params[:sdk_path]}/platform-tools/adb shell getprop sys.boot_completed"
|
76
|
+
stdout, _stdeerr, _status = Open3.capture3(boot_complete_cmd)
|
55
77
|
|
56
78
|
if stdout.strip == "1"
|
57
79
|
UI.success("Emulator Booted!")
|
58
80
|
break
|
59
81
|
end
|
82
|
+
sleep(1)
|
60
83
|
end
|
61
84
|
end
|
62
85
|
|
63
|
-
def self.
|
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
|
+
def self.stop_emulator(params)
|
64
92
|
UI.important("Shutting down emulator...")
|
65
93
|
adb = Helper::AdbHelper.new(adb_path: "#{params[:sdk_path]}/platform-tools/adb")
|
66
|
-
|
67
|
-
port = temp.match(/console on port (\d+),/)
|
68
|
-
if port
|
69
|
-
port = port[1]
|
70
|
-
else
|
71
|
-
UI.important("Could not find emulator port number, using default port.")
|
72
|
-
port = "5554"
|
73
|
-
end
|
74
|
-
|
75
|
-
adb.trigger(command: "emu kill", serial: "emulator-#{port}")
|
94
|
+
adb.trigger(command: "emu kill", serial: @android_serial)
|
76
95
|
|
77
96
|
UI.success("Deleting emulator...")
|
78
97
|
Action.sh("#{params[:sdk_path]}/tools/android delete avd -n #{params[:avd_name]}")
|
@@ -117,6 +136,16 @@ module Fastlane
|
|
117
136
|
description: "The sys-img tag to use for the AVD. The default is to auto-select if the platform has only one tag for its system images",
|
118
137
|
is_string: true,
|
119
138
|
optional: true),
|
139
|
+
FastlaneCore::ConfigItem.new(key: :avd_port,
|
140
|
+
env_name: "AVD_PORT",
|
141
|
+
description: "The port used for communication with the emulator. If not set it is randomly selected",
|
142
|
+
is_string: false,
|
143
|
+
optional: true),
|
144
|
+
FastlaneCore::ConfigItem.new(key: :avd_hide,
|
145
|
+
env_name: "AVD_HIDE",
|
146
|
+
description: "Hide the avd interface, required for CI. Default true if on CI, false if not on CI",
|
147
|
+
is_string: false,
|
148
|
+
optional: true),
|
120
149
|
FastlaneCore::ConfigItem.new(key: :sdk_path,
|
121
150
|
env_name: "ANDROID_HOME",
|
122
151
|
description: "The path to your android sdk directory",
|
@@ -147,7 +176,7 @@ module Fastlane
|
|
147
176
|
end
|
148
177
|
|
149
178
|
def self.authors
|
150
|
-
["joshrlesch"]
|
179
|
+
["joshrlesch", "lexxdark"]
|
151
180
|
end
|
152
181
|
|
153
182
|
def self.is_supported?(platform)
|
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.2
|
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-07-
|
11
|
+
date: 2016-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|