solargraph_test_coverage 0.1.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +2 -6
- data/README.md +22 -16
- data/Rakefile +4 -2
- data/lib/solargraph_test_coverage/config.rb +81 -0
- data/lib/solargraph_test_coverage/helpers.rb +63 -19
- data/lib/solargraph_test_coverage/test_coverage_reporter.rb +54 -27
- data/lib/solargraph_test_coverage/test_runner.rb +55 -0
- data/lib/solargraph_test_coverage/version.rb +3 -1
- data/lib/solargraph_test_coverage.rb +9 -11
- data/solargraph_test_coverage.gemspec +5 -4
- metadata +9 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecd6c766dce692dd3817bffae0044eb53f3a85b016865bc32e3a699f9e1c706f
|
4
|
+
data.tar.gz: ad27ec8345225e6d9538b6debdaf68ea0621ef810bc49f65dd321c4f62566753
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee3a2a267a8afbe5f43e6ade8a267d6ea7ce320c06a04811cf5828a34771758f7720b97cfa0d1159f6abfe6f6139d4dccfa0101c8aed2c74332e9b6dc1a8e441
|
7
|
+
data.tar.gz: edc5b1ff123b4e22120146494bf0fad32a498d6fea12af00a53d1390f81f4cd693d158ae60da44edd489019b7fc85dfd05edbd58019631df6c068e7e9750d577
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
solargraph_test_coverage (0.
|
5
|
-
rspec-core (~> 3.10, >= 3.10.0)
|
4
|
+
solargraph_test_coverage (0.2.1)
|
6
5
|
solargraph (~> 0.40, > 0.40)
|
7
6
|
|
8
7
|
GEM
|
@@ -18,7 +17,7 @@ GEM
|
|
18
17
|
rexml
|
19
18
|
kramdown-parser-gfm (1.1.0)
|
20
19
|
kramdown (~> 2.0)
|
21
|
-
nokogiri (1.12.
|
20
|
+
nokogiri (1.12.4-x86_64-darwin)
|
22
21
|
racc (~> 1.4)
|
23
22
|
parallel (1.20.1)
|
24
23
|
parser (3.0.2.0)
|
@@ -30,9 +29,6 @@ GEM
|
|
30
29
|
reverse_markdown (2.0.0)
|
31
30
|
nokogiri
|
32
31
|
rexml (3.2.5)
|
33
|
-
rspec-core (3.10.1)
|
34
|
-
rspec-support (~> 3.10.0)
|
35
|
-
rspec-support (3.10.2)
|
36
32
|
rubocop (1.20.0)
|
37
33
|
parallel (~> 1.10)
|
38
34
|
parser (>= 3.0.0.0)
|
data/README.md
CHANGED
@@ -2,7 +2,12 @@
|
|
2
2
|
|
3
3
|
Solargraph Plugin that provides a diagnostic reporter for unit-test coverage.
|
4
4
|
|
5
|
-
Currently
|
5
|
+
Currently there are four different diagnostics:
|
6
|
+
- Line is not covered
|
7
|
+
- Branch is not covered (With a note if it's the 'THEN' or 'ELSE' branch)
|
8
|
+
- Spec is failing (Error message will be on line 1)
|
9
|
+
- Spec cannot be found (Error message will be on line 1)
|
10
|
+
|
6
11
|
|
7
12
|
## Installation
|
8
13
|
|
@@ -13,6 +18,7 @@ gem 'solargraph_test_coverage'
|
|
13
18
|
```
|
14
19
|
|
15
20
|
Then add this to your `.solargraph.yml` config:
|
21
|
+
|
16
22
|
```yaml
|
17
23
|
plugins:
|
18
24
|
- solargraph_test_coverage
|
@@ -20,16 +26,22 @@ reporters:
|
|
20
26
|
- test_coverage
|
21
27
|
```
|
22
28
|
|
23
|
-
|
24
|
-
|
25
|
-
|
29
|
+
Additionally, a `test_coverage` key can be added to `.solargraph.yml`. The default values are shown below:
|
30
|
+
|
31
|
+
```yaml
|
32
|
+
test_coverage:
|
33
|
+
preload_rails: true
|
34
|
+
test_framework: rspec # or minitest
|
35
|
+
coverage:
|
36
|
+
- line
|
37
|
+
- branch
|
38
|
+
- test_failing
|
39
|
+
- test_missing
|
40
|
+
exclude_paths:
|
41
|
+
- 'app/controller'
|
26
42
|
```
|
27
43
|
|
28
|
-
to
|
29
44
|
|
30
|
-
```ruby
|
31
|
-
require_relative "spec_helper"
|
32
|
-
```
|
33
45
|
|
34
46
|
And then execute:
|
35
47
|
|
@@ -41,18 +53,12 @@ Or install it yourself as:
|
|
41
53
|
|
42
54
|
## Usage
|
43
55
|
|
44
|
-
With solargraph running and connected to your text editor, you should see diagnostic messages for test
|
45
|
-
|
46
|
-
Currently there are four different messages:
|
47
|
-
- Line is not covered
|
48
|
-
- Branch is not covered (With a note if it's the 'THEN' or 'ELSE' branch)
|
49
|
-
- Spec is failing (Error message will be on line 1)
|
50
|
-
- Spec cannot be found (Error message will be on line 1)
|
56
|
+
With solargraph running and connected to your text editor, you should see diagnostic messages for line coverage, branch coverage, test file presence, and test status (if it's failing)
|
51
57
|
|
52
58
|
|
53
59
|
## Contributing
|
54
60
|
|
55
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
61
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/deepdivr/solargraph_test_coverage.
|
56
62
|
|
57
63
|
|
58
64
|
## License
|
data/Rakefile
CHANGED
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# frozen_string_literal = true
|
4
|
+
|
5
|
+
module SolargraphTestCoverage
|
6
|
+
class Config
|
7
|
+
class << self
|
8
|
+
DEFAULTS = {
|
9
|
+
'preload_rails' => true, # can be true or false - performance optimization
|
10
|
+
'test_framework' => 'rspec', # can be 'rspec' or 'minitest'
|
11
|
+
'coverage' => [ # All diagnostics are enabled by default
|
12
|
+
'line', # Specifying an array with fewer diagnostics will overwrite this
|
13
|
+
'branch',
|
14
|
+
'test_failing',
|
15
|
+
'test_missing'
|
16
|
+
],
|
17
|
+
'exclude_paths' => [ # don't attempt to find/run a spec for files that match these paths
|
18
|
+
'app/controller'
|
19
|
+
]
|
20
|
+
}.freeze
|
21
|
+
|
22
|
+
def preload_rails?
|
23
|
+
plugin_config['preload_rails']
|
24
|
+
end
|
25
|
+
|
26
|
+
def exclude_paths
|
27
|
+
plugin_config['exclude_paths']
|
28
|
+
end
|
29
|
+
|
30
|
+
def line_coverage?
|
31
|
+
plugin_config['coverage'].include? 'line'
|
32
|
+
end
|
33
|
+
|
34
|
+
def branch_coverage?
|
35
|
+
plugin_config['coverage'].include? 'branch'
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_failing_coverage?
|
39
|
+
plugin_config['coverage'].include? 'test_failing'
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_missing_coverage?
|
43
|
+
plugin_config['coverage'].include? 'test_missing'
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_framework
|
47
|
+
plugin_config['test_framework']
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_dir
|
51
|
+
case test_framework
|
52
|
+
when 'rspec'
|
53
|
+
'spec'
|
54
|
+
when 'minitest'
|
55
|
+
'test'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_file_suffix
|
60
|
+
case test_framework
|
61
|
+
when 'rspec'
|
62
|
+
'_spec.rb'
|
63
|
+
when 'minitest'
|
64
|
+
'_test.rb'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def plugin_config
|
71
|
+
@plugin_config ||= workspace_config.tap do |config|
|
72
|
+
DEFAULTS.each_key { |key| config[key] = DEFAULTS[key] unless config.key?(key) }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def workspace_config
|
77
|
+
Solargraph::Workspace::Config.new(Dir.pwd).raw_data.fetch('test_coverage', {})
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -1,34 +1,43 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module SolargraphTestCoverage
|
4
|
+
# Some helper functions for the diagnostics
|
4
5
|
module Helpers
|
6
|
+
# Determines if a file should be excluded from running diagnostics
|
7
|
+
# @return [Boolean]
|
5
8
|
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
def exclude_file?(source_filename)
|
10
|
+
return true if source_filename.start_with? Helpers.test_path
|
11
|
+
|
12
|
+
Config.exclude_paths.each { |path| return true if source_filename.sub(Dir.pwd, '').include? path }
|
13
|
+
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
# Attempts to find the corresponding unit test file
|
10
18
|
# @return [String]
|
11
19
|
#
|
12
|
-
def
|
13
|
-
source.location.filename.sub(
|
20
|
+
def test_file(source)
|
21
|
+
relative_filepath = source.location.filename.sub(Dir.pwd, '').split('/').reject(&:empty?)
|
22
|
+
relative_filepath[0] = Config.test_dir
|
23
|
+
|
24
|
+
File.join(Dir.pwd, relative_filepath.join('/'))
|
25
|
+
.sub('.rb', Config.test_file_suffix)
|
14
26
|
end
|
15
27
|
|
16
|
-
#
|
17
|
-
# Runs RSpec on test file in a child process
|
28
|
+
# Runs test file in a child process with specified testing framework
|
18
29
|
# Returns coverage results for current working file
|
19
|
-
# RSpec::Core::Runner.run will return 0 if the test file passes, and 1 if it does not.
|
20
30
|
#
|
21
31
|
# @return [Hash]
|
22
32
|
#
|
23
|
-
def
|
33
|
+
def run_test(source)
|
24
34
|
ForkProcess.run do
|
25
35
|
Coverage.start(lines: true, branches: true)
|
26
|
-
|
27
|
-
Coverage.result.fetch(source.location.filename, {}).merge({ test_status:
|
36
|
+
runner = TestRunner.with(test_file(source)).run!
|
37
|
+
Coverage.result.fetch(source.location.filename, {}).merge({ test_status: runner.passed? })
|
28
38
|
end
|
29
39
|
end
|
30
40
|
|
31
|
-
#
|
32
41
|
# Adapted from SingleCov
|
33
42
|
# Coverage returns nil for untestable lines (like do, end, if keywords)
|
34
43
|
# otherwise returns int showing how many times a line was called
|
@@ -40,12 +49,11 @@ module SolargraphTestCoverage
|
|
40
49
|
def uncovered_lines(results)
|
41
50
|
results.fetch(:lines)
|
42
51
|
.each_with_index
|
43
|
-
.select { |c, _| c
|
52
|
+
.select { |c, _| c&.zero? }
|
44
53
|
.map { |_, i| i }
|
45
54
|
.compact
|
46
55
|
end
|
47
56
|
|
48
|
-
#
|
49
57
|
# Builds a new Branch object for each branch tested from results hash
|
50
58
|
# Then removes branches which have test coverage
|
51
59
|
#
|
@@ -55,7 +63,27 @@ module SolargraphTestCoverage
|
|
55
63
|
Branch.build_from(results).reject(&:covered?)
|
56
64
|
end
|
57
65
|
|
66
|
+
# Builds a range for warnings/errors
|
67
|
+
# @return [Hash]
|
58
68
|
#
|
69
|
+
def range(start_line, start_column, end_line, end_column)
|
70
|
+
Solargraph::Range.from_to(start_line, start_column, end_line, end_column).to_hash
|
71
|
+
end
|
72
|
+
|
73
|
+
# requires the specified testing framework
|
74
|
+
# @return [Boolean]
|
75
|
+
#
|
76
|
+
def self.require_testing_framework!
|
77
|
+
case Config.test_framework
|
78
|
+
when 'rspec'
|
79
|
+
require 'rspec/core'
|
80
|
+
when 'minitest'
|
81
|
+
require 'minitest/autorun'
|
82
|
+
else
|
83
|
+
raise UnknownTestingGem
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
59
87
|
# Only called once, when gem is loaded
|
60
88
|
# Preloads rails via spec/rails_helper if Rails isn't already defined
|
61
89
|
# This gives us a nice speed-boost when running test in child process
|
@@ -63,21 +91,37 @@ module SolargraphTestCoverage
|
|
63
91
|
# We rescue the LoadError since Solargraph would catch it otherwise,
|
64
92
|
# and not load the plugin at all.
|
65
93
|
#
|
94
|
+
# Adding the spec/ directory to the $LOAD_PATH lets 'require "spec_helper"'
|
95
|
+
# commonly found in rails_helper work.
|
96
|
+
#
|
66
97
|
# If Coverage was started in Rails/Spec helper by SimpleCov,
|
67
98
|
# calling Coverage.result after requiring stops and resets it.
|
68
99
|
#
|
69
100
|
# This is a bit experimental - I'm not sure if there will be downstream side-effects
|
70
|
-
#
|
101
|
+
#
|
102
|
+
# @return [Boolean]
|
71
103
|
#
|
72
104
|
def self.preload_rails!
|
73
|
-
return if defined?(Rails)
|
74
|
-
|
105
|
+
return if defined?(Rails) || !File.file?('spec/rails_helper.rb')
|
106
|
+
|
107
|
+
$LOAD_PATH.unshift(test_path) unless $LOAD_PATH.include?(test_path)
|
75
108
|
|
76
|
-
require File.
|
109
|
+
require File.join(test_path, 'rails_helper')
|
77
110
|
Coverage.result(stop: true, clear: true) if Coverage.running?
|
111
|
+
|
112
|
+
true
|
78
113
|
rescue LoadError => e
|
79
114
|
Solargraph::Logging.logger.warn "LoadError when trying to require 'rails_helper'"
|
80
115
|
Solargraph::Logging.logger.warn "[#{e.class}] #{e.message}"
|
116
|
+
|
117
|
+
false
|
118
|
+
end
|
119
|
+
|
120
|
+
# Returns absolute path for test folder
|
121
|
+
# @return [String]
|
122
|
+
#
|
123
|
+
def self.test_path
|
124
|
+
File.join(Dir.pwd, Config.test_dir)
|
81
125
|
end
|
82
126
|
end
|
83
127
|
end
|
@@ -5,71 +5,96 @@ module SolargraphTestCoverage
|
|
5
5
|
class TestCoverageReporter < Solargraph::Diagnostics::Base
|
6
6
|
include Helpers
|
7
7
|
|
8
|
-
#
|
9
8
|
# LSP Diagnostic method
|
10
|
-
#
|
11
9
|
# @return [Array]
|
12
10
|
#
|
13
11
|
def diagnose(source, _api_map)
|
14
|
-
return [] if source.code.empty? ||
|
15
|
-
|
16
|
-
test_file = locate_test_file(source)
|
17
|
-
return [no_test_file_error(source, test_file)] unless File.file?(test_file)
|
18
|
-
|
19
|
-
results = run_rspec(source, test_file)
|
20
|
-
lines = uncovered_lines(results).map { |line| line_coverage_warning(source, line) }
|
21
|
-
branches = uncovered_branches(results).map { |branch| branch_coverage_warning(source, branch.report) }
|
22
|
-
status = results[:test_status].zero? ? [] : [test_failing_error(source)]
|
12
|
+
return [] if source.code.empty? || exclude_file?(source.location.filename)
|
13
|
+
return [test_missing_error(source)] unless File.file?(test_file(source))
|
23
14
|
|
24
|
-
|
15
|
+
results = run_test(source)
|
16
|
+
messages(source, results)
|
25
17
|
rescue ChildFailedError
|
26
18
|
[]
|
27
19
|
end
|
28
20
|
|
29
21
|
private
|
30
22
|
|
23
|
+
# Compiles all diagnostic messages for source file
|
24
|
+
# @return [Array]
|
31
25
|
#
|
32
|
-
|
26
|
+
def messages(source, results)
|
27
|
+
messages = [
|
28
|
+
line_warnings(source, results),
|
29
|
+
branch_warnings(source, results),
|
30
|
+
test_passing_error(source, results)
|
31
|
+
]
|
32
|
+
|
33
|
+
messages.flatten.compact
|
34
|
+
end
|
35
|
+
|
36
|
+
# Creates array of warnings for uncovered lines
|
37
|
+
# @return [Array]
|
38
|
+
#
|
39
|
+
def line_warnings(source, results)
|
40
|
+
uncovered_lines(results).map { |line| line_coverage_warning(source, line) }
|
41
|
+
end
|
42
|
+
|
43
|
+
# Creates array of warnings for uncovered branches
|
44
|
+
# @return [Array]
|
33
45
|
#
|
46
|
+
def branch_warnings(source, results)
|
47
|
+
uncovered_branches(results).map { |branch| branch_coverage_warning(source, branch.report) }
|
48
|
+
end
|
49
|
+
|
50
|
+
# Creates array containing error for failing spec
|
51
|
+
# @return [Array]
|
52
|
+
#
|
53
|
+
def test_passing_error(source, results)
|
54
|
+
results[:test_status] ? [] : [test_failing_error(source)]
|
55
|
+
end
|
56
|
+
|
57
|
+
# Creates LSP warning message for missing line coverage
|
34
58
|
# @return [Hash]
|
35
59
|
#
|
36
60
|
def line_coverage_warning(source, line)
|
61
|
+
return unless Config.line_coverage?
|
62
|
+
|
37
63
|
{
|
38
|
-
range:
|
64
|
+
range: range(line, 0, line, source.code.lines[line].length),
|
39
65
|
severity: Solargraph::Diagnostics::Severities::WARNING,
|
40
66
|
source: 'TestCoverage',
|
41
67
|
message: 'Line is missing test coverage'
|
42
68
|
}
|
43
69
|
end
|
44
70
|
|
45
|
-
#
|
46
71
|
# Creates LSP warning message for missing branch coverage
|
47
|
-
#
|
48
|
-
# starts counting lines at 1, while the LSP (source.code.line) is an array
|
49
|
-
# with an index starting at 0
|
72
|
+
# Line numbers are off by 1, since Branch Coverage starts counting at 1, not 0
|
50
73
|
#
|
51
74
|
# @return [Hash]
|
52
75
|
#
|
53
76
|
def branch_coverage_warning(source, report)
|
77
|
+
return unless Config.branch_coverage?
|
78
|
+
|
54
79
|
{
|
55
|
-
range:
|
80
|
+
range: range(report[:line] - 1, 0, report[:line] - 1, source.code.lines[report[:line] - 1].length),
|
56
81
|
severity: Solargraph::Diagnostics::Severities::WARNING,
|
57
82
|
source: 'TestCoverage',
|
58
83
|
message: "'#{report[:type].upcase}' branch is missing test coverage"
|
59
84
|
}
|
60
85
|
end
|
61
86
|
|
62
|
-
#
|
63
|
-
# Creates LSP error message if test is failing
|
64
|
-
#
|
87
|
+
# Creates LSP error message if test file is failing
|
65
88
|
# @return [Hash]
|
66
89
|
#
|
67
90
|
def test_failing_error(source)
|
91
|
+
return unless Config.test_failing_coverage?
|
92
|
+
|
68
93
|
{
|
69
|
-
range:
|
94
|
+
range: range(0, 0, 0, source.code.lines[0].length),
|
70
95
|
severity: Solargraph::Diagnostics::Severities::ERROR,
|
71
96
|
source: 'TestCoverage',
|
72
|
-
message:
|
97
|
+
message: 'Unit Test is currently failing.'
|
73
98
|
}
|
74
99
|
end
|
75
100
|
|
@@ -78,12 +103,14 @@ module SolargraphTestCoverage
|
|
78
103
|
#
|
79
104
|
# @return [Hash]
|
80
105
|
#
|
81
|
-
def
|
106
|
+
def test_missing_error(source)
|
107
|
+
return unless Config.test_missing_coverage?
|
108
|
+
|
82
109
|
{
|
83
|
-
range:
|
110
|
+
range: range(0, 0, 0, source.code.lines[0].length),
|
84
111
|
severity: Solargraph::Diagnostics::Severities::ERROR,
|
85
112
|
source: 'TestCoverage',
|
86
|
-
message: "No unit test file found at #{
|
113
|
+
message: "No unit test file found at #{test_file(source)}"
|
87
114
|
}
|
88
115
|
end
|
89
116
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolargraphTestCoverage
|
4
|
+
# Parent Class for different testing frameworks
|
5
|
+
class TestRunner
|
6
|
+
def self.with(test_file)
|
7
|
+
case Config.test_framework
|
8
|
+
when 'rspec'
|
9
|
+
RSpecRunner.new(test_file)
|
10
|
+
when 'minitest'
|
11
|
+
MinitestRunner.new(test_file)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(test_file)
|
16
|
+
@test_file = test_file
|
17
|
+
@result = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def run!
|
21
|
+
@result = test_framework_runner.run([@test_file])
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
def passed?
|
26
|
+
raise NotImplementedError
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_framework_runner
|
30
|
+
raise NotImplementedError
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Test Runner Subclass for RSpec
|
35
|
+
class RSpecRunner < TestRunner
|
36
|
+
def passed?
|
37
|
+
@result&.zero?
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_framework_runner
|
41
|
+
RSpec::Core::Runner
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Test Runner Subclass for Minitest
|
46
|
+
class MinitestRunner < TestRunner
|
47
|
+
def passed?
|
48
|
+
@result
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_framework_runner
|
52
|
+
Minitest
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,25 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'solargraph_test_coverage/version'
|
2
4
|
require 'solargraph_test_coverage/branch'
|
3
5
|
require 'solargraph_test_coverage/fork_process'
|
4
6
|
require 'solargraph_test_coverage/helpers'
|
7
|
+
require 'solargraph_test_coverage/config'
|
8
|
+
require 'solargraph_test_coverage/test_runner'
|
5
9
|
require 'solargraph_test_coverage/test_coverage_reporter'
|
6
10
|
|
7
11
|
require 'solargraph'
|
8
|
-
require 'rspec/core'
|
9
12
|
require 'coverage'
|
10
|
-
require 'pry-byebug'
|
11
|
-
|
12
|
-
# TODO
|
13
|
-
# - Finding the right file could use some work
|
14
|
-
# - Config Options for different errors (line, branch, test missing, test failing)
|
15
|
-
# - Minitest/Cucumber Support
|
16
|
-
# - app/lib support
|
17
|
-
# - filter out stuff like controllers that wouldn't have tests
|
18
|
-
# - Publish Gem to Rubygems
|
19
13
|
|
20
14
|
module SolargraphTestCoverage
|
21
15
|
class ChildFailedError < StandardError; end
|
22
|
-
|
16
|
+
|
17
|
+
class UnknownTestingGem < StandardError; end
|
18
|
+
|
19
|
+
Helpers.require_testing_framework!
|
20
|
+
Helpers.preload_rails! if Config.preload_rails?
|
23
21
|
|
24
22
|
Solargraph::Diagnostics.register 'test_coverage', TestCoverageReporter
|
25
23
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'lib/solargraph_test_coverage/version'
|
2
4
|
|
3
5
|
Gem::Specification.new do |spec|
|
@@ -8,11 +10,11 @@ Gem::Specification.new do |spec|
|
|
8
10
|
|
9
11
|
spec.summary = 'Solargraph Plugin'
|
10
12
|
spec.description = 'Solargraph Plugin that reports line/branch coverage from unit tests'
|
11
|
-
spec.homepage = 'https://github.com/
|
13
|
+
spec.homepage = 'https://github.com/deepdivr/solargraph_test_coverage'
|
12
14
|
spec.license = 'MIT'
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
|
14
16
|
|
15
|
-
spec.metadata['allowed_push_host'] =
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
16
18
|
|
17
19
|
spec.metadata['homepage_uri'] = spec.homepage
|
18
20
|
spec.metadata['source_code_uri'] = spec.homepage
|
@@ -29,5 +31,4 @@ Gem::Specification.new do |spec|
|
|
29
31
|
spec.require_paths = ['lib']
|
30
32
|
|
31
33
|
spec.add_runtime_dependency 'solargraph', '~> 0.40', '> 0.40'
|
32
|
-
spec.add_runtime_dependency 'rspec-core', '~> 3.10', '>= 3.10.0'
|
33
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solargraph_test_coverage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Kolkey
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solargraph
|
@@ -30,26 +30,6 @@ dependencies:
|
|
30
30
|
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '0.40'
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: rspec-core
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - ">="
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: 3.10.0
|
40
|
-
- - "~>"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '3.10'
|
43
|
-
type: :runtime
|
44
|
-
prerelease: false
|
45
|
-
version_requirements: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - ">="
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: 3.10.0
|
50
|
-
- - "~>"
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '3.10'
|
53
33
|
description: Solargraph Plugin that reports line/branch coverage from unit tests
|
54
34
|
email:
|
55
35
|
- Cameron.Kolkey@gmail.com
|
@@ -66,19 +46,21 @@ files:
|
|
66
46
|
- Rakefile
|
67
47
|
- lib/solargraph_test_coverage.rb
|
68
48
|
- lib/solargraph_test_coverage/branch.rb
|
49
|
+
- lib/solargraph_test_coverage/config.rb
|
69
50
|
- lib/solargraph_test_coverage/fork_process.rb
|
70
51
|
- lib/solargraph_test_coverage/helpers.rb
|
71
52
|
- lib/solargraph_test_coverage/test_coverage_reporter.rb
|
53
|
+
- lib/solargraph_test_coverage/test_runner.rb
|
72
54
|
- lib/solargraph_test_coverage/version.rb
|
73
55
|
- solargraph_test_coverage.gemspec
|
74
|
-
homepage: https://github.com/
|
56
|
+
homepage: https://github.com/deepdivr/solargraph_test_coverage
|
75
57
|
licenses:
|
76
58
|
- MIT
|
77
59
|
metadata:
|
78
60
|
allowed_push_host: https://rubygems.org
|
79
|
-
homepage_uri: https://github.com/
|
80
|
-
source_code_uri: https://github.com/
|
81
|
-
changelog_uri: https://github.com/
|
61
|
+
homepage_uri: https://github.com/deepdivr/solargraph_test_coverage
|
62
|
+
source_code_uri: https://github.com/deepdivr/solargraph_test_coverage
|
63
|
+
changelog_uri: https://github.com/deepdivr/solargraph_test_coverage
|
82
64
|
post_install_message:
|
83
65
|
rdoc_options: []
|
84
66
|
require_paths:
|
@@ -87,7 +69,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
69
|
requirements:
|
88
70
|
- - ">="
|
89
71
|
- !ruby/object:Gem::Version
|
90
|
-
version: 2.
|
72
|
+
version: 2.6.0
|
91
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
74
|
requirements:
|
93
75
|
- - ">="
|