git-recommend 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/git-test +1 -1
- data/lib/git_recommend.rb +1 -0
- data/lib/git_test.rb +17 -14
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7396b42cb2f6d31e427214554481e4425f20e5b7
|
4
|
+
data.tar.gz: 4ef7cbba5c84eaef068e1c5c2d120e7cc09bab19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e277ce21a284fc256370aebcb744f4d47dc5516930ce75817763439b4dd6dff8498214c7446d282902ce7945b4cee1aac5d9679b203792a59925ee35593c9ae7
|
7
|
+
data.tar.gz: df30d9cf8bb9d86899fd2c73d0de86613789b444ddc6394eb24caa9754890dfd651aa4406cb24dd05886cb54cd67363e51f29ae58fcd46704993855d41c15ebd
|
data/bin/git-test
CHANGED
data/lib/git_recommend.rb
CHANGED
data/lib/git_test.rb
CHANGED
@@ -2,6 +2,9 @@ require 'helper'
|
|
2
2
|
|
3
3
|
class GitTest < Thor
|
4
4
|
|
5
|
+
LHS = 'changed_items'
|
6
|
+
RHS = 'impacted_items'
|
7
|
+
|
5
8
|
method_option :change_recommendation, aliases: '-c', type: :string, required: true, desc: "Path to test augmented change recommendation"
|
6
9
|
desc "plan", "Generates a prioritized test plan given a test augmented change recommendation (output of 'git-test join')"
|
7
10
|
def plan
|
@@ -12,18 +15,19 @@ class GitTest < Thor
|
|
12
15
|
exit 1
|
13
16
|
end
|
14
17
|
|
18
|
+
|
15
19
|
test_plan = Hash.new
|
16
|
-
coverage = {
|
20
|
+
coverage = {LHS => Set.new, RHS => Set.new}
|
17
21
|
|
18
22
|
change_rec.each do |row|
|
19
23
|
support = row["support"].to_r.to_f
|
20
24
|
# find relevant tests
|
21
|
-
[
|
25
|
+
[LHS,RHS].each do |side|
|
22
26
|
tests = (row["#{side}_tested_by"].nil? ? [] : row["#{side}_tested_by"].split(","))
|
23
27
|
tests.each do |test|
|
24
28
|
coverage[side] << row[side]
|
25
29
|
if test_plan[test].nil?
|
26
|
-
test_plan[test] = {'cg' => 0,
|
30
|
+
test_plan[test] = {'cg' => 0, LHS => 0, RHS => 0}
|
27
31
|
end
|
28
32
|
test_plan[test]['cg'] += support
|
29
33
|
test_plan[test][side] += 1
|
@@ -35,27 +39,26 @@ class GitTest < Thor
|
|
35
39
|
test_plan.each {|test,v| test_plan[test]['cg'] = v['cg']/max_cg}
|
36
40
|
|
37
41
|
# print warnings to stderr if any
|
38
|
-
[
|
42
|
+
[LHS,RHS].each do |side|
|
39
43
|
items_in_plan = change_rec.map {|row| row[side]}.to_set
|
40
44
|
if coverage[side].size < items_in_plan.size
|
41
45
|
uncovered = items_in_plan - coverage[side]
|
42
|
-
|
43
|
-
$stderr.puts "#{uncovered.size} #{type_of_impact} items were not covered by at least 1 test. The first 10 were: \n #{uncovered.take(10).join("\n")}"
|
46
|
+
$stderr.puts "#{uncovered.size} #{side.gsub('_',' ')} were not covered by at least 1 test. The first 10 were: \n #{uncovered.take(10).join("\n")}"
|
44
47
|
end
|
45
48
|
end
|
46
49
|
# print testplan to stdout
|
47
|
-
$stdout.puts "test,impact
|
48
|
-
test_plan.sort_by {|k,v| [v[
|
49
|
-
$stdout.puts "#{test},#{v['cg']},#{v[
|
50
|
+
$stdout.puts "test,impact,#{LHS}_covered,#{RHS}_covered"
|
51
|
+
test_plan.sort_by {|k,v| [v[LHS],v[RHS]].max}.each do |test,v|
|
52
|
+
$stdout.puts "#{test},#{v['cg']},#{v[LHS]},#{v[RHS]}"
|
50
53
|
end
|
51
54
|
end
|
52
55
|
|
53
56
|
method_option :mapping, aliases: '-m', type: :string, required: true, desc: "Path to test<->code mapping file"
|
54
57
|
method_option :change_recommendation, aliases: '-c', type: :string, required: true ,desc: "Path to change recommendation"
|
55
|
-
desc "join", "Adds
|
58
|
+
desc "join", "Adds columns which specify which tests are covering each item"
|
56
59
|
def join
|
57
60
|
begin
|
58
|
-
mapping = CSV.read(options[:mapping], headers: true)
|
61
|
+
mapping = CSV.read(options[:mapping], headers: true, skip_lines: /#/)
|
59
62
|
rescue CSV::MalformedCSVError, ArgumentError => e
|
60
63
|
$stderr.puts "An error occured when parsing the mapping file '#{options[:mapping]}:\n #{e}"
|
61
64
|
exit 1
|
@@ -70,10 +73,10 @@ class GitTest < Thor
|
|
70
73
|
|
71
74
|
|
72
75
|
# print header
|
73
|
-
CSV {|r| r << %w(
|
76
|
+
CSV {|r| r << %w(#{LHS} #{RHS} support #{LHS}_tested_by #{RHS}_tested_by)}
|
74
77
|
change_rec.each do |row|
|
75
|
-
lhs = row[
|
76
|
-
rhs = row[
|
78
|
+
lhs = row['lhs']
|
79
|
+
rhs = row['rhs']
|
77
80
|
support = row["support"].to_r.to_f
|
78
81
|
# find relevant tests
|
79
82
|
lhs_tests = []
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-recommend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Rolfsnes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|