test-prof 0.7.5 → 0.9.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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +174 -107
  3. data/LICENSE.txt +1 -1
  4. data/README.md +9 -3
  5. data/lib/minitest/base_reporter.rb +18 -12
  6. data/lib/minitest/test_prof_plugin.rb +8 -8
  7. data/lib/test_prof/any_fixture.rb +3 -3
  8. data/lib/test_prof/before_all/adapters/active_record.rb +11 -0
  9. data/lib/test_prof/before_all/isolator.rb +18 -0
  10. data/lib/test_prof/before_all.rb +82 -2
  11. data/lib/test_prof/cops/rspec/aggregate_failures.rb +6 -6
  12. data/lib/test_prof/event_prof/custom_events/factory_create.rb +27 -45
  13. data/lib/test_prof/event_prof/custom_events/sidekiq_inline.rb +8 -38
  14. data/lib/test_prof/event_prof/custom_events/sidekiq_jobs.rb +7 -25
  15. data/lib/test_prof/event_prof/instrumentations/active_support.rb +1 -1
  16. data/lib/test_prof/event_prof/minitest.rb +4 -4
  17. data/lib/test_prof/event_prof/monitor.rb +45 -8
  18. data/lib/test_prof/event_prof/rspec.rb +4 -11
  19. data/lib/test_prof/event_prof.rb +6 -6
  20. data/lib/test_prof/ext/factory_bot_strategy.rb +24 -0
  21. data/lib/test_prof/factory_bot.rb +1 -1
  22. data/lib/test_prof/factory_default.rb +1 -1
  23. data/lib/test_prof/factory_doctor/fabrication_patch.rb +12 -0
  24. data/lib/test_prof/factory_doctor/factory_bot_patch.rb +5 -1
  25. data/lib/test_prof/factory_doctor/minitest.rb +4 -4
  26. data/lib/test_prof/factory_doctor/rspec.rb +15 -12
  27. data/lib/test_prof/factory_doctor.rb +29 -7
  28. data/lib/test_prof/factory_prof/factory_builders/fabrication.rb +1 -1
  29. data/lib/test_prof/factory_prof/factory_builders/factory_bot.rb +2 -17
  30. data/lib/test_prof/factory_prof/printers/flamegraph.rb +6 -2
  31. data/lib/test_prof/factory_prof/printers/simple.rb +8 -6
  32. data/lib/test_prof/factory_prof.rb +29 -15
  33. data/lib/test_prof/recipes/logging.rb +86 -21
  34. data/lib/test_prof/recipes/minitest/before_all.rb +3 -2
  35. data/lib/test_prof/recipes/minitest/sample.rb +5 -5
  36. data/lib/test_prof/recipes/rspec/any_fixture.rb +3 -1
  37. data/lib/test_prof/recipes/rspec/before_all.rb +12 -3
  38. data/lib/test_prof/recipes/rspec/factory_all_stub.rb +5 -1
  39. data/lib/test_prof/recipes/rspec/let_it_be.rb +27 -12
  40. data/lib/test_prof/rspec_dissect/rspec.rb +2 -6
  41. data/lib/test_prof/rspec_dissect.rb +13 -19
  42. data/lib/test_prof/rspec_stamp/parser.rb +1 -1
  43. data/lib/test_prof/rspec_stamp/rspec.rb +1 -1
  44. data/lib/test_prof/rspec_stamp.rb +14 -14
  45. data/lib/test_prof/ruby_prof/rspec.rb +2 -6
  46. data/lib/test_prof/ruby_prof.rb +32 -24
  47. data/lib/test_prof/stack_prof/rspec.rb +5 -6
  48. data/lib/test_prof/stack_prof.rb +23 -15
  49. data/lib/test_prof/tag_prof/printers/simple.rb +4 -4
  50. data/lib/test_prof/tag_prof/result.rb +3 -3
  51. data/lib/test_prof/tag_prof/rspec.rb +9 -14
  52. data/lib/test_prof/utils/html_builder.rb +1 -1
  53. data/lib/test_prof/utils/sized_ordered_set.rb +1 -1
  54. data/lib/test_prof/version.rb +1 -1
  55. data/lib/test_prof.rb +6 -12
  56. metadata +35 -14
