test-prof 0.7.4 → 0.8.0
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/CHANGELOG.md +26 -2
- data/README.md +5 -3
- data/lib/minitest/base_reporter.rb +18 -12
- data/lib/minitest/test_prof_plugin.rb +8 -8
- data/lib/test_prof/any_fixture.rb +3 -3
- data/lib/test_prof/before_all/adapters/active_record.rb +12 -0
- data/lib/test_prof/before_all/isolator.rb +18 -0
- data/lib/test_prof/before_all.rb +9 -0
- data/lib/test_prof/cops/rspec/aggregate_failures.rb +6 -6
- data/lib/test_prof/event_prof/custom_events/factory_create.rb +1 -1
- data/lib/test_prof/event_prof/custom_events/sidekiq_inline.rb +2 -2
- data/lib/test_prof/event_prof/custom_events/sidekiq_jobs.rb +2 -2
- data/lib/test_prof/event_prof/instrumentations/active_support.rb +1 -1
- data/lib/test_prof/event_prof/minitest.rb +4 -4
- data/lib/test_prof/event_prof/rspec.rb +4 -11
- data/lib/test_prof/event_prof.rb +9 -8
- data/lib/test_prof/factory_bot.rb +1 -1
- data/lib/test_prof/factory_default.rb +1 -1
- data/lib/test_prof/factory_doctor/minitest.rb +4 -4
- data/lib/test_prof/factory_doctor/rspec.rb +7 -10
- data/lib/test_prof/factory_doctor.rb +5 -4
- data/lib/test_prof/factory_prof/factory_builders/fabrication.rb +1 -1
- data/lib/test_prof/factory_prof/factory_builders/factory_bot.rb +19 -1
- data/lib/test_prof/factory_prof/printers/flamegraph.rb +1 -1
- data/lib/test_prof/factory_prof.rb +6 -6
- data/lib/test_prof/logging.rb +1 -1
- data/lib/test_prof/recipes/logging.rb +89 -22
- data/lib/test_prof/recipes/minitest/before_all.rb +3 -2
- data/lib/test_prof/recipes/minitest/sample.rb +5 -5
- data/lib/test_prof/recipes/rspec/any_fixture.rb +3 -1
- data/lib/test_prof/recipes/rspec/before_all.rb +13 -6
- data/lib/test_prof/recipes/rspec/factory_all_stub.rb +5 -1
- data/lib/test_prof/recipes/rspec/let_it_be.rb +4 -16
- data/lib/test_prof/rspec_dissect/rspec.rb +2 -6
- data/lib/test_prof/rspec_dissect.rb +15 -20
- data/lib/test_prof/rspec_stamp/parser.rb +1 -1
- data/lib/test_prof/rspec_stamp/rspec.rb +1 -1
- data/lib/test_prof/rspec_stamp.rb +16 -15
- data/lib/test_prof/ruby_prof/rspec.rb +2 -6
- data/lib/test_prof/ruby_prof.rb +36 -26
- data/lib/test_prof/stack_prof/rspec.rb +5 -6
- data/lib/test_prof/stack_prof.rb +26 -16
- data/lib/test_prof/tag_prof/printers/simple.rb +4 -4
- data/lib/test_prof/tag_prof/result.rb +3 -3
- data/lib/test_prof/tag_prof/rspec.rb +9 -14
- data/lib/test_prof/tag_prof.rb +3 -1
- data/lib/test_prof/utils/html_builder.rb +1 -1
- data/lib/test_prof/utils/sized_ordered_set.rb +1 -1
- data/lib/test_prof/version.rb +1 -1
- data/lib/test_prof.rb +13 -3
- metadata +41 -13
data/lib/test_prof/ruby_prof.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "test_prof"
|
|
4
|
+
|
|
3
5
|
module TestProf
|
|
4
6
|
# RubyProf wrapper.
|
|
5
7
|
#
|
|
@@ -23,24 +25,24 @@ module TestProf
|
|
|
23
25
|
# RubyProf configuration
|
|
24
26
|
class Configuration
|
|
25
27
|
PRINTERS = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
"flat" => "FlatPrinter",
|
|
29
|
+
"flat_wln" => "FlatPrinterWithLineNumbers",
|
|
30
|
+
"graph" => "GraphPrinter",
|
|
31
|
+
"graph_html" => "GraphHtmlPrinter",
|
|
32
|
+
"dot" => "DotPrinter",
|
|
33
|
+
"." => "DotPrinter",
|
|
34
|
+
"call_stack" => "CallStackPrinter",
|
|
35
|
+
"call_tree" => "CallTreePrinter",
|
|
36
|
+
"multi" => "MultiPrinter"
|
|
35
37
|
}.freeze
|
|
36
38
|
|
|
37
39
|
# Mapping from printer to report file extension
|
|
38
40
|
# NOTE: txt is not included and considered default
|
|
39
41
|
PRINTER_EXTENSTION = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
"graph_html" => "html",
|
|
43
|
+
"dot" => "dot",
|
|
44
|
+
"." => "dot",
|
|
45
|
+
"call_stack" => "html"
|
|
44
46
|
}.freeze
|
|
45
47
|
|
|
46
48
|
LOGFILE_PREFIX = "ruby-prof-report"
|
|
@@ -51,9 +53,9 @@ module TestProf
|
|
|
51
53
|
:custom_exclusions
|
|
52
54
|
|
|
53
55
|
def initialize
|
|
54
|
-
@printer = ENV[
|
|
55
|
-
@printer ||= ENV.fetch(
|
|
56
|
-
@mode = ENV.fetch(
|
|
56
|
+
@printer = ENV["TEST_RUBY_PROF"].to_sym if PRINTERS.key?(ENV["TEST_RUBY_PROF"])
|
|
57
|
+
@printer ||= ENV.fetch("TEST_RUBY_PROF_PRINTER", :flat).to_sym
|
|
58
|
+
@mode = ENV.fetch("TEST_RUBY_PROF_MODE", :wall).to_sym
|
|
57
59
|
@min_percent = 1
|
|
58
60
|
@include_threads = false
|
|
59
61
|
@exclude_common_methods = true
|
|
@@ -75,7 +77,7 @@ module TestProf
|
|
|
75
77
|
|
|
76
78
|
# Returns an array of printer type (ID) and class.
|
|
77
79
|
def resolve_printer
|
|
78
|
-
return [
|
|
80
|
+
return ["custom", printer] if printer.is_a?(Module)
|
|
79
81
|
|
|
80
82
|
type = printer.to_s
|
|
81
83
|
|
|
@@ -111,7 +113,7 @@ module TestProf
|
|
|
111
113
|
)
|
|
112
114
|
else
|
|
113
115
|
path = build_path name, printer_type
|
|
114
|
-
File.open(path,
|
|
116
|
+
File.open(path, "w") do |f|
|
|
115
117
|
printer_class.new(result).print(f, min_percent: config.min_percent)
|
|
116
118
|
end
|
|
117
119
|
|
|
@@ -125,7 +127,7 @@ module TestProf
|
|
|
125
127
|
def build_path(name, printer)
|
|
126
128
|
TestProf.artifact_path(
|
|
127
129
|
"#{RubyProf::Configuration::LOGFILE_PREFIX}-#{printer}-#{config.mode}-#{name}" \
|
|
128
|
-
".#{RubyProf::Configuration::PRINTER_EXTENSTION.fetch(printer,
|
|
130
|
+
".#{RubyProf::Configuration::PRINTER_EXTENSTION.fetch(printer, "txt")}"
|
|
129
131
|
)
|
|
130
132
|
end
|
|
131
133
|
|
|
@@ -156,13 +158,21 @@ module TestProf
|
|
|
156
158
|
|
|
157
159
|
@locked = true
|
|
158
160
|
|
|
159
|
-
log :info, "RubyProf enabled"
|
|
161
|
+
log :info, "RubyProf enabled globally"
|
|
160
162
|
|
|
161
163
|
at_exit { report.dump("total") }
|
|
162
164
|
end
|
|
163
165
|
|
|
164
166
|
def profile
|
|
165
|
-
|
|
167
|
+
if locked?
|
|
168
|
+
log :warn, <<~MSG
|
|
169
|
+
RubyProf is activated globally, you cannot generate per-example report.
|
|
170
|
+
|
|
171
|
+
Make sure you haven's set the TEST_RUBY_PROF environmental variable.
|
|
172
|
+
MSG
|
|
173
|
+
return
|
|
174
|
+
end
|
|
175
|
+
|
|
166
176
|
return unless init_ruby_prof
|
|
167
177
|
|
|
168
178
|
options = {
|
|
@@ -202,7 +212,7 @@ module TestProf
|
|
|
202
212
|
return @initialized if instance_variable_defined?(:@initialized)
|
|
203
213
|
ENV["RUBY_PROF_MEASURE_MODE"] = config.mode.to_s
|
|
204
214
|
@initialized = TestProf.require(
|
|
205
|
-
|
|
215
|
+
"ruby-prof",
|
|
206
216
|
<<~MSG
|
|
207
217
|
Please, install 'ruby-prof' first:
|
|
208
218
|
# Gemfile
|
|
@@ -212,7 +222,7 @@ module TestProf
|
|
|
212
222
|
end
|
|
213
223
|
|
|
214
224
|
def check_ruby_prof_version
|
|
215
|
-
if Utils.verify_gem_version(
|
|
225
|
+
if Utils.verify_gem_version("ruby-prof", at_least: "0.17.0")
|
|
216
226
|
true
|
|
217
227
|
else
|
|
218
228
|
log :error, <<~MGS
|
|
@@ -223,7 +233,7 @@ module TestProf
|
|
|
223
233
|
end
|
|
224
234
|
|
|
225
235
|
def exclude_rspec_methods(profiler)
|
|
226
|
-
return unless
|
|
236
|
+
return unless TestProf.rspec?
|
|
227
237
|
|
|
228
238
|
RSpecExclusions.generate.each do |klass, mids|
|
|
229
239
|
profiler.exclude_methods!(klass, *mids)
|
|
@@ -251,12 +261,12 @@ module TestProf
|
|
|
251
261
|
end
|
|
252
262
|
end
|
|
253
263
|
|
|
254
|
-
if
|
|
264
|
+
if TestProf.rspec?
|
|
255
265
|
require "test_prof/ruby_prof/rspec"
|
|
256
266
|
require "test_prof/ruby_prof/rspec_exclusions"
|
|
257
267
|
end
|
|
258
268
|
|
|
259
269
|
# Hook to run RubyProf globally
|
|
260
|
-
TestProf.activate(
|
|
270
|
+
TestProf.activate("TEST_RUBY_PROF") do
|
|
261
271
|
TestProf::RubyProf.run
|
|
262
272
|
end
|
|
@@ -6,24 +6,23 @@ module TestProf
|
|
|
6
6
|
class Listener # :nodoc:
|
|
7
7
|
NOTIFICATIONS = %i[
|
|
8
8
|
example_started
|
|
9
|
-
|
|
10
|
-
example_passed
|
|
9
|
+
example_finished
|
|
11
10
|
].freeze
|
|
12
11
|
|
|
13
12
|
def example_started(notification)
|
|
14
|
-
|
|
13
|
+
return unless profile?(notification.example)
|
|
14
|
+
notification.example.metadata[:sprof_report] = TestProf::StackProf.profile
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def example_finished(notification)
|
|
18
18
|
return unless profile?(notification.example)
|
|
19
|
+
return unless notification.example.metadata[:sprof_report] == false
|
|
20
|
+
|
|
19
21
|
TestProf::StackProf.dump(
|
|
20
22
|
notification.example.full_description.parameterize
|
|
21
23
|
)
|
|
22
24
|
end
|
|
23
25
|
|
|
24
|
-
alias example_passed example_finished
|
|
25
|
-
alias example_failed example_finished
|
|
26
|
-
|
|
27
26
|
private
|
|
28
27
|
|
|
29
28
|
def profile?(example)
|
data/lib/test_prof/stack_prof.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "test_prof"
|
|
4
|
+
|
|
3
5
|
module TestProf
|
|
4
6
|
# StackProf wrapper.
|
|
5
7
|
#
|
|
@@ -27,14 +29,14 @@ module TestProf
|
|
|
27
29
|
attr_accessor :mode, :interval, :raw, :target, :format
|
|
28
30
|
|
|
29
31
|
def initialize
|
|
30
|
-
@mode = ENV.fetch(
|
|
31
|
-
@target = ENV[
|
|
32
|
-
@raw = ENV[
|
|
32
|
+
@mode = ENV.fetch("TEST_STACK_PROF_MODE", :wall).to_sym
|
|
33
|
+
@target = ENV["TEST_STACK_PROF"] == "boot" ? :boot : :suite
|
|
34
|
+
@raw = ENV["TEST_STACK_PROF_RAW"] != "0"
|
|
33
35
|
@format =
|
|
34
|
-
if FORMATS.include?(ENV[
|
|
35
|
-
ENV[
|
|
36
|
+
if FORMATS.include?(ENV["TEST_STACK_PROF_FORMAT"])
|
|
37
|
+
ENV["TEST_STACK_PROF_FORMAT"]
|
|
36
38
|
else
|
|
37
|
-
|
|
39
|
+
"html"
|
|
38
40
|
end
|
|
39
41
|
end
|
|
40
42
|
|
|
@@ -69,15 +71,23 @@ module TestProf
|
|
|
69
71
|
|
|
70
72
|
@locked = true
|
|
71
73
|
|
|
72
|
-
log :info, "StackProf
|
|
74
|
+
log :info, "StackProf#{config.raw? ? " (raw)" : ""} enabled globally: " \
|
|
73
75
|
"mode – #{config.mode}, target – #{config.target}"
|
|
74
76
|
|
|
75
77
|
at_exit { dump("total") } if config.suite?
|
|
76
78
|
end
|
|
77
79
|
|
|
78
80
|
def profile(name = nil)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
if locked?
|
|
82
|
+
log :warn, <<~MSG
|
|
83
|
+
StackProf is activated globally, you cannot generate per-example report.
|
|
84
|
+
|
|
85
|
+
Make sure you haven's set the TEST_STACK_PROF environmental variable.
|
|
86
|
+
MSG
|
|
87
|
+
return false
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
return false unless init_stack_prof
|
|
81
91
|
|
|
82
92
|
options = {
|
|
83
93
|
mode: config.mode,
|
|
@@ -113,7 +123,7 @@ module TestProf
|
|
|
113
123
|
|
|
114
124
|
def build_path(name)
|
|
115
125
|
TestProf.artifact_path(
|
|
116
|
-
"stack-prof-report-#{config.mode}#{config.raw ?
|
|
126
|
+
"stack-prof-report-#{config.mode}#{config.raw ? "-raw" : ""}-#{name}.dump"
|
|
117
127
|
)
|
|
118
128
|
end
|
|
119
129
|
|
|
@@ -124,7 +134,7 @@ module TestProf
|
|
|
124
134
|
def init_stack_prof
|
|
125
135
|
return @initialized if instance_variable_defined?(:@initialized)
|
|
126
136
|
@initialized = TestProf.require(
|
|
127
|
-
|
|
137
|
+
"stackprof",
|
|
128
138
|
<<~MSG
|
|
129
139
|
Please, install 'stackprof' first:
|
|
130
140
|
# Gemfile
|
|
@@ -134,7 +144,7 @@ module TestProf
|
|
|
134
144
|
end
|
|
135
145
|
|
|
136
146
|
def check_stack_prof_version
|
|
137
|
-
if Utils.verify_gem_version(
|
|
147
|
+
if Utils.verify_gem_version("stackprof", at_least: "0.2.9")
|
|
138
148
|
true
|
|
139
149
|
else
|
|
140
150
|
log :error, <<~MSG
|
|
@@ -145,7 +155,7 @@ module TestProf
|
|
|
145
155
|
end
|
|
146
156
|
|
|
147
157
|
def dump_html_report(path)
|
|
148
|
-
html_path = path.gsub(/\.dump$/,
|
|
158
|
+
html_path = path.gsub(/\.dump$/, ".html")
|
|
149
159
|
|
|
150
160
|
log :info, <<~MSG
|
|
151
161
|
Run the following command to generate a flame graph report:
|
|
@@ -158,7 +168,7 @@ module TestProf
|
|
|
158
168
|
report = ::StackProf::Report.new(
|
|
159
169
|
Marshal.load(IO.binread(path)) # rubocop:disable Security/MarshalLoad
|
|
160
170
|
)
|
|
161
|
-
json_path = path.gsub(/\.dump$/,
|
|
171
|
+
json_path = path.gsub(/\.dump$/, ".json")
|
|
162
172
|
File.write(json_path, JSON.generate(report.data))
|
|
163
173
|
|
|
164
174
|
log :info, <<~MSG
|
|
@@ -169,9 +179,9 @@ module TestProf
|
|
|
169
179
|
end
|
|
170
180
|
end
|
|
171
181
|
|
|
172
|
-
require "test_prof/stack_prof/rspec" if
|
|
182
|
+
require "test_prof/stack_prof/rspec" if TestProf.rspec?
|
|
173
183
|
|
|
174
184
|
# Hook to run StackProf globally
|
|
175
|
-
TestProf.activate(
|
|
185
|
+
TestProf.activate("TEST_STACK_PROF") do
|
|
176
186
|
TestProf::StackProf.run
|
|
177
187
|
end
|
|
@@ -20,8 +20,8 @@ module TestProf::TagProf
|
|
|
20
20
|
header = []
|
|
21
21
|
|
|
22
22
|
header << format(
|
|
23
|
-
|
|
24
|
-
result.tag,
|
|
23
|
+
"%15s %12s ",
|
|
24
|
+
result.tag, "time"
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
events_format = nil
|
|
@@ -36,8 +36,8 @@ module TestProf::TagProf
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
header << format(
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
"%6s %6s %6s %12s",
|
|
40
|
+
"total", "%total", "%time", "avg"
|
|
41
41
|
)
|
|
42
42
|
|
|
43
43
|
msgs << header.join
|
|
@@ -11,7 +11,7 @@ module TestProf
|
|
|
11
11
|
@events = events
|
|
12
12
|
|
|
13
13
|
@data = Hash.new do |h, k|
|
|
14
|
-
h[k] = {
|
|
14
|
+
h[k] = {value: k, count: 0, time: 0.0}
|
|
15
15
|
h[k].merge!(Hash[events.map { |event| [event, 0.0] }]) unless
|
|
16
16
|
events.empty?
|
|
17
17
|
h[k]
|
|
@@ -26,12 +26,12 @@ module TestProf
|
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
def to_json
|
|
29
|
+
def to_json(*args)
|
|
30
30
|
{
|
|
31
31
|
tag: tag,
|
|
32
32
|
data: data.values,
|
|
33
33
|
events: events
|
|
34
|
-
}.to_json
|
|
34
|
+
}.to_json(*args)
|
|
35
35
|
end
|
|
36
36
|
end
|
|
37
37
|
end
|
|
@@ -7,24 +7,23 @@ module TestProf
|
|
|
7
7
|
|
|
8
8
|
NOTIFICATIONS = %i[
|
|
9
9
|
example_started
|
|
10
|
-
|
|
11
|
-
example_passed
|
|
10
|
+
example_finished
|
|
12
11
|
].freeze
|
|
13
12
|
|
|
14
13
|
attr_reader :result, :printer
|
|
15
14
|
|
|
16
15
|
def initialize
|
|
17
|
-
@printer = ENV[
|
|
16
|
+
@printer = ENV["TAG_PROF_FORMAT"] == "html" ? Printers::HTML : Printers::Simple
|
|
18
17
|
|
|
19
18
|
@result =
|
|
20
|
-
if ENV[
|
|
21
|
-
Result.new ENV[
|
|
19
|
+
if ENV["TAG_PROF_EVENT"].nil?
|
|
20
|
+
Result.new ENV["TAG_PROF"].to_sym
|
|
22
21
|
else
|
|
23
22
|
require "test_prof/event_prof"
|
|
24
23
|
|
|
25
|
-
@events_profiler = EventProf.build(ENV[
|
|
24
|
+
@events_profiler = EventProf.build(ENV["TAG_PROF_EVENT"])
|
|
26
25
|
|
|
27
|
-
Result.new ENV[
|
|
26
|
+
Result.new ENV["TAG_PROF"].to_sym, @events_profiler.events
|
|
28
27
|
end
|
|
29
28
|
|
|
30
29
|
log :info, "TagProf enabled (#{result.tag})"
|
|
@@ -45,10 +44,6 @@ module TestProf
|
|
|
45
44
|
@events_profiler&.group_started(nil)
|
|
46
45
|
end
|
|
47
46
|
|
|
48
|
-
# NOTE: RSpec < 3.4.0 doesn't have example_finished event
|
|
49
|
-
alias example_passed example_finished
|
|
50
|
-
alias example_failed example_finished
|
|
51
|
-
|
|
52
47
|
def report
|
|
53
48
|
printer.dump(result)
|
|
54
49
|
end
|
|
@@ -69,7 +64,7 @@ module TestProf
|
|
|
69
64
|
end
|
|
70
65
|
|
|
71
66
|
# Register TagProf listener
|
|
72
|
-
TestProf.activate(
|
|
67
|
+
TestProf.activate("TAG_PROF") do
|
|
73
68
|
RSpec.configure do |config|
|
|
74
69
|
listener = nil
|
|
75
70
|
|
|
@@ -85,8 +80,8 @@ TestProf.activate('TAG_PROF') do
|
|
|
85
80
|
end
|
|
86
81
|
|
|
87
82
|
# Activate custom events
|
|
88
|
-
TestProf.activate(
|
|
83
|
+
TestProf.activate("TAG_PROF_EVENT") do
|
|
89
84
|
require "test_prof/event_prof"
|
|
90
85
|
|
|
91
|
-
TestProf::EventProf::CustomEvents.activate_all(ENV[
|
|
86
|
+
TestProf::EventProf::CustomEvents.activate_all(ENV["TAG_PROF_EVENT"])
|
|
92
87
|
end
|
data/lib/test_prof/tag_prof.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "test_prof"
|
|
4
|
+
|
|
3
5
|
require "test_prof/tag_prof/result"
|
|
4
6
|
require "test_prof/tag_prof/printers/simple"
|
|
5
7
|
require "test_prof/tag_prof/printers/html"
|
|
@@ -9,4 +11,4 @@ module TestProf
|
|
|
9
11
|
end
|
|
10
12
|
end
|
|
11
13
|
|
|
12
|
-
require "test_prof/tag_prof/rspec" if
|
|
14
|
+
require "test_prof/tag_prof/rspec" if TestProf.rspec?
|
|
@@ -9,7 +9,7 @@ module TestProf
|
|
|
9
9
|
class << self
|
|
10
10
|
def generate(data:, template:, output:)
|
|
11
11
|
template = File.read(TestProf.asset_path(template))
|
|
12
|
-
template.sub!
|
|
12
|
+
template.sub! "/**REPORT-DATA**/", data.to_json
|
|
13
13
|
|
|
14
14
|
outpath = TestProf.artifact_path(output)
|
|
15
15
|
File.write(outpath, template)
|
data/lib/test_prof/version.rb
CHANGED
data/lib/test_prof.rb
CHANGED
|
@@ -34,6 +34,16 @@ module TestProf
|
|
|
34
34
|
yield config
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
# Returns true if we're inside RSpec
|
|
38
|
+
def rspec?
|
|
39
|
+
defined?(RSpec::Core)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Returns true if we're inside Minitest
|
|
43
|
+
def minitest?
|
|
44
|
+
defined?(Minitest)
|
|
45
|
+
end
|
|
46
|
+
|
|
37
47
|
# Avoid issues with wrong time due to monkey-patches (e.g. timecop)
|
|
38
48
|
# See https://github.com/rspec/rspec-core/blob/v3.6.0/lib/rspec/core.rb#L147
|
|
39
49
|
#
|
|
@@ -104,13 +114,13 @@ module TestProf
|
|
|
104
114
|
def with_timestamps(path)
|
|
105
115
|
return path unless config.timestamps?
|
|
106
116
|
timestamps = "-#{now.to_i}"
|
|
107
|
-
"#{path.sub(/\.\w+$/,
|
|
117
|
+
"#{path.sub(/\.\w+$/, "")}#{timestamps}#{::File.extname(path)}"
|
|
108
118
|
end
|
|
109
119
|
|
|
110
120
|
def with_report_suffix(path)
|
|
111
121
|
return path if config.report_suffix.nil?
|
|
112
122
|
|
|
113
|
-
"#{path.sub(/\.\w+$/,
|
|
123
|
+
"#{path.sub(/\.\w+$/, "")}-#{config.report_suffix}#{::File.extname(path)}"
|
|
114
124
|
end
|
|
115
125
|
|
|
116
126
|
def notify_spring_detected
|
|
@@ -137,7 +147,7 @@ module TestProf
|
|
|
137
147
|
@color = true
|
|
138
148
|
@output_dir = "tmp/test_prof"
|
|
139
149
|
@timestamps = false
|
|
140
|
-
@report_suffix = ENV[
|
|
150
|
+
@report_suffix = ENV["TEST_PROF_REPORT"]
|
|
141
151
|
end
|
|
142
152
|
|
|
143
153
|
def color?
|
metadata
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: test-prof
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vladimir Dementyev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-04-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '1.10'
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.10'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
@@ -52,6 +52,20 @@ dependencies:
|
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '3.4'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: isolator
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0.6'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0.6'
|
|
55
69
|
- !ruby/object:Gem::Dependency
|
|
56
70
|
name: minitest
|
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -72,28 +86,42 @@ dependencies:
|
|
|
72
86
|
requirements:
|
|
73
87
|
- - "~>"
|
|
74
88
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 0.
|
|
89
|
+
version: 0.65.0
|
|
76
90
|
type: :development
|
|
77
91
|
prerelease: false
|
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
93
|
requirements:
|
|
80
94
|
- - "~>"
|
|
81
95
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 0.
|
|
96
|
+
version: 0.65.0
|
|
83
97
|
- !ruby/object:Gem::Dependency
|
|
84
98
|
name: rubocop-md
|
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
|
86
100
|
requirements:
|
|
87
|
-
- - "
|
|
101
|
+
- - "~>"
|
|
88
102
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: 0.
|
|
103
|
+
version: '0.2'
|
|
90
104
|
type: :development
|
|
91
105
|
prerelease: false
|
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
107
|
requirements:
|
|
94
|
-
- - "
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0.2'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: standard
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 0.0.36
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
95
123
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: 0.
|
|
124
|
+
version: 0.0.36
|
|
97
125
|
description: "\n Ruby applications tests profiling tools.\n\n Contains tools
|
|
98
126
|
to analyze factories usage, integrate with Ruby profilers,\n profile your examples
|
|
99
127
|
using ActiveSupport notifications (if any) and\n statically analyze your code
|
|
@@ -127,6 +155,7 @@ files:
|
|
|
127
155
|
- lib/test_prof/any_fixture/dsl.rb
|
|
128
156
|
- lib/test_prof/before_all.rb
|
|
129
157
|
- lib/test_prof/before_all/adapters/active_record.rb
|
|
158
|
+
- lib/test_prof/before_all/isolator.rb
|
|
130
159
|
- lib/test_prof/cops/rspec/aggregate_failures.rb
|
|
131
160
|
- lib/test_prof/event_prof.rb
|
|
132
161
|
- lib/test_prof/event_prof/custom_events.rb
|
|
@@ -206,15 +235,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
206
235
|
requirements:
|
|
207
236
|
- - ">="
|
|
208
237
|
- !ruby/object:Gem::Version
|
|
209
|
-
version: 2.
|
|
238
|
+
version: 2.4.0
|
|
210
239
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
240
|
requirements:
|
|
212
241
|
- - ">="
|
|
213
242
|
- !ruby/object:Gem::Version
|
|
214
243
|
version: '0'
|
|
215
244
|
requirements: []
|
|
216
|
-
|
|
217
|
-
rubygems_version: 2.7.6
|
|
245
|
+
rubygems_version: 3.0.2
|
|
218
246
|
signing_key:
|
|
219
247
|
specification_version: 4
|
|
220
248
|
summary: Ruby applications tests profiling tools
|