diff --git a/lib/parallel_tests/test/runner.rb b/lib/parallel_tests/test/runner.rb index fa88d8a5..27133817 100644 --- a/lib/parallel_tests/test/runner.rb +++ b/lib/parallel_tests/test/runner.rb @@ -192,7 +192,7 @@ def runtimes(tests, options) log = options[:runtime_log] || runtime_log lines = File.read(log).split("\n") lines.each_with_object({}) do |line, times| - test, time = line.split(":", 2) + test, _, time = line.rpartition(':') next unless test and time times[test] = time.to_f if tests.include?(test) end diff --git a/spec/parallel_tests/test/runner_spec.rb b/spec/parallel_tests/test/runner_spec.rb index be92b495..79a0d67a 100644 --- a/spec/parallel_tests/test/runner_spec.rb +++ b/spec/parallel_tests/test/runner_spec.rb @@ -100,6 +100,16 @@ def call(*args) call(["aaa", "bbb", "ccc"], 3, group_by: :runtime) end + it "groups when test name contains colons" do + File.write("tmp/parallel_runtime_test.log", "ccc[1:2:3]:1\nbbb[1:2:3]:2\naaa[1:2:3]:3") + 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]"]]) + end + + it "groups when not even statistic" do + File.write("tmp/parallel_runtime_test.log", "aaa:1\nbbb:1\nccc:8") + expect(call(["aaa", "bbb", "ccc"], 2, group_by: :runtime)).to match_array([["aaa", "bbb"], ["ccc"]]) + end + it "groups with average for missing" do File.write("tmp/parallel_runtime_test.log", "xxx:123\nbbb:10\nccc:1") expect(call(["aaa", "bbb", "ccc", "ddd"], 2, group_by: :runtime)).to eq([["bbb", "ccc"], ["aaa", "ddd"]]) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 49941120..5438aa3d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,7 @@ require 'bundler/setup' require 'tempfile' require 'tmpdir' +require 'timeout' require 'parallel_tests' require 'parallel_tests/test/runtime_logger'