rspec-tracer 0.6.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/README.md +333 -260
- data/lib/rspec_tracer/configuration.rb +12 -23
- data/lib/rspec_tracer/coverage_reporter.rb +7 -3
- data/lib/rspec_tracer/html_reporter/Rakefile +18 -0
- data/lib/rspec_tracer/remote_cache/Rakefile +38 -0
- data/lib/rspec_tracer/remote_cache/aws.rb +178 -0
- data/lib/rspec_tracer/remote_cache/cache.rb +36 -144
- data/lib/rspec_tracer/remote_cache/repo.rb +175 -0
- data/lib/rspec_tracer/remote_cache/validator.rb +52 -0
- data/lib/rspec_tracer/reporter.rb +61 -9
- data/lib/rspec_tracer/rspec_runner.rb +14 -4
- data/lib/rspec_tracer/runner.rb +19 -5
- data/lib/rspec_tracer/version.rb +1 -1
- data/lib/rspec_tracer.rb +17 -14
- metadata +28 -21
- data/lib/rspec_tracer/remote_cache/git.rb +0 -113
data/lib/rspec_tracer/version.rb
CHANGED
data/lib/rspec_tracer.rb
CHANGED
@@ -28,7 +28,7 @@ require_relative 'rspec_tracer/version'
|
|
28
28
|
|
29
29
|
module RSpecTracer
|
30
30
|
class << self
|
31
|
-
attr_accessor :running, :pid
|
31
|
+
attr_accessor :running, :pid, :no_examples
|
32
32
|
|
33
33
|
def start(&block)
|
34
34
|
RSpecTracer.running = false
|
@@ -74,7 +74,11 @@ module RSpecTracer
|
|
74
74
|
def at_exit_behavior
|
75
75
|
return unless RSpecTracer.pid == Process.pid && RSpecTracer.running
|
76
76
|
|
77
|
+
::Kernel.exit(1) if runner.incorrect_analysis?
|
78
|
+
|
77
79
|
run_exit_tasks
|
80
|
+
ensure
|
81
|
+
RSpecTracer.running = false
|
78
82
|
end
|
79
83
|
|
80
84
|
def start_example_trace
|
@@ -154,15 +158,11 @@ module RSpecTracer
|
|
154
158
|
def setup_coverage
|
155
159
|
@simplecov = defined?(SimpleCov) && SimpleCov.running
|
156
160
|
|
157
|
-
if simplecov?
|
158
|
-
# rubocop:disable Lint/EmptyBlock
|
159
|
-
SimpleCov.at_exit {}
|
160
|
-
# rubocop:enable Lint/EmptyBlock
|
161
|
-
else
|
162
|
-
require 'coverage'
|
161
|
+
return if simplecov?
|
163
162
|
|
164
|
-
|
165
|
-
|
163
|
+
require 'coverage'
|
164
|
+
|
165
|
+
::Coverage.start
|
166
166
|
end
|
167
167
|
|
168
168
|
def setup_trace_point
|
@@ -175,11 +175,13 @@ module RSpecTracer
|
|
175
175
|
end
|
176
176
|
|
177
177
|
def run_exit_tasks
|
178
|
-
|
178
|
+
if RSpecTracer.no_examples
|
179
|
+
puts 'Skipped reports generation since all examples were filtered out'
|
180
|
+
else
|
181
|
+
generate_reports
|
182
|
+
end
|
179
183
|
|
180
184
|
simplecov? ? run_simplecov_exit_task : run_coverage_exit_task
|
181
|
-
ensure
|
182
|
-
RSpecTracer.running = false
|
183
185
|
end
|
184
186
|
|
185
187
|
def generate_reports
|
@@ -224,12 +226,13 @@ module RSpecTracer
|
|
224
226
|
|
225
227
|
puts 'SimpleCov will now generate coverage report (<3 RSpec tracer)'
|
226
228
|
|
227
|
-
|
229
|
+
coverage_reporter.record_coverage if RSpecTracer.no_examples
|
228
230
|
end
|
229
231
|
|
230
232
|
def run_coverage_exit_task
|
231
233
|
starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
232
234
|
|
235
|
+
coverage_reporter.record_coverage if RSpecTracer.no_examples
|
233
236
|
coverage_reporter.generate_final_coverage
|
234
237
|
|
235
238
|
file_name = File.join(RSpecTracer.coverage_path, 'coverage.json')
|
@@ -250,7 +253,7 @@ module RSpecTracer
|
|
250
253
|
}
|
251
254
|
}
|
252
255
|
|
253
|
-
File.write(file_name, JSON.
|
256
|
+
File.write(file_name, JSON.pretty_generate(report))
|
254
257
|
end
|
255
258
|
|
256
259
|
def print_coverage_stats(file_name, elpased)
|
metadata
CHANGED
@@ -1,58 +1,60 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-tracer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abhimanyu Singh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docile
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.1.0
|
20
17
|
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: '1.1'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.1.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 1.1.0
|
30
27
|
- - "~>"
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: '1.1'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.1.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rspec-core
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - ">="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: 3.6.0
|
40
37
|
- - "~>"
|
41
38
|
- !ruby/object:Gem::Version
|
42
39
|
version: '3.6'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 3.6.0
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - ">="
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: 3.6.0
|
50
47
|
- - "~>"
|
51
48
|
- !ruby/object:Gem::Version
|
52
49
|
version: '3.6'
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 3.6.0
|
53
|
+
description: RSpec Tracer is a specs dependency analyzer, flaky tests detector, tests
|
54
|
+
accelerator, and coverage reporter tool for RSpec. It maintains a list of files
|
55
|
+
for each test, enabling itself to skip tests in the subsequent runs if none of the
|
56
|
+
dependent files are changed. It uses Ruby's built-in coverage library to keep track
|
57
|
+
of the coverage for each test
|
56
58
|
email:
|
57
59
|
- abhisinghabhimanyu@gmail.com
|
58
60
|
executables: []
|
@@ -69,6 +71,7 @@ files:
|
|
69
71
|
- lib/rspec_tracer/defaults.rb
|
70
72
|
- lib/rspec_tracer/example.rb
|
71
73
|
- lib/rspec_tracer/filter.rb
|
74
|
+
- lib/rspec_tracer/html_reporter/Rakefile
|
72
75
|
- lib/rspec_tracer/html_reporter/assets/javascripts/application.js
|
73
76
|
- lib/rspec_tracer/html_reporter/assets/javascripts/libraries/jquery.js
|
74
77
|
- lib/rspec_tracer/html_reporter/assets/javascripts/plugins/datatables.js
|
@@ -92,8 +95,11 @@ files:
|
|
92
95
|
- lib/rspec_tracer/html_reporter/views/files_dependency.erb
|
93
96
|
- lib/rspec_tracer/html_reporter/views/flaky_examples.erb
|
94
97
|
- lib/rspec_tracer/html_reporter/views/layout.erb
|
98
|
+
- lib/rspec_tracer/remote_cache/Rakefile
|
99
|
+
- lib/rspec_tracer/remote_cache/aws.rb
|
95
100
|
- lib/rspec_tracer/remote_cache/cache.rb
|
96
|
-
- lib/rspec_tracer/remote_cache/
|
101
|
+
- lib/rspec_tracer/remote_cache/repo.rb
|
102
|
+
- lib/rspec_tracer/remote_cache/validator.rb
|
97
103
|
- lib/rspec_tracer/reporter.rb
|
98
104
|
- lib/rspec_tracer/rspec_reporter.rb
|
99
105
|
- lib/rspec_tracer/rspec_runner.rb
|
@@ -107,7 +113,7 @@ licenses:
|
|
107
113
|
- MIT
|
108
114
|
metadata:
|
109
115
|
homepage_uri: https://github.com/avmnu-sng/rspec-tracer
|
110
|
-
source_code_uri: https://github.com/avmnu-sng/rspec-tracer/tree/v0.
|
116
|
+
source_code_uri: https://github.com/avmnu-sng/rspec-tracer/tree/v0.9.0
|
111
117
|
changelog_uri: https://github.com/avmnu-sng/rspec-tracer/blob/main/CHANGELOG.md
|
112
118
|
bug_tracker_uri: https://github.com/avmnu-sng/rspec-tracer/issues
|
113
119
|
post_install_message:
|
@@ -125,8 +131,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
131
|
- !ruby/object:Gem::Version
|
126
132
|
version: '0'
|
127
133
|
requirements: []
|
128
|
-
rubygems_version: 3.
|
134
|
+
rubygems_version: 3.2.26
|
129
135
|
signing_key:
|
130
136
|
specification_version: 4
|
131
|
-
summary: RSpec Tracer is a specs dependency
|
137
|
+
summary: RSpec Tracer is a specs dependency analyzer, flaky tests detector, tests
|
138
|
+
accelerator, and coverage reporter tool.
|
132
139
|
test_files: []
|
@@ -1,113 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RSpecTracer
|
4
|
-
module RemoteCache
|
5
|
-
class Git
|
6
|
-
class GitOperationError < StandardError; end
|
7
|
-
|
8
|
-
attr_reader :branch_ref, :ref_list
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
fetch_head_ref
|
12
|
-
fetch_branch_ref
|
13
|
-
end
|
14
|
-
|
15
|
-
def prepare_for_download
|
16
|
-
fetch_unreachable_refs
|
17
|
-
fetch_ancestry_refs
|
18
|
-
fetch_ordered_refs
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def fetch_head_ref
|
24
|
-
@head_ref = `git rev-parse HEAD`.chomp
|
25
|
-
|
26
|
-
raise GitOperationError, 'Could not find HEAD commit sha' unless $CHILD_STATUS.success?
|
27
|
-
end
|
28
|
-
|
29
|
-
def fetch_branch_ref
|
30
|
-
@merged_parents = []
|
31
|
-
@ignored_refs = []
|
32
|
-
|
33
|
-
unless merged?
|
34
|
-
@branch_ref = @head_ref
|
35
|
-
|
36
|
-
return
|
37
|
-
end
|
38
|
-
|
39
|
-
@ignored_refs << @head_ref
|
40
|
-
|
41
|
-
fetch_merged_parents
|
42
|
-
fetch_merged_branch_ref
|
43
|
-
end
|
44
|
-
|
45
|
-
def merged?
|
46
|
-
system('git', 'rev-parse', 'HEAD^2', out: File::NULL, err: File::NULL)
|
47
|
-
end
|
48
|
-
|
49
|
-
def fetch_merged_parents
|
50
|
-
first_parent = `git rev-parse HEAD^1`.chomp
|
51
|
-
@merged_parents << first_parent if $CHILD_STATUS.success?
|
52
|
-
|
53
|
-
second_parent = `git rev-parse HEAD^2`.chomp
|
54
|
-
@merged_parents << second_parent if $CHILD_STATUS.success?
|
55
|
-
|
56
|
-
raise GitOperationError, 'Could not find merged commit parents' if @merged_parents.length != 2
|
57
|
-
end
|
58
|
-
|
59
|
-
def fetch_merged_branch_ref
|
60
|
-
@origin_head_ref = `git rev-parse origin/HEAD`.chomp
|
61
|
-
@branch_ref = nil
|
62
|
-
|
63
|
-
if @merged_parents.first != @origin_head_ref
|
64
|
-
@branch_ref = @head_ref
|
65
|
-
@ignored_refs = []
|
66
|
-
|
67
|
-
return
|
68
|
-
end
|
69
|
-
|
70
|
-
@branch_ref = @merged_parents.last
|
71
|
-
@ignored_refs = @ignored_refs.to_set | `git rev-list #{@branch_ref}..origin/HEAD`.chomp.split
|
72
|
-
|
73
|
-
raise GitOperationError, 'Could not find ignored refs' unless $CHILD_STATUS.success?
|
74
|
-
end
|
75
|
-
|
76
|
-
def fetch_unreachable_refs
|
77
|
-
command = <<-COMMAND.strip.gsub(/\s+/, ' ')
|
78
|
-
git fsck
|
79
|
-
--no-progress
|
80
|
-
--unreachable
|
81
|
-
--connectivity-only #{@branch_ref}
|
82
|
-
| awk '/commit/ { print $3 }'
|
83
|
-
| head -n 25
|
84
|
-
COMMAND
|
85
|
-
|
86
|
-
@unreachable_refs = `#{command}`.chomp.split
|
87
|
-
|
88
|
-
raise GitOperationError, 'Could not find unreachable refs' unless $CHILD_STATUS.success?
|
89
|
-
end
|
90
|
-
|
91
|
-
def fetch_ancestry_refs
|
92
|
-
@ancestry_refs = `git rev-list --max-count=25 #{@branch_ref}`.chomp.split
|
93
|
-
|
94
|
-
raise GitOperationError, 'Could not find ancestry refs' unless $CHILD_STATUS.success?
|
95
|
-
end
|
96
|
-
|
97
|
-
def fetch_ordered_refs
|
98
|
-
unordered_refs = (@unreachable_refs.to_set | @ancestry_refs) - @ignored_refs
|
99
|
-
|
100
|
-
command = <<-COMMAND.strip.gsub(/\s+/, ' ')
|
101
|
-
git rev-list
|
102
|
-
--topo-order
|
103
|
-
--no-walk=sorted
|
104
|
-
#{unordered_refs.to_a.join(' ')}
|
105
|
-
COMMAND
|
106
|
-
|
107
|
-
@ref_list = `#{command}`.chomp.split
|
108
|
-
|
109
|
-
raise GitOperationError, 'Could not find refs to download cache' unless $CHILD_STATUS.success?
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|