flaky 0.0.16 → 0.0.17
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/flaky.gemspec +0 -1
- data/lib/flaky.rb +3 -4
- data/lib/flaky/appium.rb +3 -2
- data/lib/flaky/run.rb +47 -3
- data/release_notes.md +7 -0
- data/test/all_tests.rb +0 -1
- metadata +2 -17
- data/lib/flaky/log.rb +0 -106
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 114eb59e36a70bf9654f2ff5b456325bdff0ab70
|
4
|
+
data.tar.gz: 3e201be6fc05c9d2786067aa7971d9dfe48b432b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13e0202fd081788b1c49d3ce80454ecf606e2408711b113f86f7215d96526991ddaa5ee3b052e4b9ee1e4b863b2a16ac3f0fab0086c77623ff6f04071f611f47
|
7
|
+
data.tar.gz: 1a123780cacd99a3f9af0da8ea64b303558336c0629e793b76d5e59b7c8c0529967cf0e628c0cd8f899f7c2282784b3d5f78bfe3cc56912736d1302fceef5f67
|
data/flaky.gemspec
CHANGED
@@ -25,7 +25,6 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.require_paths = %w(lib)
|
26
26
|
|
27
27
|
s.add_runtime_dependency 'chronic_duration', '~> 0.10.2'
|
28
|
-
s.add_runtime_dependency 'escape_utils', '~> 1.0.0'
|
29
28
|
s.add_runtime_dependency 'posix-spawn', '~> 0.3.6'
|
30
29
|
|
31
30
|
s.add_development_dependency 'rake', '~> 10.1.0'
|
data/lib/flaky.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'fileutils' # system requires
|
3
3
|
require 'open3'
|
4
|
+
require 'timeout' # to timeout long running color runs
|
4
5
|
|
5
6
|
require 'rubygems' # gem requires
|
6
7
|
require 'chronic_duration'
|
7
|
-
require 'escape_utils'
|
8
8
|
require 'posix/spawn' # http://rubygems.org/gems/posix-spawn
|
9
9
|
require 'digest/md5'
|
10
10
|
|
11
11
|
module Flaky
|
12
|
-
VERSION = '0.0.
|
13
|
-
DATE = '2013-12-
|
12
|
+
VERSION = '0.0.17' unless defined? ::Flaky::VERSION
|
13
|
+
DATE = '2013-12-10' unless defined? ::Flaky::DATE
|
14
14
|
|
15
15
|
# https://github.com/appium/ruby_lib/blob/0e203d76610abd519ba9d2fe9c14b50c94df5bbd/lib/appium_lib.rb#L24
|
16
16
|
def self.add_to_path file, path=false
|
@@ -26,7 +26,6 @@ module Flaky
|
|
26
26
|
# require internal files
|
27
27
|
require 'flaky/appium'
|
28
28
|
require 'flaky/applescript'
|
29
|
-
require 'flaky/log'
|
30
29
|
require 'flaky/run'
|
31
30
|
|
32
31
|
require 'flaky/run/all_tests'
|
data/lib/flaky/appium.rb
CHANGED
@@ -23,7 +23,7 @@ module Flaky
|
|
23
23
|
class Appium
|
24
24
|
include POSIX::Spawn
|
25
25
|
# logcat is read & stopped by run.execute
|
26
|
-
attr_reader :ready, :pid, :in, :out, :err, :log, :logcat
|
26
|
+
attr_reader :ready, :pid, :in, :out, :err, :log, :logcat, :ios, :android
|
27
27
|
@@thread = nil
|
28
28
|
|
29
29
|
def self.remove_ios_apps
|
@@ -61,6 +61,7 @@ module Flaky
|
|
61
61
|
@droid = Flaky::Android.new
|
62
62
|
@logcat = Flaky::Logcat.new
|
63
63
|
end
|
64
|
+
@ios = ! @android
|
64
65
|
end
|
65
66
|
|
66
67
|
def start
|
@@ -101,7 +102,7 @@ module Flaky
|
|
101
102
|
def flush_buffer
|
102
103
|
return if @buffer.nil? || @buffer.empty?
|
103
104
|
File.open(@log, 'a') do |f|
|
104
|
-
f.write
|
105
|
+
f.write @buffer
|
105
106
|
end
|
106
107
|
@buffer = ''
|
107
108
|
@log
|
data/lib/flaky/run.rb
CHANGED
@@ -126,8 +126,13 @@ module Flaky
|
|
126
126
|
|
127
127
|
log_file = LogArtifact.new result_dir: result_dir, pass_str: pass_str, test_name: test_name
|
128
128
|
|
129
|
+
# File.open 'w' will not create folders. Use mkdir_p before.
|
130
|
+
test_file_path = log_file.name("#{postfix}.html")
|
131
|
+
FileUtils.mkdir_p File.dirname(test_file_path)
|
129
132
|
# html Ruby test log
|
130
|
-
|
133
|
+
File.open(test_file_path, 'w') do |f|
|
134
|
+
f.write log
|
135
|
+
end
|
131
136
|
|
132
137
|
# TODO: Get iOS simulator system log from appium
|
133
138
|
# File.open(log_file.name("#{postfix}.server.log.txt"), 'w') do |f|
|
@@ -136,21 +141,45 @@ module Flaky
|
|
136
141
|
|
137
142
|
# adb logcat log
|
138
143
|
logcat = appium.logcat ? appium.logcat.stop : nil
|
139
|
-
|
144
|
+
logcat_file_path = log_file.name("#{postfix}.logcat.txt")
|
145
|
+
FileUtils.mkdir_p File.dirname(logcat_file_path)
|
146
|
+
File.open(logcat_file_path, 'w') do |f|
|
140
147
|
f.write logcat
|
141
148
|
end if logcat
|
142
149
|
|
143
150
|
# appium server log
|
144
|
-
|
151
|
+
appium_server_path = log_file.name("#{postfix}.appium.html")
|
152
|
+
FileUtils.mkdir_p File.dirname(appium_server_path)
|
153
|
+
File.open(appium_server_path, 'w') do |f|
|
154
|
+
# this may return nil
|
155
|
+
tmp_file = appium.flush_buffer
|
156
|
+
|
157
|
+
if !tmp_file.nil? && !tmp_file.empty?
|
158
|
+
f.write File.read tmp_file
|
159
|
+
File.delete tmp_file
|
160
|
+
end
|
161
|
+
end
|
145
162
|
|
146
163
|
passed
|
147
164
|
end
|
148
165
|
|
166
|
+
def collect_crashes array
|
167
|
+
Dir.glob(File.join(Dir.home, '/Library/Logs/DiagnosticReports/*.crash')) do |crash|
|
168
|
+
array << crash
|
169
|
+
end
|
170
|
+
array
|
171
|
+
end
|
172
|
+
|
149
173
|
def execute opts={}
|
150
174
|
run_cmd = opts[:run_cmd]
|
151
175
|
test_name = opts[:test_name]
|
152
176
|
appium = opts[:appium]
|
153
177
|
|
178
|
+
old_crash_files = []
|
179
|
+
if appium.ios
|
180
|
+
collect_crashes old_crash_files
|
181
|
+
end
|
182
|
+
|
154
183
|
raise 'must pass :run_cmd' unless run_cmd
|
155
184
|
raise 'must pass :test_name' unless test_name
|
156
185
|
raise 'must pass :appium' unless appium
|
@@ -165,6 +194,21 @@ module Flaky
|
|
165
194
|
|
166
195
|
print passed ? green(' ✓') : red(' ✖')
|
167
196
|
|
197
|
+
if appium.ios
|
198
|
+
new_crash_files = []
|
199
|
+
collect_crashes new_crash_files
|
200
|
+
|
201
|
+
new_crash_files = new_crash_files - old_crash_files
|
202
|
+
if new_crash_files.length > 0
|
203
|
+
File.open('/tmp/flaky/crashes.txt', 'a') do |f|
|
204
|
+
f.puts '--'
|
205
|
+
f.puts "Test: #{test_name} crashed on iOS:"
|
206
|
+
new_crash_files.each { |crash| f.puts crash }
|
207
|
+
f.puts '--'
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
168
212
|
@last_test = test_name
|
169
213
|
passed
|
170
214
|
end
|
data/release_notes.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
#### v0.0.16 2013-12-09
|
2
|
+
|
3
|
+
- [fed719a](https://github.com/appium/flaky/commit/fed719af184a6f38a4d29b3c65f1906d6917c1fb) Release 0.0.16
|
4
|
+
- [4aa7711](https://github.com/appium/flaky/commit/4aa7711b206a71338fc8d771c5ef49ec036f1ab8) Fix file exists error. Write current test to current.txt
|
5
|
+
- [1b0589c](https://github.com/appium/flaky/commit/1b0589c232219b5c535432976056a6d5c30ed073) Update todo.md
|
6
|
+
|
7
|
+
|
1
8
|
#### v0.0.15 2013-12-05
|
2
9
|
|
3
10
|
- [5397189](https://github.com/appium/flaky/commit/539718980a1c1578da63c30f773e5c249415b2b9) Release 0.0.15
|
data/test/all_tests.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flaky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- code@bootstraponline.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic_duration
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.10.2
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: escape_utils
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0.0
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0.0
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: posix-spawn
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,7 +70,6 @@ files:
|
|
84
70
|
- lib/flaky.rb
|
85
71
|
- lib/flaky/appium.rb
|
86
72
|
- lib/flaky/applescript.rb
|
87
|
-
- lib/flaky/log.rb
|
88
73
|
- lib/flaky/logcat.rb
|
89
74
|
- lib/flaky/reset_android.rb
|
90
75
|
- lib/flaky/run.rb
|
data/lib/flaky/log.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Flaky
|
3
|
-
class << self
|
4
|
-
# Monaco 18 pt
|
5
|
-
# ANSI colors
|
6
|
-
#
|
7
|
-
# [36m = 00eee9 = cyan
|
8
|
-
# [32m = 00e800 = green
|
9
|
-
# [0m = f4f4f4 = reset
|
10
|
-
def html_before
|
11
|
-
<<-'HTML'
|
12
|
-
<html>
|
13
|
-
<head>
|
14
|
-
<style>
|
15
|
-
* {
|
16
|
-
padding: 0;
|
17
|
-
margin: 0;
|
18
|
-
border: 0;
|
19
|
-
width: 0;
|
20
|
-
height: 0;
|
21
|
-
}
|
22
|
-
div { display: inline; }
|
23
|
-
body { background-color: #262626; }
|
24
|
-
#terminal {
|
25
|
-
display: inherit;
|
26
|
-
white-space: pre;
|
27
|
-
font-family: "Monaco";
|
28
|
-
font-size: 14px;
|
29
|
-
color: #f4f4f4;
|
30
|
-
padding-left: 18px;
|
31
|
-
}
|
32
|
-
div.cyan { color: #00eee9; }
|
33
|
-
div.green { color: #00e800; }
|
34
|
-
div.grey { color: #666666; }
|
35
|
-
</style>
|
36
|
-
</head>
|
37
|
-
<body>
|
38
|
-
<div id="terminal">
|
39
|
-
HTML
|
40
|
-
end
|
41
|
-
|
42
|
-
def html_after
|
43
|
-
<<-'HTML'
|
44
|
-
</div>
|
45
|
-
</body>
|
46
|
-
</html>
|
47
|
-
HTML
|
48
|
-
end
|
49
|
-
|
50
|
-
def write log_file, log, file_path=nil
|
51
|
-
# directory must exist
|
52
|
-
FileUtils.mkdir_p File.dirname log_file
|
53
|
-
# Pry & Awesome Print use the ruby objects to insert term colors.
|
54
|
-
# this can't be done with the raw text output.
|
55
|
-
|
56
|
-
# escape_html will error if called when log is nil
|
57
|
-
# must escape for rendering HTML in the browser
|
58
|
-
log = EscapeUtils.escape_html log || '' unless file_path
|
59
|
-
# [90mPOST /wd/hub/session [36m303 [90m6877ms - 9[0m
|
60
|
-
|
61
|
-
scan = StringScanner.new log || File.read(file_path)
|
62
|
-
File.delete(file_path) if file_path # delete tmp buffer file
|
63
|
-
|
64
|
-
new_log = '<div>'
|
65
|
-
|
66
|
-
color_rgx = /\[(\d+)m/
|
67
|
-
while !scan.eos?
|
68
|
-
match = scan.scan_until color_rgx
|
69
|
-
match_size = scan.matched_size
|
70
|
-
|
71
|
-
# no more color codes
|
72
|
-
if match_size.nil?
|
73
|
-
new_log += scan.rest
|
74
|
-
new_log += '</div>'
|
75
|
-
break
|
76
|
-
end
|
77
|
-
|
78
|
-
# save before the color code, excluding the color code
|
79
|
-
new_log += match[0..-1 - match_size]
|
80
|
-
new_log += '</div>'
|
81
|
-
|
82
|
-
found_number = match.match(color_rgx).to_a.last.gsub(/[^\d]/, '').to_i
|
83
|
-
|
84
|
-
# now make a new colored div
|
85
|
-
color = case (found_number)
|
86
|
-
when 39, 0 # white text
|
87
|
-
'<div>'
|
88
|
-
when 90 # grey
|
89
|
-
'<div class="grey">'
|
90
|
-
when 36
|
91
|
-
'<div class="cyan">'
|
92
|
-
when 32
|
93
|
-
'<div class="green">'
|
94
|
-
else
|
95
|
-
'<div>' # Unknown color code
|
96
|
-
end
|
97
|
-
|
98
|
-
new_log += color
|
99
|
-
end
|
100
|
-
|
101
|
-
File.open(log_file, 'w') do |f|
|
102
|
-
f.write html_before + new_log + html_after
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end # class << self
|
106
|
-
end # module Flaky
|