| Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
|---|---|---|---|---|
| lib/buildr/java/test_result.rb | 101 | 66 | 30.69%
|
36.36%
|
Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.
1 # Licensed to the Apache Software Foundation (ASF) under one or more |
2 # contributor license agreements. See the NOTICE file distributed with this |
3 # work for additional information regarding copyright ownership. The ASF |
4 # licenses this file to you under the Apache License, Version 2.0 (the |
5 # "License"); you may not use this file except in compliance with the License. |
6 # You may obtain a copy of the License at |
7 # |
8 # http://www.apache.org/licenses/LICENSE-2.0 |
9 # |
10 # Unless required by applicable law or agreed to in writing, software |
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
13 # License for the specific language governing permissions and limitations under |
14 # the License. |
15 |
16 # necessary to require YAML even if it is mentioned by autoload as it fails on some platforms. |
17 require 'yaml' |
18 require 'fileutils' |
19 require 'rspec/core/formatters/base_formatter' |
20 |
21 module Buildr #:nodoc: |
22 module TestFramework |
23 |
24 # A class used by buildr for jruby based frameworks, so that buildr can know |
25 # which tests succeeded/failed. |
26 class TestResult |
27 |
28 class Error < ::Exception |
29 attr_reader :message, :backtrace |
30 def initialize(message, backtrace) |
31 @message = message |
32 @backtrace = backtrace |
33 set_backtrace backtrace |
34 end |
35 |
36 def self.dump_yaml(file, e) |
37 FileUtils.mkdir_p File.dirname(file) |
38 File.open(file, 'w') { |f| f.puts(YAML.dump(Error.new(e.message, e.backtrace))) } |
39 end |
40 |
41 def self.guard(file) |
42 begin |
43 yield |
44 rescue => e |
45 dump_yaml(file, e) |
46 end |
47 end |
48 end |
49 |
50 attr_accessor :failed, :succeeded |
51 |
52 def initialize |
53 @failed, @succeeded = [], [] |
54 end |
55 |
56 # An Rspec formatter used by buildr |
57 class YamlFormatter < ::RSpec::Core::Formatters::BaseFormatter |
58 attr_reader :result |
59 |
60 def initialize(output) |
61 super(output) |
62 @result = Hash.new |
63 @result[:succeeded] = [] |
64 @result[:failed] = [] |
65 end |
66 |
67 def example_passed(example) |
68 super(example) |
69 result.succeeded << example_name(example) |
70 end |
71 |
72 def example_pending(example) |
73 super(example) |
74 result.succeeded << example_name(example) |
75 end |
76 |
77 def example_failed(example) |
78 super(example) |
79 result.failed << example_name(example) |
80 end |
81 |
82 def start(example_count) |
83 super(example_count) |
84 @result = TestResult.new |
85 end |
86 |
87 def close |
88 super |
89 result.succeeded = result.succeeded - result.failed |
90 output.puts YAML.dump(result) |
91 end |
92 |
93 private |
94 def example_name(example) |
95 example.file_path |
96 end |
97 end # YamlFormatter |
98 |
99 end # TestResult |
100 end |
101 end |
Generated on 2011-07-06 23:35:37 -0700 with rcov 0.9.8