test-prof 1.0.2 → 1.0.3

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
2
  SHA256:
3
- metadata.gz: 4d33f8b474fb308b33c253a2213cc86f192c976b9b6289e73511f2d4f5b9dc5f
4
- data.tar.gz: c150fd5213ba2aefa34f3d56c75bcb6d69d7172a281d090b1d14a7a5b9f389d1
3
+ metadata.gz: c3ea5b7078b12209f32a60554f25acffccd184bdf852ebfe14cad161ded2c180
4
+ data.tar.gz: 34e61ec6d58e5688b441ea09c1be524ae563f9ca82f334541c3f2c3197787cbd
5
5
  SHA512:
6
- metadata.gz: 18295b823f620a143a867e183ccf203f08b08a9e8e344ed1b95c076a0cfe98b84688e090cb8cbe8a33f60d17b249a1828afb57d7bdeba962207f253f4f6b4e5a
7
- data.tar.gz: 86ff82bdd8f3f6a17f15d44234034c71847c2a459d907d8c6acad11c52bcfac98b8fe60b584bbcb7c5b73ac718c6e90e17b6c9fc1741d19d34e8bcebf01f5310
6
+ metadata.gz: d866bfe03650d81cb2dd5b698b5de5703a8fa505c7c8d0b0e4283b8130eb774ac43c5cca6a750fef6f8342acdec7e518613489e898fd354f133e1793df833e45
7
+ data.tar.gz: cf92cef8973837d2e09ff3bcc4449fb0675ebfca3f10fc75a314f10d885ad92aaae2f6fac0cd99e7250eb57985208e6d6f53b88d101f177709a172b8fcae1815
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master (unrealeased)
4
4
 
5
+ ## 1.0.3 (2021-04-30)
6
+
7
+ - Minor fixes.
8
+
5
9
  ## 1.0.2 (2021-02-26)
6
10
 
7
11
  - Make `before_all(setup_fixtures: true)` compatible with Rails 6.1. ([@palkan][])
