test-prof 1.4.4 → 1.5.1
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 +31 -1
- data/lib/{test_prof → rubocop/test_prof}/cops/rspec/aggregate_examples/matchers_with_side_effects.rb +1 -1
- data/lib/{test_prof → rubocop/test_prof}/cops/rspec/aggregate_examples/node_matchers.rb +1 -1
- data/lib/{test_prof → rubocop/test_prof}/cops/rspec/aggregate_examples.rb +5 -5
- data/lib/rubocop/test_prof/plugin.rb +31 -0
- data/lib/rubocop/test_prof.rb +11 -0
- data/lib/test-prof.rb +7 -0
- data/lib/test_prof/any_fixture/dsl.rb +16 -4
- data/lib/test_prof/before_all/adapters/active_record.rb +11 -1
- data/lib/test_prof/event_prof/custom_events/factory_create.rb +1 -1
- data/lib/test_prof/event_prof/rspec.rb +1 -0
- data/lib/test_prof/factory_all_stub.rb +1 -1
- data/lib/test_prof/factory_bot.rb +2 -6
- data/lib/test_prof/factory_doctor/rspec.rb +1 -0
- data/lib/test_prof/factory_doctor.rb +2 -1
- data/lib/test_prof/factory_prof/factory_builders/factory_bot.rb +1 -1
- data/lib/test_prof/factory_prof/printers/simple.rb +35 -5
- data/lib/test_prof/factory_prof.rb +5 -3
- data/lib/test_prof/memory_prof/printer.rb +1 -0
- data/lib/test_prof/recipes/logging.rb +20 -0
- data/lib/test_prof/recipes/rspec/let_it_be.rb +1 -1
- data/lib/test_prof/rspec_dissect/collectors/let.rb +1 -1
- data/lib/test_prof/rspec_dissect/rspec.rb +1 -0
- data/lib/test_prof/rubocop.rb +10 -9
- data/lib/test_prof/stack_prof.rb +2 -2
- data/lib/test_prof/tag_prof/printers/simple.rb +2 -1
- data/lib/test_prof/tps_prof/reporter/text.rb +1 -0
- data/lib/test_prof/version.rb +1 -1
- metadata +15 -13
- data/lib/test_prof/cops/inject.rb +0 -25
- /data/lib/{test_prof → rubocop/test_prof}/cops/rspec/aggregate_examples/its.rb +0 -0
- /data/lib/{test_prof → rubocop/test_prof}/cops/rspec/aggregate_examples/line_range_helpers.rb +0 -0
- /data/lib/{test_prof → rubocop/test_prof}/cops/rspec/aggregate_examples/metadata_helpers.rb +0 -0
- /data/lib/{test_prof → rubocop/test_prof}/cops/rspec/language.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2dff1d8ae5206095a30da3b95a68c39df0571bcd7525f8601c2ff0b7ce0b5d06
|
|
4
|
+
data.tar.gz: a67fe77ee1826c220e7afde7e5df026d88c61a2d376134bc858b4a2143a6b883
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a939c453031278d52fc942f81e712aaafc6959286757a9fdc2680e514f6932488e38da8e2591b4e04aac790088cb109da49a014403f3e67156f31bf4e53b46d2
|
|
7
|
+
data.tar.gz: 43130ba15fbb3f17cb087733c587724185ad849011477424cb2805df9e86cde41c8101d14126b7d0483999f5f08363727b09caabf471b73d85b8652eb2412fb4
|
data/CHANGELOG.md
CHANGED
|
@@ -2,9 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
## master (unreleased)
|
|
4
4
|
|
|
5
|
+
## 1.5.1 (2026-01-27)
|
|
6
|
+
|
|
7
|
+
- Fix RuboCop plugin. ([@palkan][])
|
|
8
|
+
|
|
9
|
+
Now you should use `--plugin test-prof` or `plugins: [test-prof]` (in YAML) (so LintRoller can correctly obtain the plugin class name from the gemspec).
|
|
10
|
+
|
|
11
|
+
## 1.5.0 (2025-12-04)
|
|
12
|
+
|
|
13
|
+
- Logging: support Rails 8.2 structured events based logging. ([@palkan][])
|
|
14
|
+
|
|
15
|
+
- Allow using AnyFixture DSL through module inclusion, not refinements. ([@palkan][])
|
|
16
|
+
|
|
17
|
+
In Rails 7.2+, refined `#fixture` no longer works since there is a same-called method. So, from now on we recommend including the DSL module, instead of _using_ it.
|
|
18
|
+
|
|
19
|
+
## 1.4.5. (2025-05-09) 🎇
|
|
20
|
+
|
|
21
|
+
- FactoryProf: Add truncate_names configuration parameter. ([@skaestle][])
|
|
22
|
+
|
|
23
|
+
- Update Rubocop setup to support new plugins system. ([@julianpasquale])
|
|
24
|
+
|
|
25
|
+
Now you can truncate long factory-names when using the simple output mode.
|
|
26
|
+
|
|
27
|
+
Set `FPROF_TRUNCATE_NAMES=1` env var or set it through `FactoryProf` configuration:
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
TestProf::FactoryProf.configure do |config|
|
|
31
|
+
config.truncate_names = true
|
|
32
|
+
end
|
|
33
|
+
```
|
|
34
|
+
|
|
5
35
|
## 1.4.4 (2025-01-03)
|
|
6
36
|
|
|
7
|
-
- Fix _stamping_ specs with single quotes with
|
|
37
|
+
- Fix _stamping_ specs with single quotes with RSpec Stamp. ([@elasticspoon][])
|
|
8
38
|
|
|
9
39
|
## 1.4.3 (2024-12-18)
|
|
10
40
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
require_relative "aggregate_examples/line_range_helpers"
|
|
4
|
+
require_relative "aggregate_examples/metadata_helpers"
|
|
5
|
+
require_relative "aggregate_examples/node_matchers"
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
require_relative "aggregate_examples/its"
|
|
8
|
+
require_relative "aggregate_examples/matchers_with_side_effects"
|
|
9
9
|
|
|
10
10
|
module RuboCop
|
|
11
11
|
module Cop
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "lint_roller"
|
|
4
|
+
|
|
5
|
+
module RuboCop
|
|
6
|
+
module TestProf
|
|
7
|
+
# A plugin that integrates TestProf with RuboCop's plugin system.
|
|
8
|
+
class Plugin < LintRoller::Plugin
|
|
9
|
+
def about
|
|
10
|
+
LintRoller::About.new(
|
|
11
|
+
name: "test-prof",
|
|
12
|
+
version: ::TestProf::VERSION,
|
|
13
|
+
homepage: "https://test-prof.evilmartians.io/misc/rubocop",
|
|
14
|
+
description: "RuboCop plugin to help you write more performant tests."
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def supported?(context)
|
|
19
|
+
context.engine == :rubocop
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def rules(_context)
|
|
23
|
+
LintRoller::Rules.new(
|
|
24
|
+
type: :path,
|
|
25
|
+
config_format: :rubocop,
|
|
26
|
+
value: Pathname.new(__dir__).join("../../../config/default.yml")
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "test_prof/utils"
|
|
4
|
+
supported = TestProf::Utils.verify_gem_version("rubocop", at_least: "0.51.0")
|
|
5
|
+
unless supported
|
|
6
|
+
warn "TestProf cops require RuboCop >= 0.51.0 to run."
|
|
7
|
+
return
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
require "rubocop/test_prof/plugin"
|
|
11
|
+
require "rubocop/test_prof/cops/rspec/aggregate_examples"
|
data/lib/test-prof.rb
CHANGED
|
@@ -9,10 +9,7 @@ module TestProf
|
|
|
9
9
|
module AnyFixture
|
|
10
10
|
# Adds "global" `fixture`, `before_fixtures_reset` and `after_fixtures_reset` methods (through refinement)
|
|
11
11
|
module DSL
|
|
12
|
-
|
|
13
|
-
# - https://bugs.ruby-lang.org/issues/13446
|
|
14
|
-
# - Rails added `Kernel.prepend` in 6.1: https://github.com/rails/rails/commit/3124007bd674dcdc9c3b5c6b2964dfb7a1a0733c
|
|
15
|
-
refine ::Object do
|
|
12
|
+
module Methods
|
|
16
13
|
def fixture(id, &block)
|
|
17
14
|
id = :"#{id}"
|
|
18
15
|
record = ::TestProf::AnyFixture.cached(id)
|
|
@@ -38,6 +35,21 @@ module TestProf
|
|
|
38
35
|
::TestProf::AnyFixture.after_fixtures_reset(&block)
|
|
39
36
|
end
|
|
40
37
|
end
|
|
38
|
+
|
|
39
|
+
def self.included(base)
|
|
40
|
+
base.include Methods
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Refine object, 'cause refining modules (Kernel) is vulnerable to prepend:
|
|
44
|
+
# - https://bugs.ruby-lang.org/issues/13446
|
|
45
|
+
# - Rails added `Kernel.prepend` in 6.1: https://github.com/rails/rails/commit/3124007bd674dcdc9c3b5c6b2964dfb7a1a0733c
|
|
46
|
+
refine ::Object do
|
|
47
|
+
if RUBY_VERSION >= "3.1.0"
|
|
48
|
+
import_methods Methods
|
|
49
|
+
else
|
|
50
|
+
include Methods
|
|
51
|
+
end
|
|
52
|
+
end
|
|
41
53
|
end
|
|
42
54
|
end
|
|
43
55
|
end
|
|
@@ -24,6 +24,11 @@ module TestProf
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def subscribe!
|
|
27
|
+
Thread.current[:before_all_subscription_count] ||= 0
|
|
28
|
+
Thread.current[:before_all_subscription_count] += 1
|
|
29
|
+
|
|
30
|
+
return unless Thread.current[:before_all_subscription_count] == 1
|
|
31
|
+
|
|
27
32
|
Thread.current[:before_all_connection_subscriber] = ActiveSupport::Notifications.subscribe("!connection.active_record") do |_, _, _, _, payload|
|
|
28
33
|
connection_name = payload[:connection_name] if payload.key?(:connection_name)
|
|
29
34
|
shard = payload[:shard] if payload.key?(:shard)
|
|
@@ -37,7 +42,12 @@ module TestProf
|
|
|
37
42
|
end
|
|
38
43
|
|
|
39
44
|
def unsubscribe!
|
|
40
|
-
return unless Thread.current[:
|
|
45
|
+
return unless Thread.current[:before_all_subscription_count]
|
|
46
|
+
|
|
47
|
+
Thread.current[:before_all_subscription_count] -= 1
|
|
48
|
+
|
|
49
|
+
return unless Thread.current[:before_all_subscription_count] == 0 && Thread.current[:before_all_connection_subscriber]
|
|
50
|
+
|
|
41
51
|
ActiveSupport::Notifications.unsubscribe(Thread.current[:before_all_connection_subscriber])
|
|
42
52
|
Thread.current[:before_all_connection_subscriber] = nil
|
|
43
53
|
end
|
|
@@ -29,7 +29,7 @@ TestProf::EventProf::CustomEvents.register("factory.create") do
|
|
|
29
29
|
TestProf.log(
|
|
30
30
|
:error,
|
|
31
31
|
<<~MSG
|
|
32
|
-
Failed to load factory_bot /
|
|
32
|
+
Failed to load factory_bot / fabrication.
|
|
33
33
|
|
|
34
34
|
Make sure that any of them is in your Gemfile.
|
|
35
35
|
MSG
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module TestProf # :nodoc: all
|
|
4
|
-
FACTORY_GIRL_NAMES = {"factory_bot" => "::FactoryBot", "factory_girl" => "::FactoryGirl"}.freeze
|
|
5
|
-
|
|
6
4
|
TestProf.require("active_support")
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
TestProf.
|
|
10
|
-
TestProf::FactoryBot = Object.const_get(cname)
|
|
11
|
-
end
|
|
6
|
+
TestProf.require("factory_bot") do
|
|
7
|
+
TestProf::FactoryBot = Object.const_get("::FactoryBot")
|
|
12
8
|
end
|
|
13
9
|
end
|
|
@@ -27,6 +27,7 @@ module TestProf
|
|
|
27
27
|
pg_attribute|
|
|
28
28
|
pg_namespace|
|
|
29
29
|
show\stables|
|
|
30
|
+
show\ssearch_path|
|
|
30
31
|
pragma|
|
|
31
32
|
sqlite_master/rollback|
|
|
32
33
|
\ATRUNCATE TABLE|
|
|
@@ -70,7 +71,7 @@ module TestProf
|
|
|
70
71
|
|
|
71
72
|
log :info, "FactoryDoctor enabled (event: \"#{config.event}\", threshold: #{config.threshold})"
|
|
72
73
|
|
|
73
|
-
# Monkey-patch FactoryBot
|
|
74
|
+
# Monkey-patch FactoryBot
|
|
74
75
|
TestProf::FactoryBot::FactoryRunner.prepend(FactoryBotPatch) if
|
|
75
76
|
defined?(TestProf::FactoryBot)
|
|
76
77
|
|
|
@@ -12,7 +12,7 @@ module TestProf
|
|
|
12
12
|
class FactoryBot
|
|
13
13
|
using TestProf::FactoryBotStrategy
|
|
14
14
|
|
|
15
|
-
# Monkey-patch FactoryBot
|
|
15
|
+
# Monkey-patch FactoryBot
|
|
16
16
|
def self.patch
|
|
17
17
|
TestProf::FactoryBot::FactoryRunner.prepend(FactoryBotPatch) if
|
|
18
18
|
defined? TestProf::FactoryBot
|
|
@@ -9,7 +9,7 @@ module TestProf::FactoryProf
|
|
|
9
9
|
using TestProf::FloatDuration
|
|
10
10
|
include TestProf::Logging
|
|
11
11
|
|
|
12
|
-
def dump(result, start_time:, threshold:)
|
|
12
|
+
def dump(result, start_time:, threshold:, truncate_names:)
|
|
13
13
|
return log(:info, "No factories detected") if result.raw_stats == {}
|
|
14
14
|
msgs = []
|
|
15
15
|
|
|
@@ -19,6 +19,12 @@ module TestProf::FactoryProf
|
|
|
19
19
|
total_time = result.stats.sum { |stat| stat[:top_level_time] }
|
|
20
20
|
total_uniq_factories = result.stats.map { |stat| stat[:name] }.uniq.count
|
|
21
21
|
|
|
22
|
+
table_indent = 3
|
|
23
|
+
variations_indent = 2
|
|
24
|
+
max_name_length = result.stats.map { _1[:name].length }.max
|
|
25
|
+
max_variation_length = result.stats.flat_map { _1[:variations] }.select(&:present?).map { _1[:name].length }.max || 0
|
|
26
|
+
name_column_length = truncate_names ? 20 : ([max_name_length, max_variation_length].max + variations_indent)
|
|
27
|
+
|
|
22
28
|
msgs <<
|
|
23
29
|
<<~MSG
|
|
24
30
|
Factories usage
|
|
@@ -27,14 +33,24 @@ module TestProf::FactoryProf
|
|
|
27
33
|
Total top-level: #{total_top_level_count}
|
|
28
34
|
Total time: #{total_time.duration} (out of #{total_run_time.duration})
|
|
29
35
|
Total uniq factories: #{total_uniq_factories}
|
|
30
|
-
|
|
31
|
-
name total top-level total time time per call top-level time
|
|
32
36
|
MSG
|
|
33
37
|
|
|
38
|
+
msgs << format(
|
|
39
|
+
"%#{table_indent}s%-#{name_column_length}s %8s %12s %13s %16s %17s",
|
|
40
|
+
"", "name", "total", "top-level", "total time", "time per call", "top-level time"
|
|
41
|
+
)
|
|
42
|
+
msgs << ""
|
|
43
|
+
|
|
34
44
|
result.stats.each do |stat|
|
|
35
45
|
next if stat[:total_count] < threshold
|
|
36
46
|
|
|
37
|
-
msgs <<
|
|
47
|
+
msgs << formatted(
|
|
48
|
+
table_indent,
|
|
49
|
+
name_column_length,
|
|
50
|
+
truncate_names,
|
|
51
|
+
stat
|
|
52
|
+
)
|
|
53
|
+
|
|
38
54
|
# move other variation ("[...]") to the end of the array
|
|
39
55
|
sorted_variations = stat[:variations].sort_by.with_index do |variation, i|
|
|
40
56
|
(variation[:name] == "[...]") ? stat[:variations].size + 1 : i
|
|
@@ -42,7 +58,12 @@ module TestProf::FactoryProf
|
|
|
42
58
|
sorted_variations.each do |variation_stat|
|
|
43
59
|
next if variation_stat[:total_count] < threshold
|
|
44
60
|
|
|
45
|
-
msgs <<
|
|
61
|
+
msgs << formatted(
|
|
62
|
+
table_indent + variations_indent,
|
|
63
|
+
name_column_length - variations_indent,
|
|
64
|
+
truncate_names,
|
|
65
|
+
variation_stat
|
|
66
|
+
)
|
|
46
67
|
end
|
|
47
68
|
end
|
|
48
69
|
|
|
@@ -51,6 +72,10 @@ module TestProf::FactoryProf
|
|
|
51
72
|
|
|
52
73
|
private
|
|
53
74
|
|
|
75
|
+
def formatted(indent_len, name_len, truncate_names, stat)
|
|
76
|
+
format(format_string(indent_len, name_len, truncate_names), *format_args(stat))
|
|
77
|
+
end
|
|
78
|
+
|
|
54
79
|
def format_args(stat)
|
|
55
80
|
time_per_call = stat[:total_time] / stat[:total_count]
|
|
56
81
|
format_args = [""]
|
|
@@ -58,6 +83,11 @@ module TestProf::FactoryProf
|
|
|
58
83
|
format_args << time_per_call
|
|
59
84
|
format_args << stat[:top_level_time]
|
|
60
85
|
end
|
|
86
|
+
|
|
87
|
+
def format_string(indent_len, name_len, truncate_names)
|
|
88
|
+
name_format = truncate_names ? "#{name_len}.#{name_len}" : name_len.to_s
|
|
89
|
+
"%#{indent_len}s%-#{name_format}s %8d %12d %12.4fs %15.4fs %16.4fs"
|
|
90
|
+
end
|
|
61
91
|
end
|
|
62
92
|
end
|
|
63
93
|
end
|
|
@@ -16,7 +16,8 @@ module TestProf
|
|
|
16
16
|
|
|
17
17
|
# FactoryProf configuration
|
|
18
18
|
class Configuration
|
|
19
|
-
attr_accessor :mode, :printer, :threshold, :include_variations, :variations_limit
|
|
19
|
+
attr_accessor :mode, :printer, :threshold, :include_variations, :variations_limit,
|
|
20
|
+
:truncate_names
|
|
20
21
|
|
|
21
22
|
def initialize
|
|
22
23
|
@mode = (ENV["FPROF"] == "flamegraph") ? :flamegraph : :simple
|
|
@@ -34,6 +35,7 @@ module TestProf
|
|
|
34
35
|
@threshold = ENV.fetch("FPROF_THRESHOLD", 0).to_i
|
|
35
36
|
@include_variations = ENV["FPROF_VARS"] == "1"
|
|
36
37
|
@variations_limit = ENV.fetch("FPROF_VARIATIONS_LIMIT", 2).to_i
|
|
38
|
+
@truncate_names = ENV["FPROF_TRUNCATE_NAMES"] == "1"
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
# Whether we want to generate flamegraphs
|
|
@@ -120,7 +122,7 @@ module TestProf
|
|
|
120
122
|
def print(started_at)
|
|
121
123
|
printer = config.printer
|
|
122
124
|
|
|
123
|
-
printer.dump(result, start_time: started_at, threshold: config.threshold)
|
|
125
|
+
printer.dump(result, start_time: started_at, threshold: config.threshold, truncate_names: config.truncate_names)
|
|
124
126
|
end
|
|
125
127
|
|
|
126
128
|
def start
|
|
@@ -158,7 +160,7 @@ module TestProf
|
|
|
158
160
|
|
|
159
161
|
def variation_name(variation)
|
|
160
162
|
return "-" if variation.empty?
|
|
161
|
-
variations_count = variation.to_s.scan(
|
|
163
|
+
variations_count = variation.to_s.scan(/\w+/).size
|
|
162
164
|
return "[...]" if variations_count > config.variations_limit
|
|
163
165
|
|
|
164
166
|
variation
|
|
@@ -84,16 +84,30 @@ module TestProf
|
|
|
84
84
|
|
|
85
85
|
# Enable verbose Rails logging within a block
|
|
86
86
|
def with_logging
|
|
87
|
+
if ::ActiveSupport.respond_to?(:event_reporter)
|
|
88
|
+
@was_events_debug_mode = ActiveSupport.event_reporter.debug_mode?
|
|
89
|
+
::ActiveSupport.event_reporter.debug_mode = true
|
|
90
|
+
end
|
|
87
91
|
*loggers = LoggingHelpers.swap_logger(LoggingHelpers.all_loggables)
|
|
88
92
|
yield
|
|
89
93
|
ensure
|
|
94
|
+
if ::ActiveSupport.respond_to?(:event_reporter)
|
|
95
|
+
::ActiveSupport.event_reporter.debug_mode = @was_events_debug_mode
|
|
96
|
+
end
|
|
90
97
|
LoggingHelpers.restore_logger(loggers, LoggingHelpers.all_loggables)
|
|
91
98
|
end
|
|
92
99
|
|
|
93
100
|
def with_ar_logging
|
|
101
|
+
if ::ActiveSupport.respond_to?(:event_reporter)
|
|
102
|
+
@was_events_debug_mode = ActiveSupport.event_reporter.debug_mode?
|
|
103
|
+
::ActiveSupport.event_reporter.debug_mode = true
|
|
104
|
+
end
|
|
94
105
|
*loggers = LoggingHelpers.swap_logger(LoggingHelpers.ar_loggables)
|
|
95
106
|
yield
|
|
96
107
|
ensure
|
|
108
|
+
if ::ActiveSupport.respond_to?(:event_reporter)
|
|
109
|
+
::ActiveSupport.event_reporter.debug_mode = @was_events_debug_mode
|
|
110
|
+
end
|
|
97
111
|
LoggingHelpers.restore_logger(loggers, LoggingHelpers.ar_loggables)
|
|
98
112
|
end
|
|
99
113
|
end
|
|
@@ -124,10 +138,16 @@ end
|
|
|
124
138
|
|
|
125
139
|
TestProf.activate("LOG", "all") do
|
|
126
140
|
TestProf.log :info, "Rails verbose logging enabled"
|
|
141
|
+
if ::ActiveSupport.respond_to?(:event_reporter)
|
|
142
|
+
::ActiveSupport.event_reporter.debug_mode = true
|
|
143
|
+
end
|
|
127
144
|
TestProf::Rails::LoggingHelpers.swap_logger!(TestProf::Rails::LoggingHelpers.all_loggables)
|
|
128
145
|
end
|
|
129
146
|
|
|
130
147
|
TestProf.activate("LOG", "ar") do
|
|
131
148
|
TestProf.log :info, "Active Record verbose logging enabled"
|
|
149
|
+
if ::ActiveSupport.respond_to?(:event_reporter)
|
|
150
|
+
::ActiveSupport.event_reporter.debug_mode = true
|
|
151
|
+
end
|
|
132
152
|
TestProf::Rails::LoggingHelpers.swap_logger!(TestProf::Rails::LoggingHelpers.ar_loggables)
|
|
133
153
|
end
|
|
@@ -142,7 +142,7 @@ module TestProf
|
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
private def report_duplicates(identifier)
|
|
145
|
-
if
|
|
145
|
+
if method_defined?(identifier) && File.basename(__FILE__) == File.basename(instance_method(identifier).source_location[0])
|
|
146
146
|
error_msg = "let_it_be(:#{identifier}) was redefined in nested group"
|
|
147
147
|
report_level = LetItBe.config.report_duplicates.to_sym
|
|
148
148
|
|
data/lib/test_prof/rubocop.rb
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
unless supported
|
|
6
|
-
warn "TestProf cops require RuboCop >= 0.51.0 to run."
|
|
7
|
-
return
|
|
8
|
-
end
|
|
3
|
+
warn <<~MSG
|
|
4
|
+
!!!
|
|
9
5
|
|
|
10
|
-
|
|
6
|
+
Please, update your .rubocop.yml configuration to load TestProf plugin as follows (and fix the error below):
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
plugins:
|
|
9
|
+
- test-prof
|
|
10
|
+
|
|
11
|
+
!!!
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
MSG
|
data/lib/test_prof/stack_prof.rb
CHANGED
|
@@ -72,7 +72,7 @@ module TestProf
|
|
|
72
72
|
|
|
73
73
|
@locked = true
|
|
74
74
|
|
|
75
|
-
log :info, "StackProf#{
|
|
75
|
+
log :info, "StackProf#{" (raw)" if config.raw?} enabled globally: " \
|
|
76
76
|
"mode – #{config.mode}, target – #{config.target}"
|
|
77
77
|
|
|
78
78
|
at_exit { dump("total") } if config.suite?
|
|
@@ -125,7 +125,7 @@ module TestProf
|
|
|
125
125
|
|
|
126
126
|
def build_path(name)
|
|
127
127
|
TestProf.artifact_path(
|
|
128
|
-
"stack-prof-report-#{config.mode}#{
|
|
128
|
+
"stack-prof-report-#{config.mode}#{"-raw" if config.raw}-#{name}.dump"
|
|
129
129
|
)
|
|
130
130
|
end
|
|
131
131
|
|
|
@@ -7,6 +7,7 @@ module TestProf::TagProf
|
|
|
7
7
|
module Simple # :nodoc: all
|
|
8
8
|
class << self
|
|
9
9
|
include TestProf::Logging
|
|
10
|
+
|
|
10
11
|
using TestProf::FloatDuration
|
|
11
12
|
|
|
12
13
|
def dump(result)
|
|
@@ -35,7 +36,7 @@ module TestProf::TagProf
|
|
|
35
36
|
)
|
|
36
37
|
end
|
|
37
38
|
|
|
38
|
-
header << format(
|
|
39
|
+
header << format( # rubocop:disable Style/RedundantFormat
|
|
39
40
|
"%6s %6s %6s %12s",
|
|
40
41
|
"total", "%total", "%time", "avg"
|
|
41
42
|
)
|
data/lib/test_prof/version.rb
CHANGED
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.
|
|
4
|
+
version: 1.5.1
|
|
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:
|
|
11
|
+
date: 2026-01-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -123,6 +123,15 @@ files:
|
|
|
123
123
|
- lib/minitest/base_reporter.rb
|
|
124
124
|
- lib/minitest/event_prof_formatter.rb
|
|
125
125
|
- lib/minitest/test_prof_plugin.rb
|
|
126
|
+
- lib/rubocop/test_prof.rb
|
|
127
|
+
- lib/rubocop/test_prof/cops/rspec/aggregate_examples.rb
|
|
128
|
+
- lib/rubocop/test_prof/cops/rspec/aggregate_examples/its.rb
|
|
129
|
+
- lib/rubocop/test_prof/cops/rspec/aggregate_examples/line_range_helpers.rb
|
|
130
|
+
- lib/rubocop/test_prof/cops/rspec/aggregate_examples/matchers_with_side_effects.rb
|
|
131
|
+
- lib/rubocop/test_prof/cops/rspec/aggregate_examples/metadata_helpers.rb
|
|
132
|
+
- lib/rubocop/test_prof/cops/rspec/aggregate_examples/node_matchers.rb
|
|
133
|
+
- lib/rubocop/test_prof/cops/rspec/language.rb
|
|
134
|
+
- lib/rubocop/test_prof/plugin.rb
|
|
126
135
|
- lib/test-prof.rb
|
|
127
136
|
- lib/test_prof.rb
|
|
128
137
|
- lib/test_prof/any_fixture.rb
|
|
@@ -135,14 +144,6 @@ files:
|
|
|
135
144
|
- lib/test_prof/before_all.rb
|
|
136
145
|
- lib/test_prof/before_all/adapters/active_record.rb
|
|
137
146
|
- lib/test_prof/before_all/isolator.rb
|
|
138
|
-
- lib/test_prof/cops/inject.rb
|
|
139
|
-
- lib/test_prof/cops/rspec/aggregate_examples.rb
|
|
140
|
-
- lib/test_prof/cops/rspec/aggregate_examples/its.rb
|
|
141
|
-
- lib/test_prof/cops/rspec/aggregate_examples/line_range_helpers.rb
|
|
142
|
-
- lib/test_prof/cops/rspec/aggregate_examples/matchers_with_side_effects.rb
|
|
143
|
-
- lib/test_prof/cops/rspec/aggregate_examples/metadata_helpers.rb
|
|
144
|
-
- lib/test_prof/cops/rspec/aggregate_examples/node_matchers.rb
|
|
145
|
-
- lib/test_prof/cops/rspec/language.rb
|
|
146
147
|
- lib/test_prof/core.rb
|
|
147
148
|
- lib/test_prof/event_prof.rb
|
|
148
149
|
- lib/test_prof/event_prof/custom_events.rb
|
|
@@ -241,7 +242,8 @@ metadata:
|
|
|
241
242
|
homepage_uri: https://test-prof.evilmartians.io/
|
|
242
243
|
source_code_uri: https://github.com/test-prof/test-prof
|
|
243
244
|
funding_uri: https://github.com/sponsors/test-prof
|
|
244
|
-
|
|
245
|
+
default_lint_roller_plugin: RuboCop::TestProf::Plugin
|
|
246
|
+
post_install_message:
|
|
245
247
|
rdoc_options: []
|
|
246
248
|
require_paths:
|
|
247
249
|
- lib
|
|
@@ -257,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
257
259
|
version: '0'
|
|
258
260
|
requirements: []
|
|
259
261
|
rubygems_version: 3.4.19
|
|
260
|
-
signing_key:
|
|
262
|
+
signing_key:
|
|
261
263
|
specification_version: 4
|
|
262
264
|
summary: Ruby applications tests profiling tools
|
|
263
265
|
test_files: []
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# This is shamelessly borrowed from RuboCop RSpec
|
|
4
|
-
# https://github.com/rubocop-hq/rubocop-rspec/blob/master/lib/rubocop/rspec/inject.rb
|
|
5
|
-
module TestProf
|
|
6
|
-
module Cops
|
|
7
|
-
# Because RuboCop doesn't yet support plugins, we have to monkey patch in a
|
|
8
|
-
# bit of our configuration.
|
|
9
|
-
module Inject
|
|
10
|
-
PROJECT_ROOT = Pathname.new(__dir__).parent.parent.parent.expand_path.freeze
|
|
11
|
-
CONFIG_DEFAULT = PROJECT_ROOT.join("config", "default.yml").freeze
|
|
12
|
-
|
|
13
|
-
def self.defaults!
|
|
14
|
-
path = CONFIG_DEFAULT.to_s
|
|
15
|
-
hash = RuboCop::ConfigLoader.send(:load_yaml_configuration, path)
|
|
16
|
-
config = RuboCop::Config.new(hash, path)
|
|
17
|
-
puts "configuration from #{path}" if RuboCop::ConfigLoader.debug?
|
|
18
|
-
config = RuboCop::ConfigLoader.merge_with_default(config, path)
|
|
19
|
-
RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
TestProf::Cops::Inject.defaults!
|
|
File without changes
|
/data/lib/{test_prof → rubocop/test_prof}/cops/rspec/aggregate_examples/line_range_helpers.rb
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|