Skip to content

Commit 25140f0

Browse files
committed
Merge branch 'develop'
* develop: Update README Fixed gem case in travis file Enabled gem publish from travis Added option to generate a plaintext percent file Ensure that XCS_SOURCE_DIR var is nil for dev test Removed bundler/setup (It was causing alcove/version to not be found.) Specify minitest version in gemspec. Travis build now runs tests Added rake ci to build and test Added a few tests. Update README.md Moved the scripty stuff into bin/alcove Minor style changes. ' replaced with " Removed explicit returns in most places. String#+ replaced with String#<< Fixed rename. Added TomDoc comments. Changed indentation to 2 spaces Cleanup and minor refactoring Conflicts: README.md
2 parents 88df96e + 5521a13 commit 25140f0

File tree

9 files changed

+296
-175
lines changed

9 files changed

+296
-175
lines changed

.travis.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
language: ruby
22
cache: bundler
33
rvm:
4-
- 2.0.0
5-
script: rake build
4+
- 2.0.0
5+
script: bundle exec rake ci
6+
deploy:
7+
provider: rubygems
8+
api_key:
9+
secure: QQevlWTpIwUsCHZf2kAbBc6YjedIV+T5IBvvNRnU5Uj/u+gbmpwtYqHuS0SYPGlAiCQFld7FpJ1K20FAsygUZqQaQqr8L85d++0qvaDqTmXm7OgLX4Q1ZxVYgCDA3MnDUY/oLnWmcQ7FwcvQH4yceuNXkBKLRm+OW4c2USvGNDk=
10+
gem: alcove
11+
on:
12+
repo: ioveracker/Alcove
13+
all_branches: true

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
source 'https://rubygems.org'
2+
gem 'rake', '~> 10.4'
3+
gem 'colored', '~> 1.2'
4+
5+
group :test do
6+
gem 'minitest', '~> 5.5'
7+
end

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,37 @@
1-
# Alcove [![Gem Version](https://badge.fury.io/rb/alcove.svg)](http://badge.fury.io/rb/alcove) [![Build Status](https://travis-ci.org/ioveracker/Alcove.svg?branch=master)](https://travis-ci.org/ioveracker/Alcove)
1+
# Alcove [![Gem Version](https://badge.fury.io/rb/alcove.svg)](http://badge.fury.io/rb/alcove) [![Build Status](https://travis-ci.org/ioveracker/Alcove.svg?branch=master)](https://travis-ci.org/ioveracker/Alcove) [![Code Climate](https://codeclimate.com/github/ioveracker/Alcove/badges/gpa.svg)](https://codeclimate.com/github/ioveracker/Alcove)
22
Painless code coverage reporting for Objective-C projects. Most of the heavy lifting is done by the venerable lcov. Alcove simply searches the nooks and crannies to collect the data needed to generate the report and ties everything together for you. Best of all, it's a gem with minimal depedencies, so installation is quick and painless.
33

44
## Installation
55

66
$ gem install alcove
7-
8-
If you don't have it already, you'll also need to install lcov.
97

10-
*Homebrew*
8+
You'll also need to install lcov.
9+
10+
With *Homebrew*:
1111

1212
$ brew install lcov
1313

14-
*MacPorts*
14+
Or with *MacPorts*:
1515

1616
$ sudo port install lcov
1717