@@ -126,7 +126,7 @@ module TestProf
126
126
  def parse_literal(expr)
127
127
  val = expr[1][1][1]
128
128
  val = val.to_sym if expr[0] == :symbol_literal ||
129
- expr[0] == :assoc_new
129
+ expr[0] == :assoc_new
130
130
  val
131
131
  end
132
132
 
@@ -53,7 +53,7 @@ module TestProf
53
53
  end
54
54
 
55
55
  # Register EventProf listener
56
- TestProf.activate('RSTAMP') do
56
+ TestProf.activate("RSTAMP") do
57
57
  RSpec.configure do |config|
58
58
  listener = nil
59
59
 
@@ -16,8 +16,8 @@ module TestProf
16
16
 
17
17
  def initialize
18
18
  @ignore_files = [%r{spec/support}]
19
- @dry_run = ENV['RSTAMP_DRY_RUN'] == '1'
20
- self.tags = ENV['RSTAMP']
19
+ @dry_run = ENV["RSTAMP_DRY_RUN"] == "1"
20
+ self.tags = ENV["RSTAMP"]
21
21
  end
22
22
 
23
23
  def dry_run?
@@ -26,10 +26,10 @@ module TestProf
26
26
 
27
27
  def tags=(val)
28
28
  @tags = if val.is_a?(String)
29
- parse_tags(val)
30
- else
31
- val
32
- end
29
+ parse_tags(val)
30
+ else
31
+ val
32
+ end
33
33
  end
34
34
 
35
35
  private
@@ -38,10 +38,10 @@ module TestProf
38
38
  str.split(/\s*,\s*/).each_with_object([]) do |tag, acc|
39
39
  k, v = tag.split(":")
40
40
  acc << if v.nil?
41
- k.to_sym
42
- else
43
- Hash[k.to_sym, v.to_sym]
44
- end
41
+ k.to_sym
42
+ else
43
+ Hash[k.to_sym, v.to_sym]
44
+ end
45
45
  end
46
46
  end
47
47
  end
@@ -129,7 +129,7 @@ module TestProf
129
129
  parsed = Parser.parse(code)
130
130
  return false unless parsed
131
131
 
132
- desc = parsed.desc_const || quote(parsed.desc || 'works')
132
+ desc = parsed.desc_const || quote(parsed.desc || "works")
133
133
 
134
134
  tags.each do |t|
135
135
  if t.is_a?(Hash)
@@ -156,9 +156,9 @@ module TestProf
156
156
  end
157
157
  end
158
158
 
159
- replacement = "\\1#{parsed.fname}#{need_parens ? '(' : ' '}"\
160
- "#{[desc, tags_str, htags_str].compact.join(', ')}"\
161
- "#{need_parens ? ') ' : ' '}\\3"
159
+ replacement = "\\1#{parsed.fname}#{need_parens ? "(" : " "}"\
160
+ "#{[desc, tags_str, htags_str].compact.join(", ")}"\
161
+ "#{need_parens ? ") " : " "}\\3"
162
162
 
163
163
  if config.dry_run?
164
164
  log :info, "Patched: #{example.sub(EXAMPLE_RXP, replacement)}"
@@ -6,8 +6,7 @@ module TestProf
6
6
  class Listener # :nodoc:
7
7
  NOTIFICATIONS = %i[
8
8
  example_started
9
- example_failed
10
- example_passed
9
+ example_finished
11
10
  ].freeze
12
11
 
13
12
  def example_started(notification)
@@ -18,14 +17,11 @@ module TestProf
18
17
 
19
18
  def example_finished(notification)
20
19
  return unless profile?(notification.example)