data/README.md CHANGED
@@ -32,7 +32,7 @@ TestProf toolbox aims to help you identify bottlenecks in your test suite. It co
32
32
  📑 [Documentation](https://test-prof.evilmartians.io)
33
33
 
34
34
  <p align="center">
35
- <a href="http://bit.ly/test-prof-map">
35
+ <a href="http://bit.ly/test-prof-map-v1">
36
36
  <img src="./docs/assets/images/coggle.png" alt="TestProf map" width="738">
37
37
  </a>
38
38
  </p>
data/lib/test_prof.rb CHANGED
@@ -161,5 +161,5 @@ require "test_prof/factory_doctor"
161
161
  require "test_prof/factory_prof"
162
162
  require "test_prof/rspec_stamp"
163
163
  require "test_prof/tag_prof"
164
- require "test_prof/rspec_dissect"
164
+ require "test_prof/rspec_dissect" if TestProf.rspec?
165
165
  require "test_prof/factory_all_stub"
@@ -6,7 +6,7 @@ require "test_prof/any_fixture/dump"
6
6
  module TestProf
7
7
  # Make DB fixtures from blocks.
8
8
  module AnyFixture
9
- INSERT_RXP = /^INSERT INTO ([\S]+)/.freeze
9
+ INSERT_RXP = /^INSERT INTO (\S+)/.freeze
10
10
 
11
11
  using FloatDuration
12
12
 
@@ -16,8 +16,8 @@ module TestProf
16
16
  :import_dump_via_cli, :dump_matching_queries, :force_matching_dumps
17
17
  attr_reader :default_dump_watch_paths
18
18
 
19
- alias reporting_enabled? reporting_enabled
20
- alias import_dump_via_cli? import_dump_via_cli
19
+ alias_method :reporting_enabled?, :reporting_enabled
20
+ alias_method :import_dump_via_cli?, :import_dump_via_cli
21
21
 
22
22
  def initialize
23
23
  @reporting_enabled = ENV["ANYFIXTURE_REPORT"] == "1"
@@ -42,7 +42,7 @@ module TestProf
42
42
  end
43
43
 
44
44
  def before_dump(&block)
45
- if block_given?
45
+ if block
46
46
  @before_dump << block
47
47
  else
48
48
  @before_dump
@@ -50,7 +50,7 @@ module TestProf
50
50
  end
51
51
 
52
52
  def after_dump(&block)
53
- if block_given?
53
+ if block
54
54
  @after_dump << block
55
55
  else
56
56
  @after_dump
@@ -112,7 +112,7 @@ module TestProf
112
112
  config.reporting_enabled
113
113
  end
114
114
 
115
- alias reporting_enabled? reporting_enabled
115
+ alias_method :reporting_enabled?, :reporting_enabled
116
116
 
117
117
  # Register a block of code as a fixture,
118
118
  # returns the result of the block execution
@@ -6,9 +6,9 @@ require "set"
6
6
 
7
7
  module TestProf
8
8
  module AnyFixture
9
- MODIFY_RXP = /^(INSERT INTO|UPDATE|DELETE FROM) ([\S]+)/i.freeze
10
- ANY_FIXTURE_RXP = /(\/\*|\-\-).*\bany_fixture:dump/.freeze
11
- ANY_FIXTURE_IGNORE_RXP = /(\/\*|\-\-).*\bany_fixture:ignore/.freeze
9
+ MODIFY_RXP = /^(INSERT INTO|UPDATE|DELETE FROM) (\S+)/i.freeze
10
+ ANY_FIXTURE_RXP = /(\/\*|--).*\bany_fixture:dump/.freeze
11
+ ANY_FIXTURE_IGNORE_RXP = /(\/\*|--).*\bany_fixture:ignore/.freeze
12
12
 
13
13
  using(Module.new do
14
14
  refine Object do
@@ -111,7 +111,7 @@ module TestProf
111
111
  end
112
112
 
113
113
  attr_reader :name, :digest, :path, :subscriber, :success
114
- alias success? success
114
+ alias_method :success?, :success
115
115
 
116
116
  def initialize(name, watch: [], cache_key: nil)
117
117
  @name = name
@@ -79,7 +79,7 @@ module TestProf
79
79
  # config.before(:rollback) { ... }
80
80
  def before(type, &block)
81
81
  validate_hook_type!(type)
82
- hooks[type].before << block if block_given?
82
+ hooks[type].before << block if block
83
83
  end
84
84
 
85
85
  # Add `after` hook for `begin` or
@@ -88,7 +88,7 @@ module TestProf
88
88
  # config.after(:begin) { ... }
89
89
  def after(type, &block)
90
90
  validate_hook_type!(type)
91
- hooks[type].after << block if block_given?
91
+ hooks[type].after << block if block
92
92
  end
93
93
 
94
94
  def run_hooks(type) # :nodoc:
@@ -6,7 +6,7 @@ module TestProf
6
6
  module CustomEvents
7
7
  class << self
8
8
  def register(event, &block)
9
- raise ArgumentError, "Block is required!" unless block_given?
9
+ raise ArgumentError, "Block is required!" unless block
10
10
  registrations[event] = block
11
11
  end
12
12
 
@@ -26,7 +26,7 @@ module TestProf::EventProf
26
26
 
27
27
  class << self
28
28
  def subscribe(event, &block)
29
- raise ArgumentError, "Block is required!" unless block_given?
29
+ raise ArgumentError, "Block is required!" unless block
30
30
 
31
31
  ::ActiveSupport::Notifications.subscribe(event, Subscriber.new(block))
32
32
  end
@@ -6,7 +6,7 @@ module TestProf
6
6
  attr_reader :event, :total_count, :total_time, :rank_by, :top_count, :per_example,
7
7
  :time, :count, :example_time, :example_count, :absolute_run_time
8
8
 
9
- alias per_example? per_example
9
+ alias_method :per_example?, :per_example
10
10
 
11
11
  def initialize(event:, instrumenter:, rank_by: :time, top_count: 5, per_example: false)
12
12
  @event = event
@@ -88,14 +88,13 @@ module TestProf
88
88
  end
89
89
 
90
90
  def results
91
- results = {
91
+ {
92
92
  groups: @groups.to_a
93
93
  }.tap do |data|
94
94
  next unless per_example?
95
95
 
96
96
  data[:examples] = @examples.to_a
97
97
  end
98
- results
99
98
  end
100
99
 
101
100
  def take_time(start_ts)
@@ -130,7 +129,7 @@ module TestProf
130
129
  end
131
130
 
132
131
  def each(&block)
133
- if block_given?
132
+ if block
134
133
  @profilers.each(&block)
135
134
  else
136
135
  @profilers.each
@@ -10,7 +10,7 @@ module TestProf
10
10
  # flamegraphs or detect most popular factories
11
11
  module FactoryProf
12
12
  FACTORY_BUILDERS = [FactoryBuilders::FactoryBot,
13
- FactoryBuilders::Fabrication].freeze
13
+ FactoryBuilders::Fabrication].freeze
14
14
 
15
15
  # FactoryProf configuration
16
16
  class Configuration
@@ -12,7 +12,7 @@ module TestProf
12
12
  def logger
13
13
  return @logger if instance_variable_defined?(:@logger)
14
14
 
15
- @logger = Logger.new(STDOUT)
15
+ @logger = Logger.new($stdout)
16
16
  end
17
17
 
18
18
  def ar_loggables
@@ -11,8 +11,8 @@ module TestProf
11
11
  attr_reader :active, :block, :captured_ivars, :teardown_block, :current_test_object,
12
12
  :setup_fixtures
13
13
 
14
- alias active? active
15
- alias setup_fixtures? setup_fixtures
14
+ alias_method :active?, :active
15
+ alias_method :setup_fixtures?, :setup_fixtures
16
16
 
17
17
  def initialize(setup_fixtures: false, &block)
18
18
  @setup_fixtures = setup_fixtures
@@ -7,7 +7,7 @@ module TestProf
7
7
  # Helper to wrap the whole example group into a transaction
8
8
  module RSpec
9
9
  def before_all(setup_fixtures: BeforeAll.config.setup_fixtures, &block)
10
- raise ArgumentError, "Block is required!" unless block_given?
10
+ raise ArgumentError, "Block is required!" unless block
11
11
 
12
12
  if within_before_all?
13
13
  before(:all) do
@@ -55,9 +55,7 @@ module TestProf
55
55
  end
56
56
 
57
57
  def module_for(group)
58
- modules[group] ||= begin
59
- Module.new.tap { |mod| group.prepend(mod) }
60
- end
58
+ modules[group] ||= Module.new.tap { |mod| group.prepend(mod) }
61
59
  end
62
60
 
63
61
  private
@@ -91,8 +89,7 @@ module TestProf
91
89
  initializer = proc do
92
90
  instance_variable_set(:"#{TestProf::LetItBe::PREFIX}#{identifier}", instance_exec(&block))
93
91
  rescue FrozenError => e
94
- e.message << TestProf::LetItBe::FROZEN_ERROR_HINT
95
- raise
92
+ raise e.exception("#{e.message}#{TestProf::LetItBe::FROZEN_ERROR_HINT}")
96
93
  end
97
94
 
98
95
  default_options = LetItBe.config.default_modifiers.dup
@@ -243,7 +240,7 @@ end
243
240
  RSpec.configure do |config|
244
241
  config.after(:example) do |example|
245
242
  if example.exception&.is_a?(FrozenError)
246
- example.exception.message << TestProf::LetItBe::FROZEN_ERROR_HINT
243
+ example.exception.message << TestProf::LetItBe::FROZEN_ERROR_HINT unless example.exception.message.frozen?
247
244
  end
248
245
  end
249
246
  end
@@ -38,7 +38,7 @@ module TestProf
38
38
  attr_accessor :top_count, :let_stats_enabled,
39
39
  :let_top_count
40
40
 
41
- alias let_stats_enabled? let_stats_enabled
41
+ alias_method :let_stats_enabled?, :let_stats_enabled
42
42
 
43
43
  attr_reader :mode
44
44
 
@@ -139,7 +139,7 @@ end
139
139
 
140
140
  require "test_prof/rspec_dissect/collectors/let"
141
141
  require "test_prof/rspec_dissect/collectors/before"
142
- require "test_prof/rspec_dissect/rspec" if TestProf.rspec?
142
+ require "test_prof/rspec_dissect/rspec"
143
143
 
144
144
  TestProf.activate("RD_PROF") do
145
145
  TestProf::RSpecDissect.init
@@ -239,16 +239,18 @@ module TestProf
239
239
  end
240
240
 
241
241
  def exclude_common_methods(profiler)
242
- profiler.exclude_methods!(
243
- TSort,
244
- :tsort_each
245
- )
242
+ if defined?(TSort)
243
+ profiler.exclude_methods!(
244
+ TSort,
245
+ :tsort_each
246
+ )
246
247
 
247
- profiler.exclude_methods!(
248
- TSort.singleton_class,
249
- :tsort_each, :each_strongly_connected_component,
250
- :each_strongly_connected_component_from
251
- )
248
+ profiler.exclude_methods!(
249
+ TSort.singleton_class,
250
+ :tsort_each, :each_strongly_connected_component,
251
+ :each_strongly_connected_component_from
252
+ )
253
+ end
252
254
 
253
255
  profiler.exclude_methods!(
254
256
  BasicObject,
@@ -14,7 +14,7 @@ module TestProf
14
14
  def initialize(max_size, sort_by: nil, &block)
15
15
  @max_size = max_size
16
16
  @comparator =
17
- if block_given?
17
+ if block
18
18
  block
19
19
  elsif !sort_by.nil?
20
20
  ->(x, y) { x[sort_by] >= y[sort_by] }
@@ -42,7 +42,7 @@ module TestProf
42
42
  end
43
43
 
44
44
  def each(&block)
45
- if block_given?
45
+ if block
46
46
  data.each(&block)
47
47
  else
48
48
  data.each
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestProf
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.3"
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: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-26 00:00:00.000000000 Z
11
+ date: 2021-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -219,7 +219,7 @@ metadata:
219
219
  documentation_uri: https://test-prof.evilmartians.io/
220
220
  homepage_uri: https://test-prof.evilmartians.io/
221
221
  source_code_uri: http://github.com/test-prof/test-prof
222
- post_install_message:
222
+ post_install_message:
223
223
  rdoc_options: []
224
224
  require_paths:
225
225
  - lib
@@ -234,8 +234,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
234
  - !ruby/object:Gem::Version
235
235
  version: '0'
236
236
  requirements: []
237
- rubygems_version: 3.0.6
238
- signing_key:
237
+ rubygems_version: 3.2.15
238
+ signing_key:
239
239
  specification_version: 4
240
240
  summary: Ruby applications tests profiling tools
241
241
  test_files: []