fastlane-plugin-flutter_tests 0.2.0 → 0.2.1
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/README.md +1 -0
- data/lib/fastlane/plugin/flutter_tests/helper/flutter_integration_test_helper.rb +22 -1
- data/lib/fastlane/plugin/flutter_tests/helper/flutter_unit_test_helper.rb +3 -12
- data/lib/fastlane/plugin/flutter_tests/utils/utilities.rb +26 -0
- data/lib/fastlane/plugin/flutter_tests/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 216ca212fa4e036f26af8482fe8df422e8c3f4388e7f5187b86c7af715e53246
|
4
|
+
data.tar.gz: bc7aad7153e8e729f58e201a4aa72c3dc46afb7190270a0a2515f517921dbf94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91d73eb0f995ebd7873d390493482c08f2545e0fc7797b2c2c740320b991072f524ea48c110ef5eb4d47aaac7cc8f3cef1df6dc68a074b320489d139173eb08b
|
7
|
+
data.tar.gz: bf22e2131c59c14a77a7c652704c16279663153fbbdbf36c4e3cdab6426f3e30511b0d315320bdea4708dc9c4b8019c422ba78ce213ecdc2a789fa4bb3f41dcf
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# flutter_tests plugin
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/fastlane-plugin-flutter_tests)
|
4
|
+
[](https://badge.fury.io/rb/fastlane-plugin-flutter_tests)
|
4
5
|
|
5
6
|
## Getting Started
|
6
7
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'fastlane/action'
|
2
2
|
require 'open3'
|
3
|
+
require_relative '../utils/utilities.rb'
|
3
4
|
|
4
5
|
module Fastlane
|
5
6
|
module Helper
|
@@ -33,6 +34,7 @@ module Fastlane
|
|
33
34
|
# @param platform [String] Specifies on which platform the tests should be run
|
34
35
|
# @param force_launch [Boolean] If it's true and there aren't any devices ready, the plugin will try to start one for the given platform
|
35
36
|
# @param reuse_build [Boolean] If it's true, it will run the build only for the first integration test
|
37
|
+
# @return [Integer] Value 0 or 1 if all tests were run correctly or not
|
36
38
|
def run(platform, force_launch, reuse_build)
|
37
39
|
UI.message("Checking for running devices")
|
38
40
|
device_id = _run_test_device(platform, force_launch)
|
@@ -48,6 +50,7 @@ module Fastlane
|
|
48
50
|
#
|
49
51
|
# @param device_id [String] the id of the device previously found
|
50
52
|
# @param reuse_build [Boolean] If it's true, it will run the build only for the first integration test
|
53
|
+
# @return [Integer] Value 0 or 1 if all tests were run correctly or not
|
51
54
|
def _launch_tests(device_id, reuse_build)
|
52
55
|
apk_path = nil
|
53
56
|
if reuse_build
|
@@ -71,12 +74,30 @@ module Fastlane
|
|
71
74
|
end
|
72
75
|
|
73
76
|
count = 0
|
77
|
+
|
78
|
+
tests = {
|
79
|
+
"successful" => 0,
|
80
|
+
"failed" => 0,
|
81
|
+
}
|
82
|
+
|
74
83
|
@integration_tests.each do |test|
|
75
84
|
UI.message("Launching test #{count}/#{@integration_tests.length}: #{test.split("/").last}")
|
76
85
|
_, __, status = Open3.capture3("#{@flutter_command} drive --target #{@driver} --driver #{test} -d #{device_id} #{reuse_build ? "--use-application-binary #{apk_path}" : ''}")
|
77
|
-
|
86
|
+
successful = _get_exit_code(status) == '0'
|
87
|
+
color = successful ? 'green' : 'red'
|
88
|
+
tests[successful ? 'successful' : 'failed'] += 1
|
89
|
+
|
90
|
+
UI.message(Utilities.new.colorize("Test #{test.split("/").last} #{successful ? 'terminated correctly' : 'failed'}", color))
|
78
91
|
count += 1
|
79
92
|
end
|
93
|
+
|
94
|
+
if tests['failed'] != 0
|
95
|
+
UI.error("Some integration tests failed")
|
96
|
+
1
|
97
|
+
else
|
98
|
+
0
|
99
|
+
end
|
100
|
+
|
80
101
|
end
|
81
102
|
|
82
103
|
# Returns the exit code of a process
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fastlane/action'
|
2
|
+
require_relative '../utils/utilities'
|
2
3
|
|
3
4
|
module Fastlane
|
4
5
|
|
@@ -8,16 +9,6 @@ module Fastlane
|
|
8
9
|
@launched_tests = Hash.new { |hash, key| hash[key] = nil }
|
9
10
|
end
|
10
11
|
|
11
|
-
# Wraps the message to color it
|
12
|
-
#
|
13
|
-
# @param message [String] the message that has to be wrapped
|
14
|
-
# @param color [Integer] the color of the message (34 -> blue, 32 -> green, 31 -> red)
|
15
|
-
#
|
16
|
-
# @return [String] the colorized message ready to be printed
|
17
|
-
def _colorize(message, color)
|
18
|
-
"\e[#{color}m#{message}\e[0m"
|
19
|
-
end
|
20
|
-
|
21
12
|
# Launches all the unit tests contained in the project
|
22
13
|
# folder
|
23
14
|
#
|
@@ -49,12 +40,12 @@ module Fastlane
|
|
49
40
|
]
|
50
41
|
|
51
42
|
messages = ["Ran #{@launched_tests.values.count { |e| !e.nil? }} tests"]
|
52
|
-
colors = { 0 =>
|
43
|
+
colors = { 0 => 'green', 1 => 'red', 2 => 'blue' }
|
53
44
|
max_length = 0
|
54
45
|
(0..2).each do |i|
|
55
46
|
msg = "#{table[0][i]}:\t#{table[1][i]}"
|
56
47
|
max_length = [max_length, msg.length].max
|
57
|
-
messages.append(
|
48
|
+
messages.append(Utilities.new.colorize(msg, colors[i]))
|
58
49
|
end
|
59
50
|
|
60
51
|
UI.message('-' * max_length)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Utilities
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
@colors = {
|
5
|
+
'blue' => 34,
|
6
|
+
'green' => 32,
|
7
|
+
'red' => 31,
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
# Colorize a message. If the color specified doesn't exists, returns the default
|
12
|
+
# message
|
13
|
+
#
|
14
|
+
# @param message [String] the message that has to be colorized before printing
|
15
|
+
# @param color [String] the name of the color
|
16
|
+
# @return [String] the message wrapped in a new color
|
17
|
+
def colorize(message, color)
|
18
|
+
if @colors.has_key? color
|
19
|
+
color_code = @colors[color]
|
20
|
+
"\e[#{color_code}m#{message}\e[0m"
|
21
|
+
else
|
22
|
+
message
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-flutter_tests
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- smaso
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- lib/fastlane/plugin/flutter_tests/helper/flutter_integration_test_helper.rb
|
164
164
|
- lib/fastlane/plugin/flutter_tests/helper/flutter_unit_test_helper.rb
|
165
165
|
- lib/fastlane/plugin/flutter_tests/model/test_item.rb
|
166
|
+
- lib/fastlane/plugin/flutter_tests/utils/utilities.rb
|
166
167
|
- lib/fastlane/plugin/flutter_tests/version.rb
|
167
168
|
homepage: https://github.com/smsimone/fastlane_flutter_tests.git
|
168
169
|
licenses:
|