Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 2e2fe25

Browse files
committed
Fix our simplecov setup.
Simplecov was only reporting coverage for a handful of rspec's files, and I realized why: simplecov can only track coverage of files that are loaded _after_ it has been loaded. So, to get this to work properly, we have to load simplecov before rspec-core. This commit adds a wrapper script that does that.
1 parent ef00f05 commit 2e2fe25

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

script/rspec_with_simplecov

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env ruby
2+
3+
# This is necessary for when `--standalone` is being used.
4+
$:.unshift File.expand_path '../../bundle', __FILE__
5+
require 'bundler/setup'
6+
7+
# To use simplecov while running rspec-core's test suite, we must
8+
# load simplecov _before_ loading any of rspec-core's files.
9+
# So, this executable exists purely as a wrapper script that
10+
# first loads simplecov, and then loads rspec.
11+
begin
12+
# Simplecov emits some ruby warnings when loaded, so silence them.
13+
old_verbose, $VERBOSE = $VERBOSE, false
14+
15+
unless ENV['NO_COVERAGE'] || RUBY_VERSION < '1.9.3'
16+
require 'simplecov'
17+
18+
SimpleCov.start do
19+
add_filter "./bundle/"
20+
add_filter "./tmp/"
21+
add_filter "./spec/"
22+
minimum_coverage 97
23+
end
24+
end
25+
rescue LoadError
26+
ensure
27+
$VERBOSE = old_verbose
28+
end
29+
30+
load File.expand_path("../../exe/rspec", __FILE__)

script/test_all

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export JRUBY_OPTS='-X-C' # disable JIT since these processes are so short lived
1818
export JAVA_OPTS='-client -XX:+TieredCompilation -XX:TieredStopAtLevel=1'
1919

2020
echo "Running all..."
21-
bin/rspec spec -b --format progress --profile
21+
script/rspec_with_simplecov spec -b --format progress --profile
2222

2323
echo
2424
echo "--------------------------------------------------------------------"
@@ -28,7 +28,7 @@ if is_jruby; then
2828
echo "Skipping one-by-one spec runs due to expensive JVM load time"
2929
else
3030
for file in `find spec -iname '*_spec.rb'`; do
31-
NO_COVERALLS=1 bin/rspec $file -b --format progress
31+
bin/rspec $file -b --format progress
3232
done
3333
fi
3434

spec/spec_helper.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ module ArubaLoader
2424
end
2525
end
2626

27-
RSpec::Support::Spec.setup_simplecov do
28-
minimum_coverage 96
29-
end
30-
3127
if RUBY_PLATFORM == 'java'
3228
# Works around https://jira.codehaus.org/browse/JRUBY-5678
3329
require 'fileutils'

0 commit comments

Comments
 (0)