File tree Expand file tree Collapse file tree 7 files changed +93
-6
lines changed
Expand file tree Collapse file tree 7 files changed +93
-6
lines changed Original file line number Diff line number Diff line change 99
1010# rspec failure tracking
1111.rspec_status
12+
13+
14+ # Created by https://www.toptal.com/developers/gitignore/api/macos,vim
15+ # Edit at https://www.toptal.com/developers/gitignore?templates=macos,vim
16+
17+ # ## macOS ###
18+ # General
19+ .DS_Store
20+ .AppleDouble
21+ .LSOverride
22+
23+ # Icon must end with two \r
24+ Icon
25+
26+
27+ # Thumbnails
28+ ._ *
29+
30+ # Files that might appear in the root of a volume
31+ .DocumentRevisions-V100
32+ .fseventsd
33+ .Spotlight-V100
34+ .TemporaryItems
35+ .Trashes
36+ .VolumeIcon.icns
37+ .com.apple.timemachine.donotpresent
38+
39+ # Directories potentially created on remote AFP share
40+ .AppleDB
41+ .AppleDesktop
42+ Network Trash Folder
43+ Temporary Items
44+ .apdisk
45+
46+ # ## Vim ###
47+ # Swap
48+ [._ ]* .s [a-v ][a-z ]
49+ ! * .svg # comment out if you don't need vector files
50+ [._ ]* .sw [a-p ]
51+ [._ ]s [a-rt-v ][a-z ]
52+ [._ ]ss [a-gi-z ]
53+ [._ ]sw [a-p ]
54+
55+ # Session
56+ Session.vim
57+ Sessionx.vim
58+
59+ # Temporary
60+ .netrwhist
61+ * ~
62+ # Auto-generated tag files
63+ tags
64+ # Persistent undo
65+ [._ ]* .un~
66+
67+ # End of https://www.toptal.com/developers/gitignore/api/macos,vim
68+
Original file line number Diff line number Diff line change 11PATH
22 remote: .
33 specs:
4- turbo_tests (1.2.1 )
4+ turbo_tests (1.2.2 )
55 bundler
66 parallel_tests (~> 3.3 )
77 rspec (~> 3.10.0 )
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ module TurboTests
2222 class JsonRowsFormatter
2323 RSpec ::Core ::Formatters . register (
2424 self ,
25+ :start ,
2526 :close ,
2627 :example_failed ,
2728 :example_passed ,
@@ -38,6 +39,14 @@ def initialize(output)
3839 @output = output
3940 end
4041
42+
43+ def start ( notification )
44+ output_row (
45+ "type" => :load_summary ,
46+ "summary" => load_summary_to_json ( notification )
47+ )
48+ end
49+
4150 def example_group_started ( notification )
4251 output_row (
4352 "type" => :group_started ,
@@ -48,7 +57,7 @@ def example_group_started(notification)
4857 def example_group_finished ( notification )
4958 output_row (
5059 "type" => :group_finished ,
51- "example " => group_to_json ( notification )
60+ "group " => group_to_json ( notification )
5261 )
5362 end
5463
@@ -130,6 +139,13 @@ def example_to_json(example)
130139 }
131140 end
132141
142+ def load_summary_to_json ( notification )
143+ {
144+ count : notification . count ,
145+ load_time : notification . load_time
146+ }
147+ end
148+
133149 def group_to_json ( notification )
134150 {
135151 "group" : {
Original file line number Diff line number Diff line change 22
33module TurboTests
44 class Reporter
5+ attr_writer :load_time
6+
57 def self . from_config ( formatter_config , start_time )
68 reporter = new ( start_time )
79
@@ -27,6 +29,7 @@ def initialize(start_time)
2729 @failed_examples = [ ]
2830 @all_examples = [ ]
2931 @start_time = start_time
32+ @load_time = 0
3033 end
3134
3235 def add ( name , outputs )
@@ -93,7 +96,7 @@ def finish
9396 @all_examples ,
9497 @failed_examples ,
9598 @pending_examples ,
96- 0 ,
99+ @load_time ,
97100 0
98101 ) )
99102 delegate_to_formatters ( :close ,
Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ def initialize(opts)
3939 @verbose = opts [ :verbose ]
4040 @fail_fast = opts [ :fail_fast ]
4141 @count = opts [ :count ]
42+ @load_time = 0
43+ @load_count = 0
4244
4345 @failure_count = 0
4446 @runtime_log = "tmp/parallel_runtime_rspec.log"
@@ -170,6 +172,11 @@ def handle_messages
170172 when "example_pending"
171173 example = FakeExample . from_obj ( message [ "example" ] )
172174 @reporter . example_pending ( example )
175+ when "load_summary"
176+ message = message [ "summary" ]
177+ # NOTE: notifications order and content is not guaranteed hence the fetch
178+ # and count increment tracking to get the latest accumulated load time
179+ @reporter . load_time = message [ "load_time" ] if message . fetch ( "count" , 0 ) > @load_count
173180 when "example_failed"
174181 example = FakeExample . from_obj ( message [ "example" ] )
175182 @reporter . example_failed ( example )
@@ -203,7 +210,7 @@ def report_number_of_tests(groups)
203210
204211 num_processes = groups . size
205212 num_tests = groups . map ( &:size ) . sum
206- tests_per_process = ( num_processes == 0 ? 0 : num_tests / num_processes )
213+ tests_per_process = ( num_processes == 0 ? 0 : num_tests . to_f / num_processes ) . round
207214
208215 puts "#{ num_processes } processes for #{ num_tests } #{ name } s, ~ #{ tests_per_process } #{ name } s per process"
209216 end
Original file line number Diff line number Diff line change 11module TurboTests
2- VERSION = "1.2.1 "
2+ VERSION = "1.2.2 "
33end
Original file line number Diff line number Diff line change 1+ # This delay visualizes the effect of load time calculation.
2+ # https://github.com/serpapi/turbo_tests/pull/8#issue-583037321
3+ sleep 3
4+
15RSpec . describe "Top-level context" do
26 describe "#instance_method" do
37 it "does what it's supposed to" do
812 expect ( false ) . not_to be_truthy
913 end
1014 end
11- end
15+ end
You can’t perform that action at this time.
0 commit comments