test-prof 0.7.5 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -2
  3. data/README.md +5 -3
  4. data/lib/minitest/base_reporter.rb +18 -12
  5. data/lib/minitest/test_prof_plugin.rb +8 -8
  6. data/lib/test_prof.rb +3 -3
  7. data/lib/test_prof/any_fixture.rb +3 -3
  8. data/lib/test_prof/before_all.rb +9 -0
  9. data/lib/test_prof/before_all/adapters/active_record.rb +12 -0
  10. data/lib/test_prof/before_all/isolator.rb +18 -0
  11. data/lib/test_prof/cops/rspec/aggregate_failures.rb +6 -6
  12. data/lib/test_prof/event_prof.rb +6 -6
  13. data/lib/test_prof/event_prof/custom_events/factory_create.rb +1 -1
  14. data/lib/test_prof/event_prof/custom_events/sidekiq_inline.rb +2 -2
  15. data/lib/test_prof/event_prof/custom_events/sidekiq_jobs.rb +2 -2
  16. data/lib/test_prof/event_prof/instrumentations/active_support.rb +1 -1
  17. data/lib/test_prof/event_prof/minitest.rb +4 -4
  18. data/lib/test_prof/event_prof/rspec.rb +4 -11
  19. data/lib/test_prof/factory_bot.rb +1 -1
  20. data/lib/test_prof/factory_default.rb +1 -1
  21. data/lib/test_prof/factory_doctor.rb +2 -2
  22. data/lib/test_prof/factory_doctor/minitest.rb +4 -4
  23. data/lib/test_prof/factory_doctor/rspec.rb +7 -10
  24. data/lib/test_prof/factory_prof.rb +6 -6
  25. data/lib/test_prof/factory_prof/factory_builders/fabrication.rb +1 -1
  26. data/lib/test_prof/factory_prof/printers/flamegraph.rb +1 -1
  27. data/lib/test_prof/recipes/logging.rb +86 -21
  28. data/lib/test_prof/recipes/minitest/before_all.rb +3 -2
  29. data/lib/test_prof/recipes/minitest/sample.rb +5 -5
  30. data/lib/test_prof/recipes/rspec/any_fixture.rb +3 -1
  31. data/lib/test_prof/recipes/rspec/before_all.rb +12 -3
  32. data/lib/test_prof/recipes/rspec/factory_all_stub.rb +5 -1
  33. data/lib/test_prof/recipes/rspec/let_it_be.rb +3 -13
  34. data/lib/test_prof/rspec_dissect.rb +13 -19
  35. data/lib/test_prof/rspec_dissect/rspec.rb +2 -6
  36. data/lib/test_prof/rspec_stamp.rb +14 -14
  37. data/lib/test_prof/rspec_stamp/parser.rb +1 -1
  38. data/lib/test_prof/rspec_stamp/rspec.rb +1 -1
  39. data/lib/test_prof/ruby_prof.rb +32 -24
  40. data/lib/test_prof/ruby_prof/rspec.rb +2 -6
  41. data/lib/test_prof/stack_prof.rb +23 -15
  42. data/lib/test_prof/stack_prof/rspec.rb +5 -6
  43. data/lib/test_prof/tag_prof/printers/simple.rb +4 -4
  44. data/lib/test_prof/tag_prof/result.rb +3 -3
  45. data/lib/test_prof/tag_prof/rspec.rb +9 -14
  46. data/lib/test_prof/utils/html_builder.rb +1 -1
  47. data/lib/test_prof/utils/sized_ordered_set.rb +1 -1
  48. data/lib/test_prof/version.rb +1 -1
  49. metadata +37 -9
@@ -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)
@@ -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.8.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-prof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
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-02-23 00:00:00.000000000 Z
11
+ date: 2019-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -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
@@ -84,16 +98,30 @@ dependencies:
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.1.1
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.1.1
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.3.0
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
- rubyforge_project:
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