deep-cover 0.6.4 → 0.7.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.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deep-cover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc-André Lafortune
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-08-23 00:00:00.000000000 Z
12
+ date: 2018-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: deep-cover-core
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 0.6.4
20
+ version: 0.7.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 0.6.4
27
+ version: 0.7.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -54,33 +54,19 @@ dependencies:
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
- name: slop
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '4.0'
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '4.0'
70
- - !ruby/object:Gem::Dependency
71
- name: term-ansicolor
57
+ name: thor
72
58
  requirement: !ruby/object:Gem::Requirement
73
59
  requirements:
74
60
  - - ">="
75
61
  - !ruby/object:Gem::Version
76
- version: '0'
62
+ version: 0.20.3
77
63
  type: :runtime
78
64
  prerelease: false
79
65
  version_requirements: !ruby/object:Gem::Requirement
80
66
  requirements:
81
67
  - - ">="
82
68
  - !ruby/object:Gem::Version
83
- version: '0'
69
+ version: 0.20.3
84
70
  - !ruby/object:Gem::Dependency
85
71
  name: with_progress
86
72
  requirement: !ruby/object:Gem::Requirement
@@ -201,20 +187,23 @@ files:
201
187
  - LICENSE.txt
202
188
  - README.md
203
189
  - Rakefile
204
- - bin/console
205
- - bin/cov
206
- - bin/setup
207
- - bin/test_gems
208
- - bin/testall
209
190
  - deep_cover.gemspec
210
191
  - exe/deep-cover
211
- - future_read_me.md
212
- - lib/deep_cover/cli/debugger.rb
213
- - lib/deep_cover/cli/exec.rb
214
- - lib/deep_cover/cli/instrumented_clone_reporter.rb
215
- - lib/deep_cover/cli/runner.rb
216
- - lib/deep_cover/dump_covered_code.rb
217
- - lib/deep_cover_entry.rb
192
+ - lib/deep_cover/cli.rb
193
+ - lib/deep_cover/cli/commands/clear.rb
194
+ - lib/deep_cover/cli/commands/clone.rb
195
+ - lib/deep_cover/cli/commands/exec.rb
196
+ - lib/deep_cover/cli/commands/gather.rb
197
+ - lib/deep_cover/cli/commands/help.rb
198
+ - lib/deep_cover/cli/commands/merge.rb
199
+ - lib/deep_cover/cli/commands/report.rb
200
+ - lib/deep_cover/cli/commands/run_expression.rb
201
+ - lib/deep_cover/cli/commands/short_help.rb
202
+ - lib/deep_cover/cli/commands/version.rb
203
+ - lib/deep_cover/cli/tools.rb
204
+ - lib/deep_cover/cover_cloned_tree.rb
205
+ - lib/deep_cover/expression_debugger.rb
206
+ - lib/deep_cover/instrumented_clone_reporter.rb
218
207
  homepage: https://github.com/deep-cover/deep-cover
219
208
  licenses:
