coverageval 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +22 -0
- data/README.md +42 -0
- data/bin/coverageval +5 -0
- data/lib/coverageval.rb +34 -0
- metadata +68 -0
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Andrew Moore
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
Coverage Validator
|
2
|
+
===========
|
3
|
+
|
4
|
+
This is a gem which will read a coverage xml file and either exit with a status of 0 if the coverage meets the target
|
5
|
+
|
6
|
+
# How to use?
|
7
|
+
|
8
|
+
```
|
9
|
+
coverageval <coverage file> <coverage threshold>
|
10
|
+
```
|
11
|
+
|
12
|
+
Example:
|
13
|
+
|
14
|
+
```
|
15
|
+
coverageval coverage.xml 0.9
|
16
|
+
```
|
17
|
+
|
18
|
+
# Coverage file format
|
19
|
+
|
20
|
+
The only currently support coverage file is:
|
21
|
+
|
22
|
+
```
|
23
|
+
<?xml version="1.0" ?>
|
24
|
+
<!DOCTYPE coverage
|
25
|
+
SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-03.dtd'>
|
26
|
+
<coverage branch-rate="0" line-rate="0.92" timestamp="1421847509594" version="3.7.1">
|
27
|
+
<packages>
|
28
|
+
<package branch-rate="0" complexity="0" line-rate="0.92" name="">
|
29
|
+
<classes>
|
30
|
+
<class branch-rate="0" complexity="0" filename="propertyfrontend/__init__.py" line-rate="0.8387" name="propertyfrontend/__init__">
|
31
|
+
<methods/>
|
32
|
+
<lines>
|
33
|
+
<line hits="1" number="1"/>
|
34
|
+
<line hits="0" number="2"/>
|
35
|
+
...
|
36
|
+
</lines>
|
37
|
+
</class>
|
38
|
+
</classes>
|
39
|
+
</package>
|
40
|
+
</packages>
|
41
|
+
</coverage>
|
42
|
+
```
|
data/bin/coverageval
ADDED
data/lib/coverageval.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
if (ARGV[0].nil?) then
|
4
|
+
raise "Error: Input coverage file missing"
|
5
|
+
end
|
6
|
+
|
7
|
+
input_file = ARGV[0];
|
8
|
+
|
9
|
+
if (ARGV[1].nil?) then
|
10
|
+
raise "Error: Coverage target missing"
|
11
|
+
end
|
12
|
+
|
13
|
+
target = ARGV[1].to_f;
|
14
|
+
|
15
|
+
|
16
|
+
f = File.open(input_file)
|
17
|
+
doc = Nokogiri::XML(f)
|
18
|
+
f.close
|
19
|
+
|
20
|
+
total = 0;
|
21
|
+
passed = 0;
|
22
|
+
|
23
|
+
doc.xpath('/coverage/packages/package/classes/class/lines/line').each do |row|
|
24
|
+
total = total + 1
|
25
|
+
if (row['hits'] == '1') then
|
26
|
+
passed = passed + 1
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
actual = (passed.to_f / total.to_f).round(2)
|
31
|
+
|
32
|
+
if (actual < target) then
|
33
|
+
raise "Error: Coverage is below target. Expected: >" + target.to_s + ", Actual: " + actual.to_s
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coverageval
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrew Moore
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-01-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.3.15
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.3.15
|
30
|
+
description: This gem will check if a coverage file meets the expected level. If it
|
31
|
+
doesn't it will exit with a exit code of 1. This can be used in tools such as Jenkins
|
32
|
+
to check if the coverage meets the expected level.
|
33
|
+
email: mooreandrew@gmail.com
|
34
|
+
executables:
|
35
|
+
- coverageval
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- lib/coverageval.rb
|
40
|
+
- README.md
|
41
|
+
- LICENSE
|
42
|
+
- bin/coverageval
|
43
|
+
homepage: https://github.com/mooreandrew/coverageval
|
44
|
+
licenses:
|
45
|
+
- MIT
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.8.23
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: ''
|
68
|
+
test_files: []
|