21
- notification.example.metadata[:rprof_report].dump(
20
+ notification.example.metadata[:rprof_report]&.dump(
22
21
  notification.example.full_description.parameterize
23
22
  )
24
23
  end
25
24
 
26
- alias example_passed example_finished
27
- alias example_failed example_finished
28
-
29
25
  private
30
26
 
31
27
  def profile?(example)
@@ -25,24 +25,24 @@ module TestProf
25
25
  # RubyProf configuration
26
26
  class Configuration
27
27
  PRINTERS = {
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'
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"
37
37
  }.freeze
38
38
 
39
39
  # Mapping from printer to report file extension
40
40
  # NOTE: txt is not included and considered default
41
41
  PRINTER_EXTENSTION = {
42
- 'graph_html' => 'html',
43
- 'dot' => 'dot',
44
- '.' => 'dot',
45
- 'call_stack' => 'html'
42
+ "graph_html" => "html",
43
+ "dot" => "dot",
44
+ "." => "dot",
45
+ "call_stack" => "html"
46
46
  }.freeze
47
47
 
48
48
  LOGFILE_PREFIX = "ruby-prof-report"
@@ -53,9 +53,9 @@ module TestProf
53
53
  :custom_exclusions
54
54
 
55
55
  def initialize
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
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
59
59
  @min_percent = 1
60
60
  @include_threads = false
61
61
  @exclude_common_methods = true
@@ -77,7 +77,7 @@ module TestProf
77
77
 
78
78
  # Returns an array of printer type (ID) and class.
79
79
  def resolve_printer
80
- return ['custom', printer] if printer.is_a?(Module)
80
+ return ["custom", printer] if printer.is_a?(Module)
81
81
 
82
82
  type = printer.to_s
83
83
 
@@ -113,7 +113,7 @@ module TestProf
113
113
  )
114
114
  else
115
115
  path = build_path name, printer_type
116
- File.open(path, 'w') do |f|
116
+ File.open(path, "w") do |f|
117
117
  printer_class.new(result).print(f, min_percent: config.min_percent)
118
118
  end
119
119
 
@@ -127,7 +127,7 @@ module TestProf
127
127
  def build_path(name, printer)
128
128
  TestProf.artifact_path(
129
129
  "#{RubyProf::Configuration::LOGFILE_PREFIX}-#{printer}-#{config.mode}-#{name}" \
130
- ".#{RubyProf::Configuration::PRINTER_EXTENSTION.fetch(printer, 'txt')}"
130
+ ".#{RubyProf::Configuration::PRINTER_EXTENSTION.fetch(printer, "txt")}"
131
131
  )
132
132
  end
133
133
 
@@ -158,13 +158,21 @@ module TestProf
158
158
 
159
159
  @locked = true
160
160
 
161
- log :info, "RubyProf enabled"
161
+ log :info, "RubyProf enabled globally"
162
162
 
163
163
  at_exit { report.dump("total") }
164
164
  end
165
165
 
166
166
  def profile
167
- return if locked?
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
+
168
176
  return unless init_ruby_prof
169
177
 
