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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b73d571a58194483a14486ea7254d14473701d08
4
- data.tar.gz: fbac66cc87250b307dc314e83a218d5818086afe
3
+ metadata.gz: 7396b42cb2f6d31e427214554481e4425f20e5b7
4
+ data.tar.gz: 4ef7cbba5c84eaef068e1c5c2d120e7cc09bab19
5
5
  SHA512:
6
- metadata.gz: 44f08a73639231b50ca8d20f1f871be6fced27f33ae392efcaa25ae2813bd1862f5438bcb8c612e2a1cd0338c7486314f2c6db687af2e443da119fb546262813
7
- data.tar.gz: 2edcb0a49a7b2df8aaf0ff1cca792a62f40bba9a369ee0f4d98f1eeacfba7a60517306ab465f91b08d204b073b43fa91c9e255178a87c15f28773a770373060b
6
+ metadata.gz: e277ce21a284fc256370aebcb744f4d47dc5516930ce75817763439b4dd6dff8498214c7446d282902ce7945b4cee1aac5d9679b203792a59925ee35593c9ae7
7
+ data.tar.gz: df30d9cf8bb9d86899fd2c73d0de86613789b444ddc6394eb24caa9754890dfd651aa4406cb24dd05886cb54cd67363e51f29ae58fcd46704993855d41c15ebd
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby
1
+ #impacted_items!/usr/bin/env ruby
2
2
  require_relative '../lib/helper.rb'
3
3
 
4
4
  GitTest.start(ARGV)
@@ -81,6 +81,7 @@ class GitRecommend < Thor
81
81
  end
82
82
  end
83
83
  s.print
84
+ exit 0
84
85
  else
85
86
  $stderr.puts "No changed files detected. Change some files or run with --help for more options."
86
87
  end
@@ -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 = {"lhs" => Set.new, "rhs" => Set.new}
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
- ["lhs","rhs"].each do |side|
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, 'lhs' => 0, 'rhs' => 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
- ["lhs","rhs"].each do |side|
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
- type_of_impact = ((side == "lhs") ? "changed" : "impacted")
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,changed_items_covered,impacted_items_covered"
48
- test_plan.sort_by {|k,v| [v['lhs'],v['rhs']].max}.each do |test,v|
49
- $stdout.puts "#{test},#{v['cg']},#{v['lhs']},#{v['rhs']}"
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 a column \"tested_by\", which for each potentially impacted item lists the tests which test this item."
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(lhs rhs support lhs_tested_by rhs_tested_by)}
76
+ CSV {|r| r << %w(#{LHS} #{RHS} support #{LHS}_tested_by #{RHS}_tested_by)}
74
77
  change_rec.each do |row|
75
- lhs = row["lhs"]
76
- rhs = row["rhs"]
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 = []
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  module Recommend
3
- VERSION = "0.4.1"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
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.1
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: 2016-12-16 00:00:00.000000000 Z
11
+ date: 2017-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor