coveralls-gcov 0.1.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 +7 -0
- data/.gitignore +35 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +36 -0
- data/README.md +40 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/coveralls-gcov.gemspec +27 -0
- data/exe/coveralls-gcov +47 -0
- data/lib/coveralls/gcov/runner.rb +168 -0
- data/lib/coveralls/gcov/version.rb +5 -0
- data/lib/coveralls/gcov.rb +2 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fac75447cff9dd05db9245dcc477278f7840b865
|
4
|
+
data.tar.gz: f27cb5d204b4de02ec64c7466b26283e5154646e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8ea95abe0e5d23f34071dd09133438ad7c33267416f3d88bcc1a2295571489ee0510448312fbd3e455c8d49d2dcd6e8308fe3f376443a90c14b3cc95f70c6eac
|
7
|
+
data.tar.gz: 6dde54cf36776ea269b56683788c395b65365cbfea3770bb8663cdcc4bd87aefd66450c7b12f1d33695ce1bf581b8079581fa19ba09d2b3632eb277d1bdd7b83
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/vendor/
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
# Gemfile.lock
|
31
|
+
# .ruby-version
|
32
|
+
# .ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
coveralls-gcov (0.1.0)
|
5
|
+
commander
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
commander (4.3.4)
|
11
|
+
highline (~> 1.7.2)
|
12
|
+
diff-lcs (1.2.5)
|
13
|
+
highline (1.7.2)
|
14
|
+
rake (10.4.2)
|
15
|
+
rspec (3.2.0)
|
16
|
+
rspec-core (~> 3.2.0)
|
17
|
+
rspec-expectations (~> 3.2.0)
|
18
|
+
rspec-mocks (~> 3.2.0)
|
19
|
+
rspec-core (3.2.3)
|
20
|
+
rspec-support (~> 3.2.0)
|
21
|
+
rspec-expectations (3.2.1)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.2.0)
|
24
|
+
rspec-mocks (3.2.1)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.2.0)
|
27
|
+
rspec-support (3.2.2)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
bundler (~> 1.9)
|
34
|
+
coveralls-gcov!
|
35
|
+
rake (~> 10.0)
|
36
|
+
rspec
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Coveralls::Gcov
|
2
|
+
|
3
|
+
Upload coverage information generated by Gcov to coveralls.io.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'coveralls-gcov'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install coveralls-gcov
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```shell
|
24
|
+
coveralls-gcov [send] [--repo-token TOKEN] [--root DIR] [--exclude DIR|FILE] [--exclude-pattern REGEXP] [--extension EXT] [--no-gcov]
|
25
|
+
|
26
|
+
```
|
27
|
+
|
28
|
+
## Development
|
29
|
+
|
30
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
31
|
+
|
32
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it ( https://github.com/[my-github-username]/coveralls-gcov/fork )
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "coveralls/gcov"
|
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
|
data/bin/setup
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'coveralls/gcov/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "coveralls-gcov"
|
8
|
+
spec.version = Coveralls::Gcov::VERSION
|
9
|
+
spec.authors = ["kishikawa katsumi"]
|
10
|
+
spec.email = ["kishikawakatsumi@mac.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Upload coverage information generated by Gcov to coveralls.io.}
|
13
|
+
spec.description = %q{Upload coverage information generated by Gcov to coveralls.io.}
|
14
|
+
spec.homepage = "https://github.com/kishikawakatsumi/coveralls-gcov"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "commander"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
end
|
data/exe/coveralls-gcov
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'commander/import'
|
4
|
+
|
5
|
+
require 'coveralls/gcov'
|
6
|
+
|
7
|
+
HighLine.track_eof = false # Fix for built-in Ruby
|
8
|
+
Signal.trap("INT") {} # Suppress backtrace when exiting command
|
9
|
+
|
10
|
+
program :version, Coveralls::Gcov::VERSION
|
11
|
+
program :description, 'Upload coverage information generated by Gcov to coveralls.io.'
|
12
|
+
|
13
|
+
program :help, 'Author', 'kishikawa Katsumi <kishikawakatsumi@mac.com>'
|
14
|
+
program :help, 'Website', 'http://kishikawakatsumi.com'
|
15
|
+
program :help_formatter, :compact
|
16
|
+
|
17
|
+
default_command :send
|
18
|
+
|
19
|
+
command :send do |c|
|
20
|
+
c.syntax = 'coveralls-gcov [send] [--repo-token TOKEN] [--root DIR] [--exclude DIR|FILE] [--exclude-pattern REGEXP] [--extension EXT] [--no-gcov]'
|
21
|
+
c.summary = 'Sends coverage information generated by Gcov to coveralls.io.'
|
22
|
+
c.description = ''
|
23
|
+
|
24
|
+
c.option '-r DIR', '--root DIR', 'set the root directory'
|
25
|
+
c.option '-e DIR|FILE', '--exclude DIR|FILE', Array, 'set exclude file or directory'
|
26
|
+
c.option '-E REGEXP', '--exclude-pattern REGEXP', 'set exclude file/directory pattern'
|
27
|
+
c.option '-x EXT', '--extension EXT', Array, 'set extension of files to process'
|
28
|
+
c.option '-n', '--no-gcov', 'do not run gcov'
|
29
|
+
c.option '-t TOKEN', '--repo-token TOKEN', 'set the repo_token of this project'
|
30
|
+
|
31
|
+
c.action do |args, options|
|
32
|
+
runner = Coveralls::Gcov::Runner.new
|
33
|
+
runner.root_dir = options.root if options.root
|
34
|
+
runner.excludes = options.exclude if options.exclude
|
35
|
+
runner.exclude_pattern = options.exclude_pattern if options.exclude_pattern
|
36
|
+
runner.extensions = options.extension if options.extension
|
37
|
+
runner.no_gcov = !!options.no_gcov
|
38
|
+
runner.repo_token = options.repo_token if options.repo_token
|
39
|
+
|
40
|
+
begin
|
41
|
+
runner.run
|
42
|
+
|
43
|
+
rescue => message
|
44
|
+
say_error "#{message}" and abort
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'pathname'
|
3
|
+
require 'tempfile'
|
4
|
+
require 'open3'
|
5
|
+
require 'digest/md5'
|
6
|
+
|
7
|
+
module Coveralls
|
8
|
+
module Gcov
|
9
|
+
class Runner
|
10
|
+
attr_accessor :repo_token
|
11
|
+
attr_accessor :service_name
|
12
|
+
attr_accessor :service_job_id
|
13
|
+
attr_accessor :service_number
|
14
|
+
attr_accessor :service_pull_request
|
15
|
+
attr_accessor :parallel
|
16
|
+
attr_accessor :service_job_number
|
17
|
+
attr_accessor :service_event_type
|
18
|
+
|
19
|
+
attr_accessor :no_gcov
|
20
|
+
attr_accessor :root_dir
|
21
|
+
attr_accessor :extensions
|
22
|
+
attr_accessor :excludes
|
23
|
+
attr_accessor :exclude_pattern
|
24
|
+
|
25
|
+
def initialize()
|
26
|
+
if ENV['TRAVIS']
|
27
|
+
@service_name = 'travis-ci'
|
28
|
+
@service_job_id = ENV['TRAVIS_JOB_ID']
|
29
|
+
elsif ENV['CIRCLECI']
|
30
|
+
@service_name = 'circleci'
|
31
|
+
@service_number = ENV['CIRCLE_BUILD_NUM']
|
32
|
+
@service_pull_request = (ENV['CI_PULL_REQUEST'] || "")[/(\d+)$/, 1]
|
33
|
+
@parallel = ENV['CIRCLE_NODE_TOTAL'].to_i > 1
|
34
|
+
@service_job_number = ENV['CIRCLE_NODE_INDEX']
|
35
|
+
end
|
36
|
+
|
37
|
+
@extensions = []
|
38
|
+
@excludes = []
|
39
|
+
end
|
40
|
+
|
41
|
+
def exclude_pattern=(exclude_pattern)
|
42
|
+
if !exclude_pattern.kind_of?(Regexp)
|
43
|
+
exclude_pattern = Regexp.new(exclude_pattern)
|
44
|
+
end
|
45
|
+
@exclude_pattern = exclude_pattern
|
46
|
+
end
|
47
|
+
|
48
|
+
def run()
|
49
|
+
root_dir = @root_dir || Dir.pwd
|
50
|
+
report = parse(root_dir)
|
51
|
+
file = write_report(report)
|
52
|
+
upload(file)
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def parse(base_dir)
|
58
|
+
report = {}
|
59
|
+
report['repo_token'] = repo_token if repo_token
|
60
|
+
report['service_name'] = service_name if service_name
|
61
|
+
report['service_job_id'] = service_job_id if service_job_id
|
62
|
+
report['service_number'] = service_number if service_number
|
63
|
+
report['service_pull_request'] = service_pull_request if service_pull_request
|
64
|
+
report['parallel'] = parallel if parallel
|
65
|
+
report['service_job_number'] = service_job_number if service_job_number
|
66
|
+
report['service_event_type'] = service_event_type if service_event_type
|
67
|
+
report['source_files'] = []
|
68
|
+
|
69
|
+
Dir.glob("#{base_dir}/**/*.gcov").each do |file|
|
70
|
+
File.open(file, "r") do |handle|
|
71
|
+
source_file = {}
|
72
|
+
name = ''
|
73
|
+
source_digest = nil
|
74
|
+
coverage = []
|
75
|
+
|
76
|
+
handle.each_line do |line|
|
77
|
+
match = /^[ ]*([0-9]+|-|#####):[ ]*([0-9]+):(.*)/.match(line)
|
78
|
+
next unless match.to_a.count == 4
|
79
|
+
count, number, text = match.to_a[1..3]
|
80
|
+
|
81
|
+
if number.to_i == 0
|
82
|
+
key, val = /([^:]+):(.*)$/.match(text).to_a[1..2]
|
83
|
+
if key == 'Source'
|
84
|
+
name = Pathname(val).relative_path_from(Pathname(base_dir)).to_s
|
85
|
+
if File.exist?(val)
|
86
|
+
source_digest = Digest::MD5.file(val).to_s
|
87
|
+
end
|
88
|
+
end
|
89
|
+
else
|
90
|
+
coverage[number.to_i - 1] = case count.strip
|
91
|
+
when "-"
|
92
|
+
nil
|
93
|
+
when "#####"
|
94
|
+
if text.strip == '}'
|
95
|
+
nil
|
96
|
+
else
|
97
|
+
0
|
98
|
+
end
|
99
|
+
else count.to_i
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
if !is_excluded_path(name) && !source_digest.nil?
|
105
|
+
source_file['name'] = name
|
106
|
+
source_file['source_digest'] = source_digest
|
107
|
+
source_file['coverage'] = coverage
|
108
|
+
|
109
|
+
report['source_files'] << source_file
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
report
|
115
|
+
end
|
116
|
+
|
117
|
+
def is_excluded_path(filepath)
|
118
|
+
if filepath.start_with?('..')
|
119
|
+
return true
|
120
|
+
end
|
121
|
+
@excludes.each do |exclude|
|
122
|
+
if filepath.start_with?(exclude)
|
123
|
+
return true
|
124
|
+
end
|
125
|
+
end
|
126
|
+
if !@exclude_pattern.nil? && filepath.match(@exclude_pattern)
|
127
|
+
return true
|
128
|
+
end
|
129
|
+
if !@extensions.empty?
|
130
|
+
@extensions.each do |extension|
|
131
|
+
if File.extname(filepath) == extension
|
132
|
+
return false
|
133
|
+
end
|
134
|
+
end
|
135
|
+
return true
|
136
|
+
else
|
137
|
+
return false
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def write_report(report)
|
142
|
+
tempdir = Pathname.new(Dir.tmpdir).join(SecureRandom.hex)
|
143
|
+
FileUtils.mkdir_p(tempdir)
|
144
|
+
tempfile = File::open(tempdir.join('coveralls.json'), "w")
|
145
|
+
tempfile.puts(report.to_json)
|
146
|
+
tempfile.flush
|
147
|
+
tempfile.path
|
148
|
+
end
|
149
|
+
|
150
|
+
def upload(json_file)
|
151
|
+
curl_options = ['curl', '-sSf', '-F', "json_file=@#{json_file}", 'https://coveralls.io/api/v1/jobs']
|
152
|
+
puts curl_options.join(' ')
|
153
|
+
Open3.popen2e(*curl_options) do |stdin, stdout_err, wait_thr|
|
154
|
+
output = ''
|
155
|
+
while line = stdout_err.gets
|
156
|
+
puts line
|
157
|
+
output << line
|
158
|
+
end
|
159
|
+
|
160
|
+
status = wait_thr.value
|
161
|
+
if !status.success?
|
162
|
+
raise "Upload failed (exited with status: #{status.exitstatus})"
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coveralls-gcov
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kishikawa katsumi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: commander
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.9'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Upload coverage information generated by Gcov to coveralls.io.
|
70
|
+
email:
|
71
|
+
- kishikawakatsumi@mac.com
|
72
|
+
executables:
|
73
|
+
- coveralls-gcov
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- coveralls-gcov.gemspec
|
87
|
+
- exe/coveralls-gcov
|
88
|
+
- lib/coveralls/gcov.rb
|
89
|
+
- lib/coveralls/gcov/runner.rb
|
90
|
+
- lib/coveralls/gcov/version.rb
|
91
|
+
homepage: https://github.com/kishikawakatsumi/coveralls-gcov
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.4.5
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Upload coverage information generated by Gcov to coveralls.io.
|
115
|
+
test_files: []
|