test-prof 0.7.3 → 0.7.4
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 +6 -0
- data/README.md +3 -0
- data/lib/test_prof.rb +15 -5
- data/lib/test_prof/before_all/adapters/active_record.rb +5 -0
- data/lib/test_prof/stack_prof.rb +32 -8
- data/lib/test_prof/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42dd5bfd5d77f676d37c3cf9ff88d366cf19b459da3736d891d974f31dcaef97
|
4
|
+
data.tar.gz: 7b99baeb4d93f86b11bb34c3a43fe2bb2f2b75487cd66190fcd2decc3d8ed532
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12a11804603dc80ef72ecfae63ec6f33f172c63bd447a9032df131cf33265c02926871d55eaabb08fc74d61de211d6bd78727b44802d6a488b20c9a1fee854cc
|
7
|
+
data.tar.gz: a826158093a4f66433c3b521311f2f3028f526d1864f2106c2294eb97e22b996da3328bebaed0d247b51baf9905fa117a8b75472b81119ffda2c6ebb660566a2
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.7.4 (2019-02-16)
|
6
|
+
|
7
|
+
- Add JSON report support for StackProf. ([@palkan][])
|
8
|
+
|
9
|
+
- Add ability to specify report/artifact name suffixes. ([@palkan][])
|
10
|
+
|
5
11
|
## 0.7.3 (2018-11-07)
|
6
12
|
|
7
13
|
- Add a header with the general information on factories usage [#99](https://github.com/palkan/test-prof/issues/99) ([@szemek][])
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[](http://cultofmartians.com)
|
1
2
|
[](https://rubygems.org/gems/test-prof) [](https://travis-ci.org/palkan/test-prof) [](https://www.codetriage.com/palkan/test-prof)
|
2
3
|
[](https://test-prof.evilmartians.io)
|
3
4
|
|
@@ -47,6 +48,8 @@ Supported Ruby versions:
|
|
47
48
|
|
48
49
|
- Paris.rb, 2018, "99 Problems of Slow Tests" talk [[video](https://www.youtube.com/watch?v=eDMZS_fkRtk), [slides](https://speakerdeck.com/palkan/paris-dot-rb-2018-99-problems-of-slow-tests)]
|
49
50
|
|
51
|
+
- BalkanRuby, 2018, "Take your slow tests to the doctor" talk [[video](https://www.youtube.com/watch?v=rOcrme82vC8)], [slides](https://speakerdeck.com/palkan/balkanruby-2018-take-your-slow-tests-to-the-doctor)]
|
52
|
+
|
50
53
|
- RailsClub, Moscow, 2017, "Faster Tests" talk [[video](https://www.youtube.com/watch?v=8S7oHjEiVzs) (RU), [slides](https://speakerdeck.com/palkan/railsclub-moscow-2017-faster-tests)]
|
51
54
|
|
52
55
|
- RubyConfBy, 2017, "Run Test Run" talk [[video](https://www.youtube.com/watch?v=q52n4p0wkIs), [slides](https://speakerdeck.com/palkan/rubyconfby-minsk-2017-run-test-run)]
|
data/lib/test_prof.rb
CHANGED
@@ -84,7 +84,9 @@ module TestProf
|
|
84
84
|
with_timestamps(
|
85
85
|
::File.join(
|
86
86
|
config.output_dir,
|
87
|
-
|
87
|
+
with_report_suffix(
|
88
|
+
filename
|
89
|
+
)
|
88
90
|
)
|
89
91
|
)
|
90
92
|
end
|
@@ -105,6 +107,12 @@ module TestProf
|
|
105
107
|
"#{path.sub(/\.\w+$/, '')}#{timestamps}#{::File.extname(path)}"
|
106
108
|
end
|
107
109
|
|
110
|
+
def with_report_suffix(path)
|
111
|
+
return path if config.report_suffix.nil?
|
112
|
+
|
113
|
+
"#{path.sub(/\.\w+$/, '')}-#{config.report_suffix}#{::File.extname(path)}"
|
114
|
+
end
|
115
|
+
|
108
116
|
def notify_spring_detected
|
109
117
|
return if instance_variable_defined?(:@spring_notified)
|
110
118
|
log :info, "Spring detected"
|
@@ -118,16 +126,18 @@ module TestProf
|
|
118
126
|
|
119
127
|
# TestProf configuration
|
120
128
|
class Configuration
|
121
|
-
attr_accessor :output,
|
122
|
-
:color,
|
123
|
-
:output_dir,
|
124
|
-
:timestamps
|
129
|
+
attr_accessor :output, # IO to write output messages.
|
130
|
+
:color, # Whether to colorize output or not
|
131
|
+
:output_dir, # Directory to store artifacts
|
132
|
+
:timestamps, # Whethere to use timestamped names for artifacts,
|
133
|
+
:report_suffix # Custom suffix for reports/artifacts
|
125
134
|
|
126
135
|
def initialize
|
127
136
|
@output = $stdout
|
128
137
|
@color = true
|
129
138
|
@output_dir = "tmp/test_prof"
|
130
139
|
@timestamps = false
|
140
|
+
@report_suffix = ENV['TEST_PROF_REPORT']
|
131
141
|
end
|
132
142
|
|
133
143
|
def color?
|
@@ -16,6 +16,11 @@ module TestProf
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def rollback_transaction
|
19
|
+
if ::ActiveRecord::Base.connection.open_transactions.zero?
|
20
|
+
warn "!!! before_all transaction has been already rollbacked and " \
|
21
|
+
"could work incorrectly"
|
22
|
+
return
|
23
|
+
end
|
19
24
|
::ActiveRecord::Base.connection.rollback_transaction
|
20
25
|
end
|
21
26
|
end
|
data/lib/test_prof/stack_prof.rb
CHANGED
@@ -22,12 +22,20 @@ module TestProf
|
|
22
22
|
module StackProf
|
23
23
|
# StackProf configuration
|
24
24
|
class Configuration
|
25
|
-
|
25
|
+
FORMATS = %w[html json].freeze
|
26
|
+
|
27
|
+
attr_accessor :mode, :interval, :raw, :target, :format
|
26
28
|
|
27
29
|
def initialize
|
28
30
|
@mode = ENV.fetch('TEST_STACK_PROF_MODE', :wall).to_sym
|
29
31
|
@target = ENV['TEST_STACK_PROF'] == 'boot' ? :boot : :suite
|
30
32
|
@raw = ENV['TEST_STACK_PROF_RAW'] != '0'
|
33
|
+
@format =
|
34
|
+
if FORMATS.include?(ENV['TEST_STACK_PROF_FORMAT'])
|
35
|
+
ENV['TEST_STACK_PROF_FORMAT']
|
36
|
+
else
|
37
|
+
'html'
|
38
|
+
end
|
31
39
|
end
|
32
40
|
|
33
41
|
def raw?
|
@@ -98,13 +106,7 @@ module TestProf
|
|
98
106
|
|
99
107
|
return unless config.raw
|
100
108
|
|
101
|
-
|
102
|
-
|
103
|
-
log :info, <<~MSG
|
104
|
-
Run the following command to generate a flame graph report:
|
105
|
-
|
106
|
-
stackprof --flamegraph #{path} > #{html_path} && stackprof --flamegraph-viewer=#{html_path}
|
107
|
-
MSG
|
109
|
+
send("dump_#{config.format}_report", path)
|
108
110
|
end
|
109
111
|
|
110
112
|
private
|
@@ -141,6 +143,28 @@ module TestProf
|
|
141
143
|
false
|
142
144
|
end
|
143
145
|
end
|
146
|
+
|
147
|
+
def dump_html_report(path)
|
148
|
+
html_path = path.gsub(/\.dump$/, '.html')
|
149
|
+
|
150
|
+
log :info, <<~MSG
|
151
|
+
Run the following command to generate a flame graph report:
|
152
|
+
|
153
|
+
stackprof --flamegraph #{path} > #{html_path} && stackprof --flamegraph-viewer=#{html_path}
|
154
|
+
MSG
|
155
|
+
end
|
156
|
+
|
157
|
+
def dump_json_report(path)
|
158
|
+
report = ::StackProf::Report.new(
|
159
|
+
Marshal.load(IO.binread(path)) # rubocop:disable Security/MarshalLoad
|
160
|
+
)
|
161
|
+
json_path = path.gsub(/\.dump$/, '.json')
|
162
|
+
File.write(json_path, JSON.generate(report.data))
|
163
|
+
|
164
|
+
log :info, <<~MSG
|
165
|
+
StackProf JSON report generated: #{json_path}
|
166
|
+
MSG
|
167
|
+
end
|
144
168
|
end
|
145
169
|
end
|
146
170
|
end
|
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: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
requirements: []
|
216
216
|
rubyforge_project:
|
217
|
-
rubygems_version: 2.7.
|
217
|
+
rubygems_version: 2.7.6
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: Ruby applications tests profiling tools
|