Skip to content

Commit 0ec4161

Browse files
committed
Runtime stat with test names containing colons symbol
1 parent ce5fb3e commit 0ec4161

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

lib/parallel_tests/test/runner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def runtimes(tests, options)
192192
log = options[:runtime_log] || runtime_log
193193
lines = File.read(log).split("\n")
194194
lines.each_with_object({}) do |line, times|
195-
test, time = line.split(":", 2)
195+
test, _, time = line.rpartition(':')
196196
next unless test and time
197197
times[test] = time.to_f if tests.include?(test)
198198
end

spec/parallel_tests/test/runner_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ def call(*args)
100100
call(["aaa", "bbb", "ccc"], 3, group_by: :runtime)
101101
end
102102

103+
it "groups when test name contains colons" do
104+
File.write("tmp/parallel_runtime_test.log", "ccc[1:2:3]:1\nbbb[1:2:3]:2\naaa[1:2:3]:3")
105+
expect(call(["aaa[1:2:3]", "bbb[1:2:3]", "ccc[1:2:3]"], 2, group_by: :runtime)).to match_array([["aaa[1:2:3]"], ["bbb[1:2:3]", "ccc[1:2:3]"]])
106+
end
107+
108+
it "groups when not even statistic" do
109+
File.write("tmp/parallel_runtime_test.log", "aaa:1\nbbb:1\nccc:8")
110+
expect(call(["aaa", "bbb", "ccc"], 2, group_by: :runtime)).to match_array([["aaa", "bbb"], ["ccc"]])
111+
end
112+
103113
it "groups with average for missing" do
104114
File.write("tmp/parallel_runtime_test.log", "xxx:123\nbbb:10\nccc:1")
105115
expect(call(["aaa", "bbb", "ccc", "ddd"], 2, group_by: :runtime)).to eq([["bbb", "ccc"], ["aaa", "ddd"]])

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'bundler/setup'
22
require 'tempfile'
33
require 'tmpdir'
4+
require 'timeout'
45

56
require 'parallel_tests'
67
require 'parallel_tests/test/runtime_logger'

0 commit comments

Comments
 (0)