flaky_stats 0.3.1 → 0.3.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
- SHA1:
3
- metadata.gz: '08c9beae7048ccc53a6e1673b07a48ef0ccd8da7'
4
- data.tar.gz: 54e7bb00efe140058ffa27428e04f0a6efb40aad
2
+ SHA256:
3
+ metadata.gz: 232a3564758ad1dfd02b9d00736784b72431d3b7f21380cad24258887cade075
4
+ data.tar.gz: 9ffc6f028ee1a9a7a6e80d9e236379de8225b0bf79aa36b834bd6819b083d5f4
5
5
  SHA512:
6
- metadata.gz: d6e05482698babe78a0654eb4a42bca067f516598122e6235e261095fcd9a70dc75eafe251bbaa0837a4f3ef1b0c3f59ec3a8d35ed8c2a379344225f78b741bc
7
- data.tar.gz: 60e561d14bde7288c0bc657cda87634c94ddd1f3d5185e0c0bc31e8a6be0fd789c82b8ac6b29a86b9c36c9dc31f6b26f82cdccc7c3385d846728bbfd23ba7dd1
6
+ metadata.gz: 68a51837ef9aa6b3ffdfa3bd12191334c2ac37eaf69d00cf66b353b245aa8ac17a6c1522a5914eb7d6994bcc6e21a528bd4fec57d4fcd127abcfa66ee3a9b927
7
+ data.tar.gz: 6178f95ce5bdc3d7fd23107526cb05586691282aa58464a58036daa5c652576d9f0d768e909cd974e4539571066b2cccbce71bb55ef9405e35d22ccc129d2547
data/.gitignore CHANGED
@@ -12,3 +12,5 @@
12
12
  .rspec_status
13
13
  *.gem
14
14
  /.byebug_history
15
+ /spec/files/failing_specs.log
16
+ /spec/files/flaky_tests.log.old
@@ -12,7 +12,9 @@ module FlakyStats
12
12
 
13
13
  def initialize(options)
14
14
  @failing_log = options[:failing_log]
15
- @logfile = options[:logfile]
15
+ @flaky_tests_log = options[:flaky_tests_log]
16
+ @failed_files = options[:failed_files] || []
17
+ @real_flaky_tests = options[:real_flaky_tests] || []
16
18
  end
17
19
 
18
20
  def display_error_summary()
@@ -22,7 +24,7 @@ module FlakyStats
22
24
 
23
25
  def calc_flaky_summary
24
26
  sum=Hash.new(0)
25
- CSV.foreach(@logfile) do |row|
27
+ CSV.foreach(@flaky_tests_log) do |row|
26
28
  sum[row[1]]+=row[3].to_i
27
29
  end
28
30
  return order_stats(sum)
@@ -36,8 +38,33 @@ module FlakyStats
36
38
  puts "\n"
37
39
  end
38
40
 
41
+ def display_current_flakies
42
+ heading "Flakies which passed in a single thread"
43
+
44
+ @real_flaky_tests.each do |flaky|
45
+ puts "#{flaky.split(",")[1]}:#{flaky.split(",")[2]}"
46
+ end
47
+ puts "\n"
48
+ end
49
+
50
+ # failed_files=[{:filename=>"./spec/integration/divisions/edit_divisions_spec.rb", :lineno=>26},...]
51
+ # real_flaky_tests = ["2019-10-24 15:30:45 +1100,./spec/integration/reports/activity_statement_spec.rb,13,1",...]
52
+ def filter_error_files(failed_files, real_flaky_tests)
53
+ real_flaky_tests.each do |flaky|
54
+ failed_files.reject!{|error| error[:filename] == flaky.split(",")[1]}
55
+ end
56
+ return failed_files
57
+ end
58
+
59
+ def display_failed_tests
60
+ heading "Failed tests"
61
+ real_errors = filter_error_files(@failed_files, @real_flaky_tests)
62
+ real_errors.each { |file| puts "#{file[:filename]}:#{file[:lineno]}"}
63
+ puts "\n"
64
+ end
65
+
39
66
  def rollover(days = DEFAULT_ROLLOVER_DAYS)
40
- lines = File.readlines(@logfile)
67
+ lines = File.readlines(@flaky_tests_log)
41
68
  lines.reject{|line|
42
69
  flaky_date = Time.parse(line.split(",")[0]).to_date
43
70
  cutoff = Date.today - days
@@ -47,7 +74,7 @@ module FlakyStats
47
74
 
48
75
  def rollover_and_write(options = {})
49
76
  days = options[:days] || DEFAULT_ROLLOVER_DAYS
50
- output = options[:output] || "#{@logfile}.tmp"
77
+ output = options[:output] || "#{@flaky_tests_log}.tmp"
51
78
 
52
79
  File.open(output, "w") {|file|
53
80
  rollover(days).each do |flaky|
@@ -56,8 +83,8 @@ module FlakyStats
56
83
  }
57
84
 
58
85
  # Overwrite log file.
59
- `cp #{@logfile} #{@logfile}.old`
60
- `cp #{@logfile}.tmp #{@logfile}`
86
+ `cp #{@flaky_tests_log} #{@flaky_tests_log}.old`
87
+ `cp #{@flaky_tests_log}.tmp #{@flaky_tests_log}`
61
88
  end
62
89
 
63
90
  def reject_low_flaky_tests(data)
@@ -1,3 +1,3 @@
1
1
  module FlakyStats
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -12,7 +12,7 @@ task :flaky_stats => :environment do |t|
12
12
  logfile = FlakyStats::LogFile.new(failing_log: FAILING_LOG, logfile: LOGFILE)
13
13
  failed_files = logfile.read_failing_log()
14
14
 
15
- # Run tests singularly
15
+ # Run tests singularly.
16
16
  flaky_tests = FlakyStats::FlakyTests.new(logfile: LOGFILE)
17
17
  real_flaky_tests = flaky_tests.run(failed_files)
18
18
 
@@ -20,9 +20,14 @@ task :flaky_stats => :environment do |t|
20
20
  logfile.write_flaky_stats(real_flaky_tests)
21
21
 
22
22
  # Display summaries
23
- summary = FlakyStats::Summary.new(failing_log: FAILING_LOG, logfile: LOGFILE)
23
+ summary = FlakyStats::Summary.new(failing_log: FAILING_LOG,
24
+ flaky_tests_log: LOGFILE,
25
+ failed_files: failed_files,
26
+ real_flaky_tests: real_flaky_tests)
24
27
  summary.display_error_summary()
25
28
  summary.display_flaky_summary()
29
+ summary.display_current_flakies()
30
+ summary.display_failed_tests()
26
31
 
27
32
  # Rollover logfile
28
33
  summary.rollover_and_write()
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flaky_stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Pope
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-13 00:00:00.000000000 Z
11
+ date: 2019-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -124,8 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
- rubyforge_project:
128
- rubygems_version: 2.6.14.1
127
+ rubygems_version: 3.0.3
129
128
  signing_key:
130
129
  specification_version: 4
131
130
  summary: Records flaky tests