Skip to content

Commit e962b95

Browse files
committed
Merge pull request #246 from hunner/update_build_csv
Update build_csv to understand contexts
2 parents 7443e8b + 226cc76 commit e962b95

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

spec/acceptance/build_csv.rb

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env ruby
22
# vim: set sw=2 sts=2 et tw=80 :
33
require 'rspec'
4-
require 'pry'
54

65
#XXX Super ugly hack to keep from starting beaker nodes
76
module Kernel
@@ -44,15 +43,30 @@ def get_tests(children)
4443
end
4544
end
4645

46+
def count_test_types_in(type,group)
47+
return 0 if group.nil?
48+
group.inject(0) do |m,(k,v)|
49+
m += v.length if k == type
50+
m += count_tests_in(v) if v.is_a?(Hash)
51+
m
52+
end
53+
end
54+
def count_tests_in(group)
55+
count_test_types_in('tests',group)
56+
end
57+
def count_pending_tests_in(group)
58+
count_test_types_in('pending_tests',group)
59+
end
60+
4761
# Convert tests hash to csv format
4862
def to_csv(function_list,tests)
4963
function_list.collect do |function_name|
5064
if v = tests["#{function_name} function"]
51-
positive_tests = v["groups"]["success"] ? v["groups"]["success"]["tests"].length : 0
52-
negative_tests = v["groups"]["failure"] ? v["groups"]["failure"]["tests"].length : 0
65+
positive_tests = count_tests_in(v["groups"]["success"])
66+
negative_tests = count_tests_in(v["groups"]["failure"])
5367
pending_tests =
54-
(v["groups"]["failure"] ? v["groups"]["success"]["pending_tests"].length : 0) +
55-
(v["groups"]["failure"] ? v["groups"]["failure"]["pending_tests"].length : 0)
68+
count_pending_tests_in(v["groups"]["failure"]) +
69+
count_pending_tests_in(v["groups"]["failure"])
5670
else
5771
positive_tests = 0
5872
negative_tests = 0

0 commit comments

Comments
 (0)