170
178
  options = {
@@ -204,7 +212,7 @@ module TestProf
204
212
  return @initialized if instance_variable_defined?(:@initialized)
205
213
  ENV["RUBY_PROF_MEASURE_MODE"] = config.mode.to_s
206
214
  @initialized = TestProf.require(
207
- 'ruby-prof',
215
+ "ruby-prof",
208
216
  <<~MSG
209
217
  Please, install 'ruby-prof' first:
210
218
  # Gemfile
@@ -214,7 +222,7 @@ module TestProf
214
222
  end
215
223
 
216
224
  def check_ruby_prof_version
217
- if Utils.verify_gem_version('ruby-prof', at_least: '0.17.0')
225
+ if Utils.verify_gem_version("ruby-prof", at_least: "0.17.0")
218
226
  true
219
227
  else
220
228
  log :error, <<~MGS
@@ -259,6 +267,6 @@ if TestProf.rspec?
259
267
  end
260
268
 
261
269
  # Hook to run RubyProf globally
262
- TestProf.activate('TEST_RUBY_PROF') do
270
+ TestProf.activate("TEST_RUBY_PROF") do
263
271
  TestProf::RubyProf.run
264
272
  end
@@ -6,24 +6,23 @@ module TestProf
6
6
  class Listener # :nodoc:
7
7
  NOTIFICATIONS = %i[
8
8
  example_started
9
- example_failed
10
- example_passed
9
+ example_finished
11
10
  ].freeze
12
11
 
13
12
  def example_started(notification)
14
- TestProf::StackProf.profile if profile?(notification.example)
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)
@@ -29,14 +29,14 @@ module TestProf
29
29
  attr_accessor :mode, :interval, :raw, :target, :format
30
30
 
31
31
  def initialize
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'
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"
35
35
  @format =
36
- if FORMATS.include?(ENV['TEST_STACK_PROF_FORMAT'])
37
- ENV['TEST_STACK_PROF_FORMAT']
36
+ if FORMATS.include?(ENV["TEST_STACK_PROF_FORMAT"])
37
+ ENV["TEST_STACK_PROF_FORMAT"]
38
38
  else
39
- 'html'
39
+ "html"
40
40
  end
41
41
  end
42
42
 
@@ -71,15 +71,23 @@ module TestProf
71
71
 
72
72
  @locked = true
73
73
 
74
- log :info, "StackProf enabled#{config.raw? ? ' (raw)' : ''}: " \
74
+ log :info, "StackProf#{config.raw? ? " (raw)" : ""} enabled globally: " \
75
75
  "mode – #{config.mode}, target – #{config.target}"
76
76
 
77
77
  at_exit { dump("total") } if config.suite?
78
78
  end
79
79
 
80
80
  def profile(name = nil)
81
- return if locked?
82
- return unless init_stack_prof
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
83
91
 
84
92
  options = {
85
93
  mode: config.mode,
@@ -115,7 +123,7 @@ module TestProf
115
123
 
116
124
  def build_path(name)
117
125
  TestProf.artifact_path(
118
- "stack-prof-report-#{config.mode}#{config.raw ? '-raw' : ''}-#{name}.dump"
126
+ "stack-prof-report-#{config.mode}#{config.raw ? "-raw" : ""}-#{name}.dump"
119
127
  )
120
128
  end
121
129
 
@@ -126,7 +134,7 @@ module TestProf
126
134
  def init_stack_prof
127
135
  return @initialized if instance_variable_defined?(:@initialized)
128
136
  @initialized = TestProf.require(
129
- 'stackprof',
137
+ "stackprof",
130
138
  <<~MSG
131
139
  Please, install 'stackprof' first:
132
140
  # Gemfile
@@ -136,7 +144,7 @@ module TestProf
136
144
  end
137
145
 
138
146
  def check_stack_prof_version
139
- if Utils.verify_gem_version('stackprof', at_least: '0.2.9')
147
+ if Utils.verify_gem_version("stackprof", at_least: "0.2.9")
140
148
  true
141
149
  else
142
150
  log :error, <<~MSG
@@ -147,7 +155,7 @@ module TestProf
147
155
  end
148
156
 
149
157
  def dump_html_report(path)
150
- html_path = path.gsub(/\.dump$/, '.html')
158
+ html_path = path.gsub(/\.dump$/, ".html")
151
159
 
152
160
  log :info, <<~MSG
153
161
  Run the following command to generate a flame graph report:
@@ -160,7 +168,7 @@ module TestProf
160
168
  report = ::StackProf::Report.new(
161
169
  Marshal.load(IO.binread(path)) # rubocop:disable Security/MarshalLoad
162
170
  )
163
- json_path = path.gsub(/\.dump$/, '.json')
171
+ json_path = path.gsub(/\.dump$/, ".json")
164
172
  File.write(json_path, JSON.generate(report.data))
165
173
 
166
174
  log :info, <<~MSG
@@ -174,6 +182,6 @@ end
174
182
  require "test_prof/stack_prof/rspec" if TestProf.rspec?
175
183
 
176
184
  # Hook to run StackProf globally
177
- TestProf.activate('TEST_STACK_PROF') do
185
+ TestProf.activate("TEST_STACK_PROF") do
178
186
  TestProf::StackProf.run
179
187
  end
@@ -20,8 +20,8 @@ module TestProf::TagProf
20
20
  header = []
21
21
 
22
22
  header << format(
23
- '%15s %12s ',
24
- result.tag, 'time'
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
- '%6s %6s %6s %12s',
40
- 'total', '%total', '%time', 'avg'
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] = { value: k, count: 0, time: 0.0 }
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
- example_failed
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['TAG_PROF_FORMAT'] == 'html' ? Printers::HTML : Printers::Simple
16
+ @printer = ENV["TAG_PROF_FORMAT"] == "html" ? Printers::HTML : Printers::Simple
18
17
 
19
18
  @result =
20
- if ENV['TAG_PROF_EVENT'].nil?
21
- Result.new ENV['TAG_PROF'].to_sym
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['TAG_PROF_EVENT'])
24
+ @events_profiler = EventProf.build(ENV["TAG_PROF_EVENT"])
26
25
 
27
- Result.new ENV['TAG_PROF'].to_sym, @events_profiler.events
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('TAG_PROF') do
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('TAG_PROF_EVENT') do
83
+ TestProf.activate("TAG_PROF_EVENT") do
89
84
  require "test_prof/event_prof"
90
85
 
91
- TestProf::EventProf::CustomEvents.activate_all(ENV['TAG_PROF_EVENT'])
86
+ TestProf::EventProf::CustomEvents.activate_all(ENV["TAG_PROF_EVENT"])
92
87
  end
@@ -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! '/**REPORT-DATA**/', data.to_json
12
+ template.sub! "/**REPORT-DATA**/", data.to_json
13
13
 
14
14
  outpath = TestProf.artifact_path(output)
15
15
  File.write(outpath, template)
@@ -26,7 +26,7 @@ module TestProf
26
26
 
27
27
  def <<(item)
28
28
  return if data.size == max_size &&
29
- comparator.call(data.last, item)
29
+ comparator.call(data.last, item)
30
30
 
31
31
  # Find an index of a smaller element
32
32
  index = data.bsearch_index { |x| !comparator.call(x, item) }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestProf
4
- VERSION = "0.7.5"
4
+ VERSION = "0.9.0"
5
5
  end
data/lib/test_prof.rb CHANGED
@@ -44,15 +44,9 @@ module TestProf
44
44
  defined?(Minitest)
45
45
  end
46
46
 
47
- # Avoid issues with wrong time due to monkey-patches (e.g. timecop)
48
- # See https://github.com/rspec/rspec-core/blob/v3.6.0/lib/rspec/core.rb#L147
49
- #
50
- # We also want to handle Timecop specificaly
51
- # See https://github.com/travisjeffery/timecop/blob/master/lib/timecop/time_extensions.rb#L11
52
- if Time.respond_to?(:now_without_mock_time)
53
- define_method(:now, &::Time.method(:now_without_mock_time))
54
- else
55
- define_method(:now, &::Time.method(:now))
47
+ # Returns the current process time
48
+ def now
49
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
56
50
  end
57
51
 
58
52
  # Require gem and shows a custom
@@ -114,13 +108,13 @@ module TestProf
114
108
  def with_timestamps(path)
115
109
  return path unless config.timestamps?
116
110
  timestamps = "-#{now.to_i}"
117
- "#{path.sub(/\.\w+$/, '')}#{timestamps}#{::File.extname(path)}"
111
+ "#{path.sub(/\.\w+$/, "")}#{timestamps}#{::File.extname(path)}"
118
112
  end
119
113
 
120
114
  def with_report_suffix(path)
121
115
  return path if config.report_suffix.nil?
122
116
 
123
- "#{path.sub(/\.\w+$/, '')}-#{config.report_suffix}#{::File.extname(path)}"
117
+ "#{path.sub(/\.\w+$/, "")}-#{config.report_suffix}#{::File.extname(path)}"
124
118
  end
125
119
 
126
120
  def notify_spring_detected
@@ -147,7 +141,7 @@ module TestProf
147
141
  @color = true
148
142
  @output_dir = "tmp/test_prof"
149
143
  @timestamps = false
150
- @report_suffix = ENV['TEST_PROF_REPORT']
144
+ @report_suffix = ENV["TEST_PROF_REPORT"]
151
145
  end
152
146
 
153
147
  def color?