knife-testcoverage 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/chef/knife/knife-testcoverage.rb +15 -4
- metadata +3 -3
@@ -7,11 +7,17 @@ class Chef
|
|
7
7
|
option :show_missing,
|
8
8
|
:short => "-s",
|
9
9
|
:long => "--show-missing",
|
10
|
-
:description => "Show the missing tests",
|
10
|
+
:description => "Show the missing tests. Default false",
|
11
11
|
:default => false
|
12
12
|
|
13
|
+
option :fail_threshold,
|
14
|
+
:short => "-f VALUE",
|
15
|
+
:long => "--fail-threshold VALUE",
|
16
|
+
:description => "Fail if coverage is less than this value. Default 100",
|
17
|
+
:default => 100
|
18
|
+
|
13
19
|
def run
|
14
|
-
if @name_args.length
|
20
|
+
if @name_args.length == 0
|
15
21
|
stdout.puts "You must provide the name of the cookbook to review."
|
16
22
|
stdout.puts opt_parser
|
17
23
|
exit 1
|
@@ -77,7 +83,7 @@ class Chef
|
|
77
83
|
|
78
84
|
coverage = (testcount.to_f / recipecount.to_f * 100).round
|
79
85
|
|
80
|
-
|
86
|
+
@fail = config[:fail_threshold]
|
81
87
|
|
82
88
|
if config[:show_missing]
|
83
89
|
print "Missing tests:\n"
|
@@ -86,9 +92,14 @@ class Chef
|
|
86
92
|
end
|
87
93
|
end
|
88
94
|
|
89
|
-
|
95
|
+
print "Cookbook #{cookbook} contains #{recipecount} recipes and #{testcount} tests.\n"
|
96
|
+
|
97
|
+
|
98
|
+
if coverage >= config[:fail_threshold].to_i
|
99
|
+
print "Validation passed. Test coverage #{coverage}% exceeds the required threshold (#{config[:fail_threshold]}%)\n"
|
90
100
|
exit 0
|
91
101
|
else
|
102
|
+
print "Validation failed. Test coverage #{coverage}% is less than the required threshold (#{config[:fail_threshold]}%)\n"
|
92
103
|
exit 1
|
93
104
|
end
|
94
105
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-testcoverage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-24 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A simple plugin to report on minitest-handler coverage in a cookbook
|
15
15
|
email: brian@stormtrooperguy.com
|
@@ -18,7 +18,7 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- lib/chef/knife/knife-testcoverage.rb
|
21
|
-
homepage:
|
21
|
+
homepage: http://rubygems.org/gems/knife-testcoverage
|
22
22
|
licenses: []
|
23
23
|
post_install_message:
|
24
24
|
rdoc_options: []
|