flaky 0.0.12 → 0.0.13
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 +1 -1
- data/lib/flaky.rb +2 -2
- data/lib/flaky/appium.rb +33 -14
- data/lib/flaky/log.rb +17 -16
- data/lib/flaky/run.rb +5 -5
- data/readme.md +1 -2
- data/release_notes.md +7 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c518578fad2332c3c4d04a73e4e75348b2e6298
|
4
|
+
data.tar.gz: dac38464aa7e40e539c1fbacd9816dc7671e83ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1600f893244cc2ee6f6e928567c5fbd3183461a765d9d4b813441a9986d9d5d1db74c4d16b53fb649cf3291c2d3113b7e4d974423c6378d6c5f8283034346da5
|
7
|
+
data.tar.gz: ccca18f08d340ceaf32f1f0400f16482eab2ab16bfc22445d988b7c0b3a3ef6342bcda40e88a998ba5b8ecba3fa485933324017994e9cfd079cdcc9926a70002
|
data/flaky.gemspec
CHANGED
@@ -25,7 +25,7 @@ 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', '~> 0.
|
28
|
+
s.add_runtime_dependency 'escape_utils', '~> 1.0.0'
|
29
29
|
s.add_runtime_dependency 'posix-spawn', '~> 0.3.6'
|
30
30
|
|
31
31
|
s.add_development_dependency 'rake', '~> 10.1.0'
|
data/lib/flaky.rb
CHANGED
@@ -9,8 +9,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-11-
|
12
|
+
VERSION = '0.0.13' unless defined? ::Flaky::VERSION
|
13
|
+
DATE = '2013-11-12' 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
|
data/lib/flaky/appium.rb
CHANGED
@@ -11,8 +11,11 @@ module Flaky
|
|
11
11
|
|
12
12
|
def stop
|
13
13
|
[@in, @out, @err].each { |io| io.close unless io.nil? || io.closed? }
|
14
|
-
|
15
|
-
|
14
|
+
begin
|
15
|
+
Process.kill 'KILL', @pid
|
16
|
+
Process.waitpid @pid
|
17
|
+
rescue # no such process
|
18
|
+
end
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
@@ -20,7 +23,7 @@ module Flaky
|
|
20
23
|
class Appium
|
21
24
|
include POSIX::Spawn
|
22
25
|
# logcat is read & stopped by run.execute
|
23
|
-
attr_reader :ready, :pid, :in, :out, :err, :log, :
|
26
|
+
attr_reader :ready, :pid, :in, :out, :err, :log, :logcat
|
24
27
|
@@thread = nil
|
25
28
|
|
26
29
|
def self.remove_ios_apps
|
@@ -30,7 +33,7 @@ module Flaky
|
|
30
33
|
# Must kill iPhone simulator or strange install errors will occur.
|
31
34
|
self.kill_all 'iPhone Simulator'
|
32
35
|
|
33
|
-
app_glob = "/Users/#{user}/Library/Application Support/iPhone Simulator
|
36
|
+
app_glob = "/Users/#{user}/Library/Application Support/iPhone Simulator/**/Applications/*"
|
34
37
|
Dir.glob(app_glob) do |ios_app_folder|
|
35
38
|
FileUtils.rm_rf ios_app_folder
|
36
39
|
end
|
@@ -52,7 +55,7 @@ module Flaky
|
|
52
55
|
@ready = false
|
53
56
|
@pid, @in, @out, @err = nil
|
54
57
|
@log = ''
|
55
|
-
@
|
58
|
+
@buffer = ''
|
56
59
|
@android = opts.fetch(:android, false)
|
57
60
|
if @android
|
58
61
|
@droid = Flaky::Android.new
|
@@ -61,14 +64,13 @@ module Flaky
|
|
61
64
|
end
|
62
65
|
|
63
66
|
def start
|
64
|
-
@log = ''
|
65
67
|
self.stop # stop existing process
|
66
|
-
|
68
|
+
@log = "/tmp/flaky/tmp_log_#{Random.rand(10**4..10**5-1)}"
|
67
69
|
if @android
|
68
70
|
@droid.reset
|
69
71
|
@logcat.start
|
70
72
|
else
|
71
|
-
|
73
|
+
self.class.remove_ios_apps
|
72
74
|
end
|
73
75
|
|
74
76
|
@@thread.exit if @@thread
|
@@ -81,7 +83,28 @@ module Flaky
|
|
81
83
|
sleep 0.5
|
82
84
|
end
|
83
85
|
|
84
|
-
|
86
|
+
# -e = -A = include other user's processes
|
87
|
+
# -a = include your own processes
|
88
|
+
# -x = include processes without a controlling terminal
|
89
|
+
# ps -eax | grep "tail"
|
90
|
+
# http://askubuntu.com/questions/157075/why-does-ps-aux-grep-x-give-better-results-than-pgrep-x
|
91
|
+
end
|
92
|
+
|
93
|
+
def update_buffer data
|
94
|
+
@buffer += data
|
95
|
+
|
96
|
+
if @buffer.length >= 32_000
|
97
|
+
self.flush_buffer
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def flush_buffer
|
102
|
+
return if @buffer.nil? || @buffer.empty?
|
103
|
+
File.open(@log, 'a') do |f|
|
104
|
+
f.write EscapeUtils.escape_html @buffer
|
105
|
+
end
|
106
|
+
@buffer = ''
|
107
|
+
@log
|
85
108
|
end
|
86
109
|
|
87
110
|
##
|
@@ -100,7 +123,7 @@ module Flaky
|
|
100
123
|
ready_for_reading.each do |stream|
|
101
124
|
begin
|
102
125
|
capture = stream.readpartial 999_999
|
103
|
-
|
126
|
+
update_buffer(capture) if capture
|
104
127
|
@ready = true if !@ready && capture.include?('Appium REST http interface listener started')
|
105
128
|
rescue EOFError
|
106
129
|
out_err.delete stream
|
@@ -121,7 +144,6 @@ module Flaky
|
|
121
144
|
|
122
145
|
# Invoked inside a thread by `self.go`
|
123
146
|
def launch
|
124
|
-
@log = ''
|
125
147
|
self.end_all_nodes
|
126
148
|
@ready = false
|
127
149
|
appium_home = ENV['APPIUM_HOME']
|
@@ -135,7 +157,6 @@ module Flaky
|
|
135
157
|
end
|
136
158
|
|
137
159
|
def stop
|
138
|
-
@log = ''
|
139
160
|
# https://github.com/tmm1/pygments.rb/blob/master/lib/pygments/popen.rb
|
140
161
|
begin
|
141
162
|
Process.kill 'KILL', @pid
|
@@ -144,8 +165,6 @@ module Flaky
|
|
144
165
|
@pid = nil
|
145
166
|
self.end_all_nodes
|
146
167
|
self.end_all_instruments unless @android
|
147
|
-
|
148
|
-
@tail.stop if @tail
|
149
168
|
end
|
150
169
|
end # class Appium
|
151
170
|
end # module Flaky
|
data/lib/flaky/log.rb
CHANGED
@@ -47,18 +47,19 @@ div.grey { color: #666666; }
|
|
47
47
|
HTML
|
48
48
|
end
|
49
49
|
|
50
|
-
def write log_file, log
|
50
|
+
def write log_file, log, file_path=nil
|
51
51
|
# directory must exist
|
52
52
|
FileUtils.mkdir_p File.dirname log_file
|
53
53
|
# Pry & Awesome Print use the ruby objects to insert term colors.
|
54
54
|
# this can't be done with the raw text output.
|
55
55
|
|
56
56
|
# must escape for rendering HTML in the browser
|
57
|
-
log = EscapeUtils.escape_html log
|
57
|
+
log = EscapeUtils.escape_html log unless file_path
|
58
58
|
|
59
59
|
# [90mPOST /wd/hub/session [36m303 [90m6877ms - 9[0m
|
60
60
|
|
61
|
-
scan = StringScanner.new log
|
61
|
+
scan = StringScanner.new log || File.read(file_path)
|
62
|
+
File.delete(file_path) if file_path # delete tmp buffer file
|
62
63
|
|
63
64
|
new_log = '<div>'
|
64
65
|
|
@@ -78,21 +79,21 @@ div.grey { color: #666666; }
|
|
78
79
|
new_log += match[0..-1 - match_size]
|
79
80
|
new_log += '</div>'
|
80
81
|
|
81
|
-
found_number = match.match(color_rgx).to_a.last.gsub(/[^\d]/,'').to_i
|
82
|
+
found_number = match.match(color_rgx).to_a.last.gsub(/[^\d]/, '').to_i
|
82
83
|
|
83
84
|
# now make a new colored div
|
84
|
-
color = case(found_number)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
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
|
96
97
|
|
97
98
|
new_log += color
|
98
99
|
end
|
data/lib/flaky/run.rb
CHANGED
@@ -129,10 +129,10 @@ module Flaky
|
|
129
129
|
# html Ruby test log
|
130
130
|
Flaky.write log_file.name("#{postfix}.html"), log
|
131
131
|
|
132
|
-
# iOS simulator system log
|
133
|
-
File.open(log_file.name("#{postfix}.server.log.txt"), 'w') do |f|
|
134
|
-
|
135
|
-
end
|
132
|
+
# TODO: Get iOS simulator system log from appium
|
133
|
+
# File.open(log_file.name("#{postfix}.server.log.txt"), 'w') do |f|
|
134
|
+
# f.write appium.tail.out.readpartial(999_999_999)
|
135
|
+
# end
|
136
136
|
|
137
137
|
# adb logcat log
|
138
138
|
logcat = appium.logcat ? appium.logcat.stop : nil
|
@@ -141,7 +141,7 @@ module Flaky
|
|
141
141
|
end if logcat
|
142
142
|
|
143
143
|
# appium server log
|
144
|
-
Flaky.write log_file.name("#{postfix}.appium.html"), appium.
|
144
|
+
Flaky.write log_file.name("#{postfix}.appium.html"), nil, appium.flush_buffer
|
145
145
|
|
146
146
|
passed
|
147
147
|
end
|
data/readme.md
CHANGED
@@ -41,8 +41,7 @@ Run `flake auth` to automatically dismiss security dialogs.
|
|
41
41
|
#### For each test:
|
42
42
|
|
43
43
|
- iOS Simulator is closed
|
44
|
-
- All
|
44
|
+
- All `/Users/#{user}/Library/Application Support/iPhone Simulator/**/Applications/*` are removed
|
45
45
|
- Appium server is restarted
|
46
46
|
- [spec](https://github.com/bootstraponline/spec) test logs are saved and colored
|
47
47
|
- [Appium](https://github.com/appium/appium) logs are saved and colored
|
48
|
-
- iOS Simulator logs are saved `/var/log/system.log`
|
data/release_notes.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
#### v0.0.12 2013-11-04
|
2
|
+
|
3
|
+
- [d10c66d](https://github.com/appium/flaky/commit/d10c66dc5a882d54a64fe70709968d856a6a932e) Release 0.0.12
|
4
|
+
- [ec86209](https://github.com/appium/flaky/commit/ec862093b64a0319c1f9bc233858e3568acbfcc1) Move applescript to the flake auth command
|
5
|
+
- [983998a](https://github.com/appium/flaky/commit/983998a4fdcf5809b24d1c18b2f48ff67c9a70db) Revert "Work around OS X auth issue"
|
6
|
+
|
7
|
+
|
1
8
|
#### v0.0.11 2013-11-04
|
2
9
|
|
3
10
|
- [017a45f](https://github.com/appium/flaky/commit/017a45ffb32663570c6e6a2f0f7943a143edaf5f) Release 0.0.11
|
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.13
|
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-11-
|
11
|
+
date: 2013-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic_duration
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 1.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 1.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: posix-spawn
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|