miss_cleo 0.1.2 → 0.2.0
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.
- checksums.yaml +4 -4
- data/README.md +16 -3
- data/bin/miss_cleo +47 -38
- data/lib/miss_cleo/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7443ba51e59b7d1941d4ee652e26543136da4d1
|
4
|
+
data.tar.gz: 5f8c6e24bafa1eafff383a4435fcd25bf45428d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05a3e70338e08f3c3ac99397f15def5b6212e76b0d7dd458fd4fc0715d24288db41a078337336aaad4d6c30cedf97ebcca26cf8d424059c08cbabf1e617a3fcc
|
7
|
+
data.tar.gz: f29c165a827f380f548b10fa62fdc24f08c8ef0220a8a5b2cd1f3c8dfa01b33260a0e62d21239187a10015b29e5ce8c7ae96702f5f1473ece4237d9b478400d1
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ Or install it yourself as:
|
|
25
25
|
|
26
26
|
## Setup
|
27
27
|
|
28
|
-
Right now Miss Cleo only supports Cucumber and RSpec tests. To use Miss Cleo
|
28
|
+
Right now Miss Cleo only supports Cucumber and RSpec tests. To use Miss Cleo:
|
29
29
|
|
30
30
|
### Cucumber
|
31
31
|
Before you can use Miss Cleo with your Cucumber tests, add the following line to your `support/env.rb` file:
|
@@ -43,19 +43,32 @@ MissCleo::TestConfigurations::RspecConfig.setup_hooks(self)
|
|
43
43
|
|
44
44
|
### How to get predictin'
|
45
45
|
|
46
|
-
To use Miss Cleo, you'll need to first build a coverage
|
46
|
+
To use Miss Cleo, you'll need to first build a coverage diff of your *green* build. Do this by running your tests with the `COVERAGE` environment variable set to true.
|
47
47
|
|
48
48
|
Examples:
|
49
49
|
|
50
50
|
* `COVERAGE=true cucumber features/user.feature`
|
51
51
|
* `COVERAGE=true rspec spec/user_spec.rb`
|
52
52
|
|
53
|
+
With your coverage diffs built, you'll need to generate a coverage map, which we're calling a *deck*. To build your deck, run:
|
54
|
+
`miss_cleo build_deck <list of coverage diff files>`
|
55
|
+
|
53
56
|
## Usage
|
54
57
|
|
55
|
-
After you've made some code changes, run `miss_cleo` to be shown the relevant tests to run.
|
58
|
+
After you've made some code changes, run `miss_cleo predict` to be shown the relevant tests to run.
|
56
59
|
|
57
60
|
**Note**: Miss Cleo only tries to predict tests failures for uncommitted changes. Make sure your build is green before committing code!
|
58
61
|
|
62
|
+
|
63
|
+
## Known Oversights
|
64
|
+
|
65
|
+
Like the real Miss Cleo, we can't predict everything. Things we can't predict include:
|
66
|
+
- Rails views
|
67
|
+
- ActiveRecord methods
|
68
|
+
- ActiveRecord concerns
|
69
|
+
- Anything that generally runs only through gem code
|
70
|
+
- Any external library code
|
71
|
+
|
59
72
|
## Contributing
|
60
73
|
|
61
74
|
1. Fork it ( https://github.com/[my-github-username]/miss_cleo/fork )
|
data/bin/miss_cleo
CHANGED
@@ -49,53 +49,62 @@ def diff before, after
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
def
|
52
|
+
def build_coverage_map(cov_diffs)
|
53
53
|
cov_map = Hash.new { |h, file| h[file] = Hash.new { |i, line| i[line] = [] } }
|
54
|
+
cov_diffs.each do |args|
|
55
|
+
if args.length == 4 # for Minitest
|
56
|
+
desc = args.first(2).join('#')
|
57
|
+
else # for RSpec
|
58
|
+
desc = args.first
|
59
|
+
end
|
60
|
+
|
61
|
+
before, after = args.last(2)
|
62
|
+
|
63
|
+
# calculate the per test coverage
|
64
|
+
delta = diff before, after
|
65
|
+
|
66
|
+
delta.each_pair do |file, lines|
|
67
|
+
file_map = cov_map[file]
|
68
|
+
|
69
|
+
lines.each_with_index do |val, i|
|
70
|
+
# skip lines that weren't executed
|
71
|
+
next unless val && val > 0
|
54
72
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
return if content.empty?
|
59
|
-
# Read in the coverage info
|
60
|
-
JSON.parse(content).each do |args|
|
61
|
-
if args.length == 4 # for Minitest
|
62
|
-
desc = args.first(2).join('#')
|
63
|
-
else # for RSpec
|
64
|
-
desc = args.first
|
65
|
-
end
|
66
|
-
|
67
|
-
before, after = args.last(2)
|
68
|
-
|
69
|
-
# calculate the per test coverage
|
70
|
-
delta = diff before, after
|
71
|
-
|
72
|
-
delta.each_pair do |file, lines|
|
73
|
-
file_map = cov_map[file]
|
74
|
-
|
75
|
-
lines.each_with_index do |val, i|
|
76
|
-
# skip lines that weren't executed
|
77
|
-
next unless val && val > 0
|
78
|
-
|
79
|
-
# add the test name to the map. Multiple tests can execute the same
|
80
|
-
# line, so we need to use an array.
|
81
|
-
file_map[i + 1] << desc
|
82
|
-
end
|
83
|
-
end
|
73
|
+
# add the test name to the map. Multiple tests can execute the same
|
74
|
+
# line, so we need to use an array.
|
75
|
+
file_map[i + 1] << desc
|
84
76
|
end
|
85
77
|
end
|
86
78
|
end
|
87
79
|
cov_map
|
88
80
|
end
|
89
81
|
|
90
|
-
|
91
|
-
|
82
|
+
case ARGV.first
|
83
|
+
when "build_deck"
|
84
|
+
filenames = ARGV[1..-1]
|
85
|
+
coverage_diffs = []
|
86
|
+
filenames.each do |filename|
|
87
|
+
File.open(filename, "r") do |f|
|
88
|
+
f.read
|
89
|
+
end.tap do |contents|
|
90
|
+
coverage_diffs += JSON.parse(contents)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
coverage_map = build_coverage_map(coverage_diffs)
|
92
95
|
|
93
|
-
|
94
|
-
|
95
|
-
spec_map && spec_map[File.expand_path(file)].fetch(line, []).uniq.each do |desc|
|
96
|
-
puts desc
|
96
|
+
File.open("total_coverage_map.json", "w") do |f|
|
97
|
+
f.write(JSON.dump(coverage_map))
|
97
98
|
end
|
98
|
-
|
99
|
-
|
99
|
+
when "predict"
|
100
|
+
coverage_map = JSON.parse(File.open("total_coverage_map.json").read)
|
101
|
+
puts "You need to run"
|
102
|
+
tests_to_run = []
|
103
|
+
lines_to_run.each do |file, line|
|
104
|
+
coverage_map && coverage_map[File.expand_path(file)] && coverage_map[File.expand_path(file)].fetch(line.to_s, []).uniq.each do |desc|
|
105
|
+
tests_to_run << desc
|
106
|
+
end
|
100
107
|
end
|
108
|
+
puts tests_to_run.uniq.sort
|
101
109
|
end
|
110
|
+
|
data/lib/miss_cleo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miss_cleo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dean Hu
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-10-
|
12
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -90,3 +90,4 @@ signing_key:
|
|
90
90
|
specification_version: 4
|
91
91
|
summary: Predict your test failures
|
92
92
|
test_files: []
|
93
|
+
has_rdoc:
|