1818
## Xcode Project Configuration
19-
If you haven't already, open your project in Xcode and update your non-test targets to Generate Test Coverage Files and Instrument Program Flow *for Debug configuration only*).
19+
Open your project in Xcode and update your non-test targets to Generate Test Coverage Files and Instrument Program Flow (*for Debug configuration only*).
2020
![Xcode](http://i.imgur.com/xdcg4er.png?1)
2121

2222
## Generating Reports
2323
Now that you have the prerequisites out of the way, you can generate a report. Make sure you've recently executed your tests, then:
2424

2525
alcove --product-name <your-product-name>
2626

27-
Be sure to check out the --help for additional options for fine-tuning your report.
28-
2927
## Options
3028

3129
### --output-directory
3230
Specify this option to change the output directory for the report. Any intermediate paths will be created.
3331

32+
### --percent-file
33+
Generates a plaintext file `alcove-percent.txt` in the output directory, containing only the line coverage percentage.
34+
3435
### --product-name
3536
The product name specified in your Xcode project.
3637

@@ -40,8 +41,8 @@ A list of filters to use when gathering files for the report. Use this if you w
4041
### --search-directory
4142
Use this option to specify the directory to be searched for your product. Alcove plays nicely with the the structure on your development machine, as well as on an Xcode Server, but if you have some funky output directory for your build, you can specify its parent here.
4243

43-
## Demo
44-
See [AlcoveDemo](https://github.com/ioveracker/AlcoveDemo) for a demo project.
44+
## Troubleshooting
45+
If something doesn't seem quite right, try cleaning the build folder and then run the tests again. Make sure you can generate a report for the [demo project](https://github.com/ioveracker/AlcoveDemo), too.
4546

46-
## Attribution
47-
Shoutout to [@NateBank](https://github.com/NateBank) for the [name suggestion](https://www.youtube.com/watch?v=j1Q-a5zCmhc).
47+
## Thanks
48+
Shoutout to [@NateBank](https://github.com/NateBank) for the [name suggestion](https://www.youtube.com/watch?v=j1Q-a5zCmhc) and inspiration.

Rakefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
require 'bundler/gem_tasks'
2+
require 'rake/testtask'
3+
4+
task :ci => [:test, :build]
5+
6+
Rake::TestTask.new do |test|
7+
test.pattern = "test/test_*.rb"
8+
end

alcove.gemspec

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
require './lib/alcove/version'
22
Gem::Specification.new do |s|
3-
s.name = 'alcove'
4-
s.version = Alcove::VERSION
5-
s.date = '2015-02-10'
6-
s.summary = "Painless code coverage reporting for Objective-C."
7-
s.description = "Painless code coverage reporting for Xcode projects written in Objective-C."
8-
s.authors = ['Isaac Overacker']
9-
s.email = '[email protected]'
10-
s.files = Dir["lib/**/*.rb"] + %w{ bin/alcove README.md LICENSE }
11-
s.executables = 'alcove'
12-
s.homepage = 'https://github.com/ioveracker/alcove'
13-
s.license = 'MIT'
3+
s.name = 'alcove'
4+
s.version = Alcove::VERSION
5+
s.version = "#{s.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
6+
s.date = Date.today.to_s
7+
s.summary = "Painless code coverage reporting for Objective-C."
8+
s.description = "Painless code coverage reporting for Xcode projects written in Objective-C."
9+
s.authors = ['Isaac Overacker']
10+
s.email = '[email protected]'
11+
s.files = Dir["lib/**/*.rb"] + %w{ bin/alcove README.md LICENSE }
12+
s.executables = 'alcove'
13+
s.homepage = 'https://github.com/ioveracker/alcove'
14+
s.license = 'MIT'
1415

15-
s.add_runtime_dependency 'colored', '~> 1.2'
16+
s.add_runtime_dependency 'colored', '~> 1.2'
1617

17-
s.add_development_dependency 'rake'
18-
s.add_development_dependency 'rspec'
18+
s.add_development_dependency 'rake'
19+
s.add_development_dependency 'rspec'
20+
s.add_development_dependency 'minitest', '~> 5.5'
1921
end

bin/alcove

Lines changed: 107 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,62 +7,125 @@ require 'optparse'
77

88
options = OpenStruct.new
99
OptionParser.new do |opts|
10-
opts.banner = "Usage: alcove --product-name <product-name> [options]"
10+
opts.banner = "Usage: alcove --product-name <product-name> [options]"
1111

12-
opts.on('-h', '--help', 'Displays the help screen') do
13-
puts opts
14-
exit
15-
end
12+
opts.on("-h", "--help", "Displays the help screen") do
13+
puts opts
14+
exit
15+
end
1616

17-
options.output_directory = 'alcove-report'
18-
opts.on('-o', '--output-directory DIR', 'Place report in DIR instead of default') do |o|
19-
options.output_directory = o
20-
end
17+
options.output_directory = "alcove-report"
18+
opts.on("-o", "--output-directory DIR", "Place report in DIR instead of default") do |o|
19+
options.output_directory = o
20+
end
2121

22-
options.product_name = ''
23-
opts.on('-p', '--product-name NAME', 'The name of your product') do |p|
24-
options.product_name = p
25-
end
22+
opts.on("--percent-file", "Generate a file containing coverage percent") do |p|
23+
options.generate_percent_file = true
24+
end
2625

27-
options.remove_filter = []
28-
opts.on('-r', '--remove-filter X,Y,Z...', ::Array, 'A list of filters (e.g. *.h,main.m)') do |r|
29-
options.remove_filter = r
30-
end
26+
options.product_name = ""
27+
opts.on("-p", "--product-name NAME", "The name of your product") do |p|
28+
options.product_name = p
29+
end
3130

32-
opts.on('-s', '--search-directory DIR', 'Search in DIR for coverage files') do |s|
33-
options.search_directory = s
34-
end
31+
options.remove_filter = []
32+
opts.on("-r", "--remove-filter X,Y,Z...", ::Array, "A list of filters (e.g. *.h,main.m)") do |r|
33+
options.remove_filter = r
34+
end
3535

36-
options.verbose = false
37-
opts.on('-v', '--verbose', 'Output additional information') do
38-
options.verbose = true
39-
end
36+
opts.on("-s", "--search-directory DIR", "Search in DIR for coverage files") do |s|
37+
options.search_directory = s
38+
end
4039

41-
opts.on_tail('--version', 'Show version') do
42-
puts Alcove::VERSION
43-
exit
44-
end
40+
options.verbose = false
41+
opts.on("-v", "--verbose", "Output additional information") do
42+
options.verbose = true
43+
end
4544

46-
begin
47-
opts.parse!(ARGV)
48-
if options.product_name.length == 0
49-
puts '--product-name is required'.yellow
50-
puts opts
51-
exit(1)
52-
end
53-
rescue OptionParser::InvalidOption => e
54-
puts e
55-
puts opts
56-
exit(1)
45+
opts.on_tail("--version", "Show version") do
46+
puts Alcove::VERSION
47+
exit
48+
end
49+
50+
begin
51+
opts.parse!(ARGV)
52+
if options.product_name.length == 0
53+
STDERR.puts "--product-name is required".yellow
54+
puts opts
55+
exit(1)
5756
end
57+
rescue OptionParser::InvalidOption => e
58+
puts e
59+
puts opts
60+
exit(1)
61+
end
62+
end
63+
64+
def exit_with_code(code)
65+
FileUtils.rm_rf(Alcove::TEMP_DIR)
66+
exit(code)
5867
end
5968

6069
alcoveOptions = OpenStruct.new
61-
alcoveOptions.output_directory = options.output_directory
62-
alcoveOptions.product_name = options.product_name
63-
alcoveOptions.remove_filter = options.remove_filter
64-
alcoveOptions.search_directory = options.search_directory
6570
alcoveOptions.verbose = options.verbose
6671

6772
alcove = Alcove.new(alcoveOptions)
68-
alcove.generate_report
73+
puts " 🔍 Generating report..."
74+
75+
FileUtils.rm_rf(Alcove::TEMP_DIR)
76+
FileUtils.mkdir(Alcove::TEMP_DIR)
77+
78+
if options.search_directory
79+
search_directory = options.search_directory
80+
else
81+
search_directory = alcove.get_search_directory
82+
end
83+
alcove.copy_input_files_to_temp(search_directory, options.product_name)
84+
85+
gi_filename_absolute = File.join(Alcove::TEMP_DIR, "alcove-info.temp")
86+
gen_success = alcove.gen_info_files(gi_filename_absolute)
87+
if gen_success
88+
puts " ✅ geninfo successful".green if options.verbose
89+
else
90+
STDERR.puts " 🚫 geninfo failed!".red
91+
exit_with_code(1)
92+
end
93+
94+
lcov_filename_absolute = File.join(Alcove::TEMP_DIR, "alcove-lcov.info")
95+
lcov_success = alcove.lcov(gi_filename_absolute, options.remove_filter, lcov_filename_absolute)
96+
if lcov_success
97+
puts " ✅ lcov successful".green if options.verbose
98+
else
99+
STDERR.puts " 🚫 lcov failed!".red
100+
exit_with_code(1)
101+
end
102+
103+
genhtml_success, coverage_percent = alcove.genhtml(lcov_filename_absolute, options.output_directory)
104+
if genhtml_success
105+
puts "" if options.verbose
106+
puts " ✅ Successfully generated report".green
107+
108+
coverage_string = " 📊 Line coverage: #{coverage_percent}%"
109+
if coverage_percent < 50
110+
puts coverage_string.red
111+
elsif coverage_percent < 85
112+
puts coverage_string.yellow
113+
else
114+
puts coverage_string.green
115+
end
116+
117+
puts " 🍻 Open #{options.output_directory}/index.html to view the report"
118+
119+
else
120+
STDERR.puts " 🚫 genhtml failed!".red
121+
exit_with_code(1)
122+
end
123+
124+
if options.generate_percent_file
125+
File.open("#{options.output_directory}/alcove-percent.txt", 'w') {|f|
126+
f.write(coverage_percent)
127+
}
128+
129+
end
130+
131+
exit_with_code(0)

0 commit comments

Comments
 (0)