|
1 | 1 | #!/usr/bin/env ruby |
2 | 2 | # vim: set sw=2 sts=2 et tw=80 : |
3 | 3 | require 'rspec' |
4 | | -require 'pry' |
5 | 4 |
|
6 | 5 | #XXX Super ugly hack to keep from starting beaker nodes |
7 | 6 | module Kernel |
@@ -44,15 +43,30 @@ def get_tests(children) |
44 | 43 | end |
45 | 44 | end |
46 | 45 |
|
| 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 | + |
47 | 61 | # Convert tests hash to csv format |
48 | 62 | def to_csv(function_list,tests) |
49 | 63 | function_list.collect do |function_name| |
50 | 64 | 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"]) |
53 | 67 | 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"]) |
56 | 70 | else |
57 | 71 | positive_tests = 0 |
58 | 72 | negative_tests = 0 |
|
0 commit comments