test-prof 0.10.0 → 0.10.1

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: 19888b286ec85650d1d6c24c8d92ad1643e46cc506c2f9ce5e65c2f787f43949
4
- data.tar.gz: ad6477b9980cd68782ceb2c2b138b9f01a3248f09ebf23e60acbe77e3124fc63
3
+ metadata.gz: ccd09eb7997710ebeda54cadf25fa4f9bc4f3d9fce1a180113b29c5d92b22ea8
4
+ data.tar.gz: 32f50fb3af431b6d33622e03e0dcf720a3dfbcf34f52391be421753c8dede348
5
5
  SHA512:
6
- metadata.gz: 3da02b7d11494242e30360c10c2f69123e2c43f1b3e3ebd6edea567f4f298bb572daa726d8520d524602cb5b5ce2a6b8d68d59ad21238d9d6c1060b4d2132bf4
7
- data.tar.gz: 9b5831c47845a4c4337898b5e1a58f495e60bca3e1726813b30469162544b77f715f4f0a07d901026d991304d65077abe16ae3d61c990d8fe136937e3cd4ceb3
6
+ metadata.gz: f22b272e49c8423c1b3270202a4594b8acc082082f98418dc4ff781fa9711ea8c1dd2c89097bd8bdda972619a720bfc9c0258534fed80dd5c112186f02c254a4
7
+ data.tar.gz: f64bd5dbdd363d37346fe56eb3c2fb8223d38596a327b5b32408b5a13c9fd0649d3ebe4b25783923e41974e3eb5f6af69e260501d56c124f8fb05c6bcffaf3dd
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.10.1 (2019-10-17)
6
+
7
+ - Fix AnyFixture DSL when using with Rails 6.1+. ([@palkan][])
8
+
9
+ - Fix loading `let_it_be` without ActiveRecord present. ([@palkan][])
10
+
11
+ - Fix compatibility of `before_all` with [`isolator`](https://github.com/palkan/isolator) gem to handle correct usages of non-atomic interactions outside DB transactions. ([@Envek][])
12
+
13
+ - Updates FactoryProf to show the amount of time taken per factory call. ([@tyleriguchi][])
14
+
5
15
  ## 0.10.0 (2019-08-19)
6
16
 
7
17
  - Use RSpec example ID instead of full description for RubyProf/Stackprof report names. ([@palkan][])
@@ -498,3 +508,5 @@ Fixes [#10](https://github.com/palkan/test-prof/issues/10).
498
508
  [@mkldon]: https://github.com/mkldon
499
509
  [@dmagro]: https://github.com/dmagro
500
510
  [@danielwaterworth]: https://github.com/danielwaterworth
511
+ [@Envek]: https://github.com/Envek
512
+ [@tyleriguchi]: https://github.com/tyleriguchi
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  [![Cult Of Martians](http://cultofmartians.com/assets/badges/badge.svg)](http://cultofmartians.com)
2
- [![Gem Version](https://badge.fury.io/rb/test-prof.svg)](https://rubygems.org/gems/test-prof) [![Build Status](https://travis-ci.org/palkan/test-prof.svg?branch=master)](https://travis-ci.org/palkan/test-prof) [![Code Triagers Badge](https://www.codetriage.com/palkan/test-prof/badges/users.svg)](https://www.codetriage.com/palkan/test-prof)
2
+ [![Gem Version](https://badge.fury.io/rb/test-prof.svg)](https://rubygems.org/gems/test-prof) [![Build](https://github.com/palkan/test-prof/workflows/Build/badge.svg)](https://github.com/palkan/test-prof/actions)
3
+ [![JRuby Build](https://github.com/palkan/test-prof/workflows/JRuby%20Build/badge.svg)](https://github.com/palkan/test-prof/actions)
4
+ [![Code Triagers Badge](https://www.codetriage.com/palkan/test-prof/badges/users.svg)](https://www.codetriage.com/palkan/test-prof)
3
5
  [![Documentation](https://img.shields.io/badge/docs-link-brightgreen.svg)](https://test-prof.evilmartians.io)
4
6
 
5
7
  # Ruby Tests Profiling Toolbox
data/lib/test_prof.rb CHANGED
@@ -7,7 +7,7 @@ require "test_prof/utils"
7
7
 
8
8
  # Ruby applications tests profiling tools.
9
9
  #
10
- # Contains tools to anylyze factories usage, integrate with Ruby profilers,
10
+ # Contains tools to analyze factories usage, integrate with Ruby profilers,
11
11
  # profile your examples using ActiveSupport notifications (if any) and
12
12
  # statically analyze your code with custom RuboCop cops.
13
13
  #
@@ -131,10 +131,10 @@ module TestProf
131
131
  # TestProf configuration
132
132
  class Configuration
133
133
  attr_accessor :output, # IO to write output messages.
134
- :color, # Whether to colorize output or not
135
- :output_dir, # Directory to store artifacts
136
- :timestamps, # Whethere to use timestamped names for artifacts,
137
- :report_suffix # Custom suffix for reports/artifacts
134
+ :color, # Whether to colorize output or not
135
+ :output_dir, # Directory to store artifacts
136
+ :timestamps, # Whether to use timestamped names for artifacts,
137
+ :report_suffix # Custom suffix for reports/artifacts
138
138
 
139
139
  def initialize
140
140
  @output = $stdout
@@ -4,15 +4,14 @@ module TestProf
4
4
  module AnyFixture
5
5
  # Adds "global" `fixture` method (through refinement)
6
6
  module DSL
7
- module Ext # :nodoc:
7
+ # Refine object, 'cause refining modules (Kernel) is vulnerable to prepend:
8
+ # - https://bugs.ruby-lang.org/issues/13446
9
+ # - Rails added `Kernel.prepend` in 6.1: https://github.com/rails/rails/commit/3124007bd674dcdc9c3b5c6b2964dfb7a1a0733c
10
+ refine ::Object do
8
11
  def fixture(id, &block)
9
12
  ::TestProf::AnyFixture.register(:"#{id}", &block)
10
13
  end
11
14
  end
12
-
13
- refine Kernel do
14
- include Ext
15
- end
16
15
  end
17
16
  end
18
17
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestProf
4
- # `before_all` helper configiration
4
+ # `before_all` helper configuration
5
5
  module BeforeAll
6
6
  class AdapterMissing < StandardError # :nodoc:
7
7
  MSG = "Please, provide an adapter for `before_all` " \
@@ -5,11 +5,13 @@ module TestProf
5
5
  # Disable Isolator within before_all blocks
6
6
  module Isolator
7
7
  def begin_transaction(*)
8
- ::Isolator.disable { super }
8
+ ::Isolator.transactions_threshold += 1
9
+ super
9
10
  end
10
11
 
11
- def within_transaction(*)
12
- ::Isolator.disable { super }
12
+ def rollback_transaction(*)
13
+ super
14
+ ::Isolator.transactions_threshold -= 1
13
15
  end
14
16
  end
15
17
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "test_prof"
4
3
  require "test_prof/rspec_stamp"
5
4
  require "test_prof/event_prof/profiler"
6
5
  require "test_prof/event_prof/instrumentations/active_support"
@@ -35,7 +34,7 @@ module TestProf
35
34
  }.freeze
36
35
 
37
36
  attr_accessor :instrumenter, :top_count, :per_example,
38
- :rank_by, :event
37
+ :rank_by, :event
39
38
 
40
39
  def initialize
41
40
  @event = ENV["EVENT_PROF"]
@@ -4,7 +4,7 @@ module TestProf
4
4
  module EventProf
5
5
  class Profiler # :nodoc:
6
6
  attr_reader :event, :total_count, :total_time, :rank_by, :top_count, :per_example,
7
- :time, :count, :example_time, :example_count, :absolute_run_time
7
+ :time, :count, :example_time, :example_count, :absolute_run_time
8
8
 
9
9
  alias per_example? per_example
10
10
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  module TestProf
4
4
  # Ruby 2.3 #bsearch_index method (for usage with older Rubies)
5
- # Straighforward and non-optimal implementation,
6
- # just for compatiblity
5
+ # Straightforward and non-optimal implementation,
6
+ # just for compatibility
7
7
  module ArrayBSearchIndex
8
8
  refine Array do
9
9
  def bsearch_index(&block)
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "test_prof"
4
3
  require "test_prof/factory_bot"
5
4
  require "test_prof/factory_doctor/factory_bot_patch"
6
5
  require "test_prof/factory_doctor/fabrication_patch"
@@ -67,6 +66,8 @@ module TestProf
67
66
  def init
68
67
  reset!
69
68
 
69
+ @running = false
70
+
70
71
  log :info, "FactoryDoctor enabled (event: \"#{config.event}\", threshold: #{config.threshold})"
71
72
 
72
73
  # Monkey-patch FactoryBot / FactoryGirl
@@ -24,11 +24,13 @@ module TestProf::FactoryProf
24
24
  Total time: #{format("%.4f", total_time)}s
25
25
  Total uniq factories: #{total_uniq_factories}
26
26
 
27
- total top-level total time top-level time name
27
+ total top-level total time time per call top-level time name
28
28
  MSG
29
29
 
30
30
  result.stats.each do |stat|
31
- msgs << format("%8d %11d %11.4fs %15.4fs %30s", stat[:total_count], stat[:top_level_count], stat[:total_time], stat[:top_level_time], stat[:name])
31
+ time_per_call = stat[:total_time] / stat[:total_count]
32
+
33
+ msgs << format("%8d %11d %13.4fs %17.4fs %18.4fs %18s", stat[:total_count], stat[:top_level_count], stat[:total_time], time_per_call, stat[:top_level_time], stat[:name])
32
34
  end
33
35
 
34
36
  log :info, msgs.join("\n")
@@ -127,20 +127,22 @@ module TestProf
127
127
  end
128
128
  end
129
129
 
130
- require "test_prof/ext/active_record_refind"
131
- using TestProf::Ext::ActiveRecordRefind
132
-
133
- TestProf::LetItBe.configure do |config|
134
- config.register_modifier :reload do |record, val|
135
- next record unless val
136
- next record unless record.is_a?(::ActiveRecord::Base)
137
- record.reload
138
- end
130
+ if defined?(::ActiveRecord)
131
+ require "test_prof/ext/active_record_refind"
132
+ using TestProf::Ext::ActiveRecordRefind
133
+
134
+ TestProf::LetItBe.configure do |config|
135
+ config.register_modifier :reload do |record, val|
136
+ next record unless val
137
+ next record unless record.is_a?(::ActiveRecord::Base)
138
+ record.reload
139
+ end
139
140
 
140
- config.register_modifier :refind do |record, val|
141
- next record unless val
142
- next record unless record.is_a?(::ActiveRecord::Base)
143
- record.refind
141
+ config.register_modifier :refind do |record, val|
142
+ next record unless val
143
+ next record unless record.is_a?(::ActiveRecord::Base)
144
+ record.refind
145
+ end
144
146
  end
145
147
  end
146
148
 
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "test_prof"
4
3
  require "test_prof/rspec_stamp"
5
4
  require "test_prof/logging"
6
5
 
@@ -37,7 +36,7 @@ module TestProf
37
36
  MODES = %w[all let before].freeze
38
37
 
39
38
  attr_accessor :top_count, :let_stats_enabled,
40
- :let_top_count
39
+ :let_top_count
41
40
 
42
41
  alias let_stats_enabled? let_stats_enabled
43
42
 
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "test_prof"
4
3
  require "test_prof/logging"
5
4
  require "test_prof/rspec_stamp/parser"
6
5
 
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "test_prof"
4
-
5
3
  module TestProf
6
4
  # RubyProf wrapper.
7
5
  #
@@ -48,9 +46,9 @@ module TestProf
48
46
  LOGFILE_PREFIX = "ruby-prof-report"
49
47
 
50
48
  attr_accessor :printer, :mode, :min_percent,
51
- :include_threads, :exclude_common_methods,
52
- :test_prof_exclusions_enabled,
53
- :custom_exclusions
49
+ :include_threads, :exclude_common_methods,
50
+ :test_prof_exclusions_enabled,
51
+ :custom_exclusions
54
52
 
55
53
  def initialize
56
54
  @printer = ENV["TEST_RUBY_PROF"].to_sym if PRINTERS.key?(ENV["TEST_RUBY_PROF"])
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "test_prof"
4
-
5
3
  module TestProf
6
4
  # StackProf wrapper.
7
5
  #
@@ -133,6 +131,7 @@ module TestProf
133
131
 
134
132
  def init_stack_prof
135
133
  return @initialized if instance_variable_defined?(:@initialized)
134
+ @locked = false
136
135
  @initialized = TestProf.require(
137
136
  "stackprof",
138
137
  <<~MSG
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "test_prof"
4
-
5
3
  require "test_prof/tag_prof/result"
6
4
  require "test_prof/tag_prof/printers/simple"
7
5
  require "test_prof/tag_prof/printers/html"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestProf
4
- VERSION = "0.10.0"
4
+ VERSION = "0.10.1"
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.10.0
4
+ version: 0.10.1
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-08-20 00:00:00.000000000 Z
11
+ date: 2019-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.10'
19
+ version: '1.16'
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
- version: '1.10'
26
+ version: '1.16'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -81,33 +81,19 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '5.9'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rubocop-md
84
+ name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.2'
89
+ version: 0.72.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.2'
97
- - !ruby/object:Gem::Dependency
98
- name: standard
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 0.1.0
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 0.1.0
96
+ version: 0.72.0
111
97
  description: "\n Ruby applications tests profiling tools.\n\n Contains tools
112
98
  to analyze factories usage, integrate with Ruby profilers,\n profile your examples
113
99
  using ActiveSupport notifications (if any) and\n statically analyze your code