deep-cover 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.travis.yml +10 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +127 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/cov +43 -0
- data/bin/gemcov +8 -0
- data/bin/selfcov +21 -0
- data/bin/setup +8 -0
- data/bin/testall +88 -0
- data/deep_cover.gemspec +44 -0
- data/exe/deep-cover +6 -0
- data/future_read_me.md +108 -0
- data/lib/deep-cover.rb +1 -0
- data/lib/deep_cover.rb +11 -0
- data/lib/deep_cover/analyser.rb +24 -0
- data/lib/deep_cover/analyser/base.rb +51 -0
- data/lib/deep_cover/analyser/branch.rb +20 -0
- data/lib/deep_cover/analyser/covered_code_source.rb +31 -0
- data/lib/deep_cover/analyser/function.rb +12 -0
- data/lib/deep_cover/analyser/ignore_uncovered.rb +19 -0
- data/lib/deep_cover/analyser/node.rb +11 -0
- data/lib/deep_cover/analyser/per_char.rb +20 -0
- data/lib/deep_cover/analyser/per_line.rb +23 -0
- data/lib/deep_cover/analyser/statement.rb +31 -0
- data/lib/deep_cover/analyser/subset.rb +24 -0
- data/lib/deep_cover/auto_run.rb +49 -0
- data/lib/deep_cover/autoload_tracker.rb +75 -0
- data/lib/deep_cover/backports.rb +9 -0
- data/lib/deep_cover/base.rb +55 -0
- data/lib/deep_cover/builtin_takeover.rb +2 -0
- data/lib/deep_cover/cli/debugger.rb +93 -0
- data/lib/deep_cover/cli/deep_cover.rb +49 -0
- data/lib/deep_cover/cli/instrumented_clone_reporter.rb +105 -0
- data/lib/deep_cover/config.rb +52 -0
- data/lib/deep_cover/core_ext/autoload_overrides.rb +40 -0
- data/lib/deep_cover/core_ext/coverage_replacement.rb +26 -0
- data/lib/deep_cover/core_ext/load_overrides.rb +24 -0
- data/lib/deep_cover/core_ext/require_overrides.rb +36 -0
- data/lib/deep_cover/coverage.rb +198 -0
- data/lib/deep_cover/covered_code.rb +138 -0
- data/lib/deep_cover/custom_requirer.rb +93 -0
- data/lib/deep_cover/node.rb +8 -0
- data/lib/deep_cover/node/arguments.rb +50 -0
- data/lib/deep_cover/node/assignments.rb +250 -0
- data/lib/deep_cover/node/base.rb +99 -0
- data/lib/deep_cover/node/begin.rb +25 -0
- data/lib/deep_cover/node/block.rb +53 -0
- data/lib/deep_cover/node/boolean.rb +22 -0
- data/lib/deep_cover/node/branch.rb +28 -0
- data/lib/deep_cover/node/case.rb +94 -0
- data/lib/deep_cover/node/collections.rb +21 -0
- data/lib/deep_cover/node/const.rb +10 -0
- data/lib/deep_cover/node/def.rb +38 -0
- data/lib/deep_cover/node/empty_body.rb +21 -0
- data/lib/deep_cover/node/exceptions.rb +74 -0
- data/lib/deep_cover/node/if.rb +36 -0
- data/lib/deep_cover/node/keywords.rb +84 -0
- data/lib/deep_cover/node/literals.rb +77 -0
- data/lib/deep_cover/node/loops.rb +72 -0
- data/lib/deep_cover/node/mixin/can_augment_children.rb +65 -0
- data/lib/deep_cover/node/mixin/check_completion.rb +16 -0
- data/lib/deep_cover/node/mixin/child_can_be_empty.rb +25 -0
- data/lib/deep_cover/node/mixin/executed_after_children.rb +13 -0
- data/lib/deep_cover/node/mixin/execution_location.rb +56 -0
- data/lib/deep_cover/node/mixin/flow_accounting.rb +63 -0
- data/lib/deep_cover/node/mixin/has_child.rb +138 -0
- data/lib/deep_cover/node/mixin/has_child_handler.rb +73 -0
- data/lib/deep_cover/node/mixin/has_tracker.rb +44 -0
- data/lib/deep_cover/node/mixin/is_statement.rb +18 -0
- data/lib/deep_cover/node/mixin/rewriting.rb +32 -0
- data/lib/deep_cover/node/mixin/wrapper.rb +13 -0
- data/lib/deep_cover/node/module.rb +64 -0
- data/lib/deep_cover/node/root.rb +18 -0
- data/lib/deep_cover/node/send.rb +83 -0
- data/lib/deep_cover/node/splat.rb +13 -0
- data/lib/deep_cover/node/variables.rb +14 -0
- data/lib/deep_cover/parser_ext/range.rb +40 -0
- data/lib/deep_cover/reporter.rb +6 -0
- data/lib/deep_cover/reporter/istanbul.rb +151 -0
- data/lib/deep_cover/tools.rb +18 -0
- data/lib/deep_cover/tools/builtin_coverage.rb +50 -0
- data/lib/deep_cover/tools/camelize.rb +8 -0
- data/lib/deep_cover/tools/dump_covered_code.rb +32 -0
- data/lib/deep_cover/tools/execute_sample.rb +23 -0
- data/lib/deep_cover/tools/format.rb +16 -0
- data/lib/deep_cover/tools/format_char_cover.rb +18 -0
- data/lib/deep_cover/tools/format_generated_code.rb +25 -0
- data/lib/deep_cover/tools/number_lines.rb +18 -0
- data/lib/deep_cover/tools/our_coverage.rb +9 -0
- data/lib/deep_cover/tools/require_relative_dir.rb +10 -0
- data/lib/deep_cover/tools/silence_warnings.rb +15 -0
- data/lib/deep_cover/version.rb +3 -0
- metadata +326 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e0bfde5bb75505e45c28d6e28a2cf89464a0c5ad
|
4
|
+
data.tar.gz: effb8e5d1322f994532f65406ad867e5f6b0c30c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 267136d48b010079e4ddd88c35044757aa6eeafb8619e087b52669754e105ef66b7ecc34c6e5f4b3b53f0d94dc66190ea7a6f0f7c20add4a437511560621fd44
|
7
|
+
data.tar.gz: 70bb129eecdc023b306308076b722ccb07d6200fa38e0d305a00eb844d7ebb7bcbc2e7fb7f4c165793350a1880a9d285a077d5a3a3f0220f94b203c88ccbe1f7
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at github@marc-andre.ca. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Marc-Andre Lafortune
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,127 @@
|
|
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 the best coverage tool for Ruby code:
|
6
|
+
|
7
|
+
* more accurate line coverage
|
8
|
+
* branch coverage
|
9
|
+
* can be used as a drop-in replacement for the built-in Coverage library.
|
10
|
+
|
11
|
+
It reports a more accurate picture of your code usage. In particular a line is considered covered if and only if it is entirely executed:
|
12
|
+
|
13
|
+
```
|
14
|
+
def foo(something: false)
|
15
|
+
bar if something # => This is considered covered by builtin coverage,
|
16
|
+
# even though `bar` might not even exist
|
17
|
+
end
|
18
|
+
|
19
|
+
# somewhere in a test:
|
20
|
+
foo
|
21
|
+
```
|
22
|
+
|
23
|
+
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`)
|
24
|
+
|
25
|
+
```
|
26
|
+
def foo(x)
|
27
|
+
x = x.to_s if x.respond_to? :to_s
|
28
|
+
# ...
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_foo
|
32
|
+
assert_equal something, foo(42)
|
33
|
+
assert_equal something_else, foo(:hello)
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
## Installation
|
38
|
+
|
39
|
+
gem install deep-cover
|
40
|
+
|
41
|
+
DeepCover currently uses [`Istanbul`](https://istanbul.js.org/)'s reporter, so you'll need `node` and Istanbul's command line `nyc`:
|
42
|
+
|
43
|
+
yarn global add nyc # or npm install nyc -g
|
44
|
+
|
45
|
+
### Command line interface (for a Rails app or a Gem):
|
46
|
+
|
47
|
+
An easy way to check coverage, without any configuration needed:
|
48
|
+
|
49
|
+
deep-cover /path/to/rails/app/or/gem
|
50
|
+
|
51
|
+
This assumes your project has a `Gemfile`, and that your default `rake` task is set to execute all tests (otherwise set the `--command` option)
|
52
|
+
|
53
|
+
### Builtin Coverage (including SimpleCov) users
|
54
|
+
|
55
|
+
Add to your Gemfile `gem 'deep-cover'`, then run `bundle`.
|
56
|
+
|
57
|
+
Before you require `coverage` or `simplecov`, do a `require 'deep-cover/builtin_takeover'`.
|
58
|
+
|
59
|
+
For example, the `test/test_helper.rb` file for `simplecov` users will look like
|
60
|
+
|
61
|
+
```
|
62
|
+
require 'deep_cover/builtin_takeover'
|
63
|
+
require 'simplecov'
|
64
|
+
SimpleCov.start
|
65
|
+
# rest of `test_helper.rb`
|
66
|
+
```
|
67
|
+
|
68
|
+
## Usage
|
69
|
+
|
70
|
+
### Configuration
|
71
|
+
|
72
|
+
`configure` is used to specify how specific `DeepCover` should be and which files it should analyse. The following code reflects the default settings:
|
73
|
+
|
74
|
+
```
|
75
|
+
DeepCover.configure do
|
76
|
+
ignore_uncovered :raise, :default_arguments
|
77
|
+
detect_uncovered :trivial_if
|
78
|
+
# TODO
|
79
|
+
cover_paths %w[app lib]
|
80
|
+
end
|
81
|
+
```
|
82
|
+
|
83
|
+
### Low level usage
|
84
|
+
|
85
|
+
```
|
86
|
+
# Setup
|
87
|
+
require 'deep-cover'
|
88
|
+
DeepCover.configure { ignore_uncovered :trivial_if }
|
89
|
+
# Cover
|
90
|
+
DeepCover.cover do
|
91
|
+
require 'my_file_to_cover'
|
92
|
+
require 'my_other_file_to_cover'
|
93
|
+
end
|
94
|
+
require 'this_file_wont_be_covered'
|
95
|
+
tests.run()
|
96
|
+
puts DeepCover.line_coverage('foo')
|
97
|
+
```
|
98
|
+
|
99
|
+
## Development
|
100
|
+
|
101
|
+
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.
|
102
|
+
|
103
|
+
For detailed analysis:
|
104
|
+
|
105
|
+
`deep-cover -e "if(:try_me); puts 'cool'; end"`
|
106
|
+
|
107
|
+
To run one of the specs in `spec`:
|
108
|
+
|
109
|
+
`bin/cov boolean`
|
110
|
+
|
111
|
+
### Status
|
112
|
+
|
113
|
+
Currently in heavy development. *Alpha stage, API subject to change every day*. Best time to get involved though ;-)
|
114
|
+
|
115
|
+
## Contributing
|
116
|
+
|
117
|
+
Please ask questions on StackOverflow.com. Maintainers monitor the tag `deep-cover.rb`.
|
118
|
+
|
119
|
+
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.
|
120
|
+
|
121
|
+
## License
|
122
|
+
|
123
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
124
|
+
|
125
|
+
## Code of Conduct
|
126
|
+
|
127
|
+
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).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
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
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
module DeepCover
|
3
|
+
require "bundler/setup"
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift('../covered_deep_cover') if ENV["CC"]
|
6
|
+
require "deep_cover"
|
7
|
+
require_relative "../spec/specs_tools"
|
8
|
+
require 'deep_cover/cli/debugger'
|
9
|
+
|
10
|
+
example = ARGV[0] || 'simple_if'
|
11
|
+
fn = "./spec/samples/#{example}.rb"
|
12
|
+
fn = "./spec/char_cover/#{example}.rb" 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, pry: true).show
|
43
|
+
end
|
data/bin/gemcov
ADDED
data/bin/selfcov
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "bundler/setup"
|
3
|
+
require "pry"
|
4
|
+
|
5
|
+
covered_path = ARGV[0]
|
6
|
+
if covered_path
|
7
|
+
$LOAD_PATH.unshift(covered_path)
|
8
|
+
end
|
9
|
+
require "deep_cover"
|
10
|
+
|
11
|
+
if covered_path.nil?
|
12
|
+
covered_path = DeepCover::Tools.dump_covered_code('./lib', '../covered_deep_cover')
|
13
|
+
puts "Covered code generation done. Output in", covered_path
|
14
|
+
exec 'bin/selfcov', covered_path
|
15
|
+
else
|
16
|
+
coverage = DeepCover::Coverage.load(covered_path)
|
17
|
+
require 'rspec'
|
18
|
+
error = RSpec::Core::Runner::run(Dir.glob('./spec/*_spec.rb'))
|
19
|
+
puts "Lines not covered:", coverage.report
|
20
|
+
binding.pry
|
21
|
+
end
|
data/bin/setup
ADDED
data/bin/testall
ADDED
@@ -0,0 +1,88 @@
|
|
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 = 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
|