From 0ec4161a1b160b15f709a73e7a72eb06bd7d6c33 Mon Sep 17 00:00:00 2001 From: Ivan Neverov Date: Tue, 11 Jul 2017 12:29:37 -0500 Subject: [PATCH] Runtime stat with test names containing colons symbol --- lib/parallel_tests/test/runner.rb | 2 +- spec/parallel_tests/test/runner_spec.rb | 10 ++++++++++ spec/spec_helper.rb | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) 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'