220
209
  - MIT
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'deep_cover'
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- require 'pry'
11
- Pry.start
12
-
13
- # require "irb"
14
- # IRB.start(__FILE__)
data/bin/cov DELETED
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env ruby
2
- module DeepCover
3
- require 'bundler/setup'
4
-
5
- require 'deep_cover'
6
- require_relative '../core_gem/spec/specs_tools'
7
- require 'deep_cover/cli/debugger'
8
-
9
- example = ARGV[0] || 'simple_if'
10
- fn = "./core_gem/spec/samples/#{example}.rb"
11
- fn = "./core_gem/spec/char_cover/#{example}.rb" unless File.exist?(fn)
12
- fn = example unless File.exist?(fn)
13
- if File.exist?(fn)
14
- fn = File.absolute_path(fn)
15
- source = File.read(fn)
16
- else
17
- fn = '<passed_from_command_line>'
18
- source = ARGV[0].gsub(';;', "\n")
19
- end
20
-
21
- groups = Specs::AnnotatedExamplesParser.process(source)
22
- if groups.size == 1 && groups.first.last.size == 1
23
- lines, lineno = groups.values.first.values.first
24
- else
25
- menu = []
26
- item = -1
27
- examples = groups.flat_map do |title, examples|
28
- menu << Term::ANSIColor.green(title) if title
29
- menu.concat(examples.keys.map { |ex| " #{item += 1}: #{ex || '(General)'}" })
30
- examples.values
31
- end
32
- if ARGV[1]
33
- answer = ARGV[1].to_i
34
- else
35
- require 'highline'
36
- puts menu
37
- answer = HighLine.new.ask(Term::ANSIColor.blue('Which? '), Integer) { |q| q.in = 0...examples.size }
38
- end
39
- lines, lineno = examples[answer]
40
- end
41
-
42
- CLI::Debugger.new(lines.join, filename: fn, lineno: lineno, debug: true, profile: ENV['PROF']).show
43
- end
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,54 +0,0 @@
1
- #!/usr/bin/env ruby
2
- $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
3
- require 'deep_cover'
4
-
5
- def gem_list
6
- return %w[erubis thor i18n builder tzinfo diff-lcs rack-test tilt multipart-post diff-lcs
7
- rubygems-bundler method_source daemons hike multi_json rails-deprecated_sanitizer slop
8
- rspec-support thread_safe rspec-core rspec-expectations rspec-mocks rspec mini_portile
9
- multi_json rspec-support rspec-expectations rspec-mocks mail nokogiri rack rspec unf
10
- json thread_safe rspec-core json rack-protection sdoc docile faraday multi_xml coderay
11
- mime-types net-scp multi_json turbolinks formatador coffee-script rack-test
12
- ] +
13
- %w[devise]
14
- # How I got those:
15
- require 'gems'
16
- Gems.most_downloaded
17
- .map(&:first) # discard nb downloads
18
- .map { |h| h['full_name'] } # get name-0.1.2
19
- .map { |n| n.rpartition('-').first } # => name
20
- end
21
-
22
- def install_gems
23
- gem_list.each do |n|
24
- system "gem install #{n}"
25
- end
26
- end
27
-
28
- # install_gems
29
-
30
- def test_gems
31
- gem_list.each do |n|
32
- puts "Require #{n}"
33
- begin
34
- DeepCover.cover { require n }
35
- rescue LoadError
36
- puts "Not sure how to load '#{n}'. Skipping"
37
- rescue Exception => ours
38
- begin
39
- require n
40
- rescue Exception => normal
41
- puts "Gem #{n} doesn't require normally. Skipping"
42
- else
43
- puts "DeepCover creates issue with Gem #{n}:\n#{ours}"
44
- end
45
- end
46
- end
47
- end
48
-
49
- test_gems
50
- # module DeepCover
51
-
52
- # # puts
53
- # names = Gems.most_downloaded
54
- # end
@@ -1,88 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # Will run rake test on every ruby version you have installed that matches the .travis-ci.yml
6
- #
7
- # This is a script that does basically what wwtd is meant to do (run tests following
8
- # the config in travis-ci), but:
9
- # * Only flow_entry_count the tests that are coded to be run from here
10
- # * ignores rails_head and ruby-head
11
- #
12
- # Other differences from wwtd:
13
- # * automatically installs the bundler gem if it is missing from a ruby version.
14
- #
15
- require 'term/ansicolor'
16
- require 'yaml'
17
- TRAVIS_CONFIG = '.travis.yml'
18
-
19
- def run_command(env_vars, command)
20
- puts "RUNNING: #{command} WITH: #{env_vars}"
21
- system(env_vars, command)
22
- end
23
-
24
- travis_yml = (File.exist?(TRAVIS_CONFIG) ? YAML.load_file(TRAVIS_CONFIG) : {})
25
- ruby_versions = travis_yml['rvm'] || []
26
- gemfiles = travis_yml['gemfile'] || [nil]
27
- matrix_options = travis_yml['matrix'] || {}
28
- matrix_include = matrix_options['include'] || []
29
- matrix_exclude = matrix_options['exclude'] || []
30
-
31
- configs = ruby_versions.product(gemfiles)
32
- matrix_include.each do |conf|
33
- configs << [conf['rvm'], conf['gemfile'] || nil]
34
- end
35
- matrix_exclude.each do |conf|
36
- configs.delete [conf['rvm'], conf['gemfile'] || nil]
37
- end
38
-
39
- rubies = {}
40
- results = []
41
-
42
- if (`which rvm`; $?.success?)
43
- ruby_exec = 'rvm-exec %{ruby_version} '
44
- elsif (`which chruby-exec`; $?.success?)
45
- ruby_exec = 'chruby-exec %{version} -- '
46
- end
47
-
48
- configs.each do |ruby_version, gemfile|
49
- next if ruby_version == 'ruby-head'
50
-
51
- current_ruby_exec = format(ruby_exec, ruby_version: ruby_version)
52
-
53
- env_vars = {'BUNDLE_GEMFILE' => gemfile, 'WITHOUT_PENDING' => ENV['WITHOUT_PENDING'] || '1'}
54
- gemfile_text = gemfile || 'Default gemfile'
55
- success = true
56
-
57
- if !rubies.include?(ruby_version)
58
- if (`#{current_ruby_exec} ruby -v`; $?.success?)
59
- if !system("#{current_ruby_exec} gem list -i '^bundler$' 1>/dev/null")
60
- success &&= run_command(env_vars, "#{current_ruby_exec} gem install bundler")
61
- end
62
- rubies[ruby_version] = true
63
- else
64
- rubies[ruby_version] = false
65
- end
66
- end
67
-
68
- if rubies[ruby_version] == false
69
- results << Term::ANSIColor.yellow("MISING RUBY: #{ruby_version} for #{gemfile_text}")
70
- next
71
- end
72
-
73
- if success
74
- bundle_installed = run_command(env_vars, "#{current_ruby_exec} bundle check 1>/dev/null 2>&1")
75
- bundle_installed ||= run_command(env_vars, "#{current_ruby_exec} bundle install --quiet 1>/dev/null 2>&1")
76
- bundle_installed ||= run_command(env_vars, "#{current_ruby_exec} bundle update --quiet")
77
- success &&= bundle_installed
78
- end
79
- success &&= run_command(env_vars, "#{current_ruby_exec} bundle exec rspec --format=progress") if success
80
-
81
- if success
82
- results << Term::ANSIColor.green("SUCCESS: #{ruby_version} for #{gemfile_text}")
83
- else
84
- results << Term::ANSIColor.red("FAILURE: #{ruby_version} for #{gemfile_text}")
85
- end
86
- end
87
-
88
- puts results
@@ -1,108 +0,0 @@
1
- [![Build Status](https://travis-ci.org/deep-cover/deep-cover.svg?branch=master)](https://travis-ci.org/deep-cover/deep-cover)
2
-
3
- # DeepCover
4
-
5
- Deep Cover aims to be an improved replacement for the built-in Coverage library.
6
-
7
- It will report a more accurate picture of your code usage. In particular a line is considered covered if and only if it is entirely executed:
8
-
9
- foo if false # => This is considered covered by builtin coverage, even though `foo` might not even exist
10
-
11
- Optionally, branch coverage will detect if some branches are never taken. In the following example, `test_foo` only provides values for `x` that respond to `:to_s`, thus the implicit `else` is never tested (i.e. a value of `x` that does not respond to `:to_s`)
12
-
13
- def foo(x)
14
- x = x.to_s if x.respond_to? :to_s
15
- # ...
16
- end
17
-
18
- def test_foo
19
- assert_equal something, foo(42)
20
- assert_equal something_else, foo(:hello)
21
- end
22
-
23
- ## Installation
24
-
25
- Add to your Gemfile:
26
-
27
- gem 'deep-cover'
28
-
29
- Then run:
30
-
31
- bundle
32
-
33
- ### Builtin Coverage (including SimpleCov) users
34
-
35
- Before you require `coverage` or `simplecov`, do a `require 'deep-cover/takeover'`.
36
-
37
- For example, the `test/test_helper.rb` file for `simplecov` users will look like
38
-
39
- ```
40
- require 'deep-cover/takeover'
41
- require 'simplecov'
42
- SimpleCov.start
43
- # rest of `test_helper.rb`
44
- ```
45
-
46
- ### Quick and dirty for Rails app or Gem:
47
-
48
- Assuming your default `rake` task is set to execute all tests, you can try:
49
-
50
- `deep-cover /path/to/rails/app/or/gem`
51
-
52
- ## Usage
53
-
54
- ### Configuration
55
-
56
- `configure` is used to specify how specific `DeepCover` should be and which files it should analyse. The following code reflects the default settings:
57
-
58
- ```
59
- DeepCover.configure do
60
- cover_paths %w[app lib]
61
- require_all_expression_in_line
62
- require_all_branches(false)
63
- accept_uncovered_raise(false)
64
- accept_uncovered_default_arguments(false)
65
- end
66
- ```
67
-
68
- ### Low level usage
69
-
70
- ```
71
- # Setup
72
- require 'deep-cover'
73
- DeepCover.configure { require_all_branches }
74
- # Cover
75
- DeepCover.cover do
76
- require 'my_file_to_cover'
77
- require 'my_other_file_to_cover'
78
- end
79
- require 'this_file_wont_be_covered'
80
- tests.run()
81
- DeepCover.report
82
- ```
83
-
84
- ## Development
85
-
86
- After checking out the repo, run `bundle` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
87
-
88
- For detailed analysis:
89
-
90
- `deep-cover -e "some.ruby(:code).here"`
91
-
92
- To run one of the specs in `spec`:
93
-
94
- `deep-cover -t boolean`
95
-
96
- ## Contributing
97
-
98
- Please ask questions on StackOverflow.com. Maintainers monitor the tag `deep-cover.rb`.
99
-
100
- Bug reports and pull requests are welcome on GitHub at https://github.com/deep-cover/deep-cover. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
101
-
102
- ## License
103
-
104
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
105
-
106
- ## Code of Conduct
107
-
108
- Everyone interacting in the DeepCover project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/deep-cover/deep-cover/blob/master/CODE_OF_CONDUCT.md).
@@ -1,127 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DeepCover
4
- require 'deep-cover'
5
- bootstrap
6
-
7
- module CLI
8
- class Debugger
9
- include Tools
10
-
11
- module ColorAST
12
- def fancy_type
13
- color = case
14
- when !executable?
15
- :faint
16
- when !was_executed?
17
- :red
18
- when flow_interrupt_count > 0
19
- :yellow
20
- else
21
- :green
22
- end
23
- Term::ANSIColor.send(color, super)
24
- end
25
- end
26
-
27
- attr_reader :options
28
- def initialize(source, filename: '(source)', lineno: 1, debug: false, **options)
29
- @source = source
30
- @filename = filename
31
- @lineno = lineno
32
- @debug = debug
33
- @options = options
34
- end
35
-
36
- def show
37
- Tools.profile(options[:profile]) do
38
- execute
39
- covered_code.freeze # Our output relies on the counts, so better freeze. See [#13]
40
- if @debug
41
- show_line_coverage
42
- show_instrumented_code
43
- show_ast
44
- end
45
- show_char_coverage
46
- end
47
- pry if @debug
48
- finish
49
- end
50
-
51
- def show_line_coverage
52
- output { "Line Coverage: Builtin | DeepCover | DeepCover Strict:\n" }
53
- begin
54
- builtin_line_coverage = builtin_coverage(@source, @filename, @lineno)
55
- our_line_coverage = our_coverage(@source, @filename, @lineno, **options)
56
- our_strict_line_coverage = our_coverage(@source, @filename, @lineno, allow_partial: false, **options)
57
- output do
58
- lines = format(builtin_line_coverage, our_line_coverage, our_strict_line_coverage, source: @source)
59
- number_lines(lines, lineno: @lineno)
60
- end
61
- rescue Exception => e
62
- output { "Can't run coverage: #{e.class}: #{e}\n#{e.backtrace.join("\n")}" }
63
- @failed = true
64
- end
65
- end
66
-
67
- def show_instrumented_code
68
- output { "\nInstrumented code:\n" }
69
- output { format_generated_code(covered_code) }
70
- end
71
-
72
- def show_ast
73
- output { "\nParsed code:\n" }
74
- Node.prepend ColorAST
75
- output { covered_code.covered_ast }
76
- end
77
-
78
- def show_char_coverage
79
- output { "\nNode coverage:\n" }
80
-
81
- output { format_char_cover(covered_code, show_whitespace: !!ENV['W'], **options) }
82
- end
83
-
84
- def pry
85
- a = covered_code.covered_ast
86
- b = a.children.first
87
- ::DeepCover.load_pry
88
- binding.pry
89
- end
90
-
91
- def finish
92
- exit(!@failed)
93
- end
94
-
95
- def covered_code
96
- @covered_code ||= CoveredCode.new(source: @source, path: @filename, lineno: @lineno)
97
- end
98
-
99
- def execute
100
- execute_sample(covered_code)
101
- # output { trace_counts } # Keep for low-level debugging purposes
102
- rescue Exception => e
103
- output { "Can't `execute_sample`:#{e.class}: #{e}\n#{e.backtrace.join("\n")}" }
104
- @failed = true
105
- end
106
-
107
- def trace_counts
108
- all = []
109
- trace = TracePoint.new(:call) do |tr|
110
- if %i[flow_entry_count flow_completion_count execution_count].include? tr.method_id
111
- node = tr.self
112
- str = "#{node.type} #{(node.value if node.respond_to?(:value))} #{tr.method_id}"
113
- all << str unless all.last == str
114
- end
115
- end
116
- trace.enable { covered_code.freeze }
117
- all
118
- end
119
-
120
- def output
121
- Tools.dont_profile do
122
- puts yield
123
- end
124
- end
125
- end
126
- end
127
- end