flaky 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/flake +22 -13
- data/lib/flaky.rb +3 -2
- data/lib/flaky/appium.rb +5 -7
- data/lib/flaky/run.rb +18 -16
- data/lib/flaky/run/two_pass.rb +76 -0
- data/release_notes.md +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aec17b5e5abd6c3698c2b5888db960a6366f0d77
|
4
|
+
data.tar.gz: add4521290cec54027742252bc4afbfc4121f49c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d15d2721d5119b385fc06b96eb0791bbfbe99e1cfa2d9d98a4e2490bc93ca5d25427c89812b9aa79e98ac42e3a2630775f67b88a0dca4e5ce16bfd7e3df25a93
|
7
|
+
data.tar.gz: e243b5c9e240f198ce0ee8e1c1c86d3269b5f6af901f9e2ff33b1e92b19c247e9d5f08caba5112f74c22ecc0b2fc5e984c1781a1216e097162265ead0b27ce99
|
data/bin/flake
CHANGED
@@ -17,17 +17,29 @@ flake 3 ios files.txt
|
|
17
17
|
MSG
|
18
18
|
|
19
19
|
if ARGV && ARGV.length === 1 && ARGV.first === 'auth'
|
20
|
-
|
21
|
-
exit
|
22
|
-
elsif ARGV && ARGV.length === 3
|
23
|
-
# rake 3 ios files.txt
|
24
|
-
count = ARGV.first
|
25
|
-
os = ARGV[1]
|
26
|
-
file = ARGV.last
|
27
|
-
raise 'File must end in .txt' unless File.extname(ARGV.last).downcase == '.txt'
|
28
|
-
puts "Running select #{os} tests from file #{file} #{count}x"
|
29
|
-
Flaky.run_from_file count: count, os: os, file: file
|
20
|
+
Flaky::AppleScript.beat_security_agent
|
30
21
|
exit
|
22
|
+
elsif ARGV && ARGV.length === 3
|
23
|
+
if ARGV[0].to_i.kind_of?(Integer) && ARGV[1].to_i.kind_of?(Integer)
|
24
|
+
raise 'First pass must be 1' unless ARGV[0].to_i == 1
|
25
|
+
# flake 1 2 ios
|
26
|
+
pass_1 = ARGV[0] # 1
|
27
|
+
count = ARGV[1] # 2
|
28
|
+
os = ARGV[2] # ios
|
29
|
+
puts "Running all #{os} tests 1x #{count}x"
|
30
|
+
Flaky.two_pass count: count, os: os
|
31
|
+
exit
|
32
|
+
else
|
33
|
+
# rake 3 ios files.txt
|
34
|
+
count = ARGV.first
|
35
|
+
os = ARGV[1]
|
36
|
+
file = ARGV.last
|
37
|
+
raise 'File must end in .txt' unless File.extname(ARGV.last).downcase == '.txt'
|
38
|
+
puts "Running select #{os} tests from file #{file} #{count}x"
|
39
|
+
Flaky.run_from_file count: count, os: os, file: file
|
40
|
+
exit
|
41
|
+
end
|
42
|
+
|
31
43
|
else
|
32
44
|
unless ARGV && ARGV.length === 2
|
33
45
|
puts usage_string
|
@@ -35,9 +47,6 @@ else
|
|
35
47
|
end
|
36
48
|
end
|
37
49
|
|
38
|
-
require File.expand_path '../../lib/flaky', __FILE__
|
39
|
-
|
40
|
-
|
41
50
|
# flaky 1 ios[test_name]
|
42
51
|
|
43
52
|
count = ARGV.first
|
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-12-
|
12
|
+
VERSION = '0.0.20' unless defined? ::Flaky::VERSION
|
13
|
+
DATE = '2013-12-26' unless defined? ::Flaky::DATE
|
14
14
|
|
15
15
|
# require internal files
|
16
16
|
require_relative 'flaky/appium'
|
@@ -20,4 +20,5 @@ module Flaky
|
|
20
20
|
require_relative 'flaky/run/all_tests'
|
21
21
|
require_relative 'flaky/run/from_file'
|
22
22
|
require_relative 'flaky/run/one_test'
|
23
|
+
require_relative 'flaky/run/two_pass'
|
23
24
|
end
|
data/lib/flaky/appium.rb
CHANGED
@@ -68,7 +68,8 @@ module Flaky
|
|
68
68
|
|
69
69
|
def start
|
70
70
|
self.stop # stop existing process
|
71
|
-
@log = "/tmp/flaky/
|
71
|
+
@log = "/tmp/flaky/tmp_log"
|
72
|
+
File.delete(@log) if File.exists? @log
|
72
73
|
if @android
|
73
74
|
@droid.reset
|
74
75
|
else
|
@@ -94,19 +95,16 @@ module Flaky
|
|
94
95
|
|
95
96
|
def update_buffer data
|
96
97
|
@buffer += data
|
97
|
-
|
98
|
-
if @buffer.length >= 32_000
|
99
|
-
self.flush_buffer
|
100
|
-
end
|
98
|
+
self.flush_buffer
|
101
99
|
end
|
102
100
|
|
103
101
|
def flush_buffer
|
104
|
-
return
|
102
|
+
return @log if @buffer.nil? || @buffer.empty?
|
105
103
|
File.open(@log, 'a') do |f|
|
106
104
|
f.write @buffer
|
107
105
|
end
|
108
106
|
@buffer = ''
|
109
|
-
@log
|
107
|
+
@log
|
110
108
|
end
|
111
109
|
|
112
110
|
##
|
data/lib/flaky/run.rb
CHANGED
@@ -38,11 +38,11 @@ module Flaky
|
|
38
38
|
include Flaky::Color
|
39
39
|
attr_reader :tests, :result_dir, :result_file
|
40
40
|
|
41
|
-
def initialize
|
41
|
+
def initialize result_dir_postfix=''
|
42
42
|
@tests = {}
|
43
43
|
@start_time = Time.now
|
44
44
|
|
45
|
-
result_dir = '/tmp/flaky/'
|
45
|
+
result_dir = '/tmp/flaky/' + result_dir_postfix
|
46
46
|
# rm -rf result_dir
|
47
47
|
FileUtils.rm_rf result_dir
|
48
48
|
FileUtils.mkdir_p result_dir
|
@@ -80,9 +80,14 @@ module Flaky
|
|
80
80
|
out += "Failure (#{total_failure}):\n#{failure}\n" unless failure.empty?
|
81
81
|
out += "Success (#{total_success}):\n#{success}" unless success.empty?
|
82
82
|
|
83
|
-
|
83
|
+
time_now = Time.now
|
84
|
+
duration = time_now - @start_time
|
84
85
|
duration = ChronicDuration.output(duration.round) || '0s'
|
85
|
-
out += "\nFinished in #{duration}"
|
86
|
+
out += "\nFinished in #{duration}\n"
|
87
|
+
time_format = '%b %d %l:%M %P'
|
88
|
+
time_format2 = '%l:%M %P'
|
89
|
+
out += "#{@start_time.strftime(time_format)} -#{time_now.strftime(time_format2)}"
|
90
|
+
out += "\n--\n"
|
86
91
|
|
87
92
|
if save_file
|
88
93
|
File.open(@fail_file, 'w') do |f|
|
@@ -163,16 +168,12 @@ module Flaky
|
|
163
168
|
# appium server log
|
164
169
|
appium_server_path = log_file.name("#{postfix}.appium.html")
|
165
170
|
FileUtils.mkdir_p File.dirname(appium_server_path)
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
# todo: copy file instead of read & delete
|
171
|
-
if !tmp_file.nil? && !tmp_file.empty?
|
172
|
-
f.write File.read tmp_file
|
173
|
-
File.delete tmp_file
|
174
|
-
end
|
171
|
+
|
172
|
+
tmp_file = appium.flush_buffer
|
173
|
+
if !tmp_file.nil? && !tmp_file.empty?
|
174
|
+
FileUtils.copy_file tmp_file, appium_server_path
|
175
175
|
end
|
176
|
+
File.delete tmp_file if File.exists? tmp_file
|
176
177
|
end
|
177
178
|
|
178
179
|
passed
|
@@ -193,7 +194,7 @@ module Flaky
|
|
193
194
|
|
194
195
|
old_crash_files = []
|
195
196
|
# appium is nil when on sauce
|
196
|
-
if !sauce && appium
|
197
|
+
if !sauce && appium
|
197
198
|
collect_crashes old_crash_files
|
198
199
|
end
|
199
200
|
|
@@ -217,8 +218,9 @@ module Flaky
|
|
217
218
|
print " https://saucelabs.com/tests/#{File.read('/tmp/appium_lib_session').chomp}\n"
|
218
219
|
end
|
219
220
|
|
221
|
+
# androids adb may crash also and it ends up in the same location as iOS.
|
220
222
|
# appium is nil when running on Sauce
|
221
|
-
if !sauce && appium
|
223
|
+
if !sauce && appium
|
222
224
|
new_crash_files = []
|
223
225
|
collect_crashes new_crash_files
|
224
226
|
|
@@ -226,7 +228,7 @@ module Flaky
|
|
226
228
|
if new_crash_files.length > 0
|
227
229
|
File.open('/tmp/flaky/crashes.txt', 'a') do |f|
|
228
230
|
f.puts '--'
|
229
|
-
f.puts "Test: #{test_name} crashed on
|
231
|
+
f.puts "Test: #{test_name} crashed on #{appium.ios ? 'ios' : 'android'}:"
|
230
232
|
new_crash_files.each { |crash| f.puts crash }
|
231
233
|
f.puts '--'
|
232
234
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Flaky
|
3
|
+
def self.two_pass opts={}
|
4
|
+
raise 'Must pass :count and :os' unless opts && opts[:count] && opts[:os]
|
5
|
+
|
6
|
+
count = opts[:count].to_i
|
7
|
+
os = opts[:os]
|
8
|
+
|
9
|
+
raise ':count must be an int' unless count.kind_of?(Integer)
|
10
|
+
raise ':os must be a string' unless os.kind_of?(String)
|
11
|
+
|
12
|
+
count1 = 1
|
13
|
+
count2 = count
|
14
|
+
|
15
|
+
running_on_sauce = ENV['SAUCE_USERNAME'] ? true : false
|
16
|
+
FileUtils.rm_rf '/tmp/flaky'
|
17
|
+
result_dir_postfix = '1' # /tmp/flaky/1
|
18
|
+
flaky = Flaky::Run.new(result_dir_postfix)
|
19
|
+
appium = Appium.new unless running_on_sauce
|
20
|
+
|
21
|
+
current_dir = Dir.pwd
|
22
|
+
raise "Rakefile doesn't exist in #{current_dir}" unless File.exists?(File.join(current_dir, 'Rakefile'))
|
23
|
+
|
24
|
+
# run all tests once
|
25
|
+
Dir.glob(File.join current_dir, 'appium', os, 'specs', '**/*.rb') do |test_file|
|
26
|
+
file = test_file
|
27
|
+
name = File.basename file, '.*'
|
28
|
+
|
29
|
+
raise "#{test_file} does not exist." if file.empty?
|
30
|
+
|
31
|
+
test_name = file.sub(current_dir + '/appium/', '')
|
32
|
+
test_name = File.join(File.dirname(test_name), File.basename(test_name, '.*'))
|
33
|
+
|
34
|
+
count1.times do
|
35
|
+
File.open('/tmp/flaky/current.txt', 'a') { |f| f.puts "Running: #{test_name} on #{os}" }
|
36
|
+
appium.start unless running_on_sauce
|
37
|
+
run_cmd = "cd #{current_dir}; rake #{os.downcase}['#{name}']"
|
38
|
+
passed = flaky.execute(run_cmd: run_cmd, test_name: test_name, appium: appium, sauce: running_on_sauce)
|
39
|
+
break if passed # move onto the next test after one successful run
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
appium.stop unless running_on_sauce
|
44
|
+
flaky.report
|
45
|
+
|
46
|
+
# ---
|
47
|
+
|
48
|
+
# now run only the failures count2 times
|
49
|
+
fails = File.read(File.join('/tmp/flaky/', result_dir_postfix, 'fail.txt'))
|
50
|
+
|
51
|
+
result_dir_postfix = '2' # /tmp/flaky/1
|
52
|
+
flaky = Flaky::Run.new(result_dir_postfix)
|
53
|
+
appium = Appium.new unless running_on_sauce
|
54
|
+
|
55
|
+
fails.split("\n").each do |test_file|
|
56
|
+
file = test_file
|
57
|
+
name = File.basename file, '.*'
|
58
|
+
|
59
|
+
raise "#{test_file} does not exist." if file.empty?
|
60
|
+
|
61
|
+
test_name = file.sub(current_dir + '/appium/', '')
|
62
|
+
test_name = File.join(File.dirname(test_name), File.basename(test_name, '.*'))
|
63
|
+
|
64
|
+
count2.times do
|
65
|
+
File.open('/tmp/flaky/current.txt', 'a') { |f| f.puts "Running: #{test_name} on #{os}" }
|
66
|
+
appium.start unless running_on_sauce
|
67
|
+
run_cmd = "cd #{current_dir}; rake #{os.downcase}['#{name}']"
|
68
|
+
passed = flaky.execute run_cmd: run_cmd, test_name: test_name, appium: appium, sauce: running_on_sauce
|
69
|
+
break if passed # move onto the next test after one successful run
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
appium.stop unless running_on_sauce
|
74
|
+
flaky.report
|
75
|
+
end
|
76
|
+
end # module Flaky
|
data/release_notes.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
#### v0.0.19 2013-12-23
|
2
|
+
|
3
|
+
- [25630f1](https://github.com/appium/flaky/commit/25630f1d536715db8539c2d96adba15f5b35d5e4) Release 0.0.19
|
4
|
+
- [7006405](https://github.com/appium/flaky/commit/70064050daec3d94608063edad94e37a0066d4c5) Save failed test names to fail.txt
|
5
|
+
|
6
|
+
|
1
7
|
#### v0.0.18 2013-12-23
|
2
8
|
|
3
9
|
- [2843ce6](https://github.com/appium/flaky/commit/2843ce61c0e9dd6f0cebac2e2ab1486044f4ec57) Release 0.0.18
|
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.20
|
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-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic_duration
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- lib/flaky/run/all_tests.rb
|
76
76
|
- lib/flaky/run/from_file.rb
|
77
77
|
- lib/flaky/run/one_test.rb
|
78
|
+
- lib/flaky/run/two_pass.rb
|
78
79
|
- readme.md
|
79
80
|
- release_notes.md
|
80
81
|
- test/all_tests.rb
|