Turn on simplecov to measure code coverage
This commit is contained in:
parent
9a9315f7f9
commit
f152cd9da1
1
Gemfile
1
Gemfile
@ -5,3 +5,4 @@ gem "rspec"
|
||||
gem "rdoc"
|
||||
gem "redcarpet"
|
||||
gem "syntax"
|
||||
gem "simplecov"
|
||||
|
@ -2,6 +2,7 @@ GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
diff-lcs (1.5.0)
|
||||
docile (1.4.0)
|
||||
psych (5.1.0)
|
||||
stringio
|
||||
rake (13.0.6)
|
||||
@ -21,6 +22,12 @@ GEM
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.12.0)
|
||||
rspec-support (3.12.1)
|
||||
simplecov (0.22.0)
|
||||
docile (~> 1.1)
|
||||
simplecov-html (~> 0.11)
|
||||
simplecov_json_formatter (~> 0.1)
|
||||
simplecov-html (0.12.3)
|
||||
simplecov_json_formatter (0.1.4)
|
||||
stringio (3.0.7)
|
||||
syntax (1.2.2)
|
||||
|
||||
@ -32,6 +39,7 @@ DEPENDENCIES
|
||||
rdoc
|
||||
redcarpet
|
||||
rspec
|
||||
simplecov
|
||||
syntax
|
||||
|
||||
BUNDLED WITH
|
||||
|
3
Rakefile
3
Rakefile
@ -1,5 +1,8 @@
|
||||
require "rake/clean"
|
||||
require "rspec/core/rake_task"
|
||||
|
||||
CLEAN.include %w[spec/run gen .yardoc yard coverage dist]
|
||||
|
||||
task :build_dist do
|
||||
sh "ruby rb/build_dist.rb"
|
||||
end
|
||||
|
@ -4,19 +4,52 @@ require "open3"
|
||||
Results = Struct.new(:stdout, :stderr, :status)
|
||||
|
||||
describe Propane do
|
||||
before(:all) do
|
||||
@statics = {}
|
||||
end
|
||||
|
||||
def write_grammar(grammar, options = {})
|
||||
options[:name] ||= ""
|
||||
File.write("spec/run/testparser#{options[:name]}.propane", grammar)
|
||||
end
|
||||
|
||||
def build_parser(options = {})
|
||||
options[:name] ||= ""
|
||||
@statics[:build_test_id] ||= 0
|
||||
@statics[:build_test_id] += 1
|
||||
if ENV["dist_specs"]
|
||||
propane = "dspec/propane"
|
||||
command = %W[dist/propane]
|
||||
else
|
||||
propane = "./propane.sh"
|
||||
command = %W[ruby -I spec/run -r _simplecov_setup -I lib bin/propane]
|
||||
command_prefix =
|
||||
if ENV["partial_specs"]
|
||||
"p"
|
||||
else
|
||||
"b"
|
||||
end
|
||||
command = %W[#{propane} spec/run/testparser#{options[:name]}.propane spec/run/testparser#{options[:name]}.#{options[:language]} --log spec/run/testparser#{options[:name]}.log]
|
||||
command_name = "#{command_prefix}#{@statics[:build_test_id]}"
|
||||
File.open("spec/run/_simplecov_setup.rb", "w") do |fh|
|
||||
fh.puts <<EOF
|
||||
require "bundler"
|
||||
Bundler.setup
|
||||
require "simplecov"
|
||||
class MyFormatter
|
||||
def format(*args)
|
||||
end
|
||||
end
|
||||
SimpleCov.start do
|
||||
command_name(#{command_name.inspect})
|
||||
filters.clear
|
||||
add_filter do |src|
|
||||
!(src.filename[SimpleCov.root])
|
||||
end
|
||||
formatter(MyFormatter)
|
||||
end
|
||||
# force color off
|
||||
ENV["TERM"] = nil
|
||||
EOF
|
||||
end
|
||||
end
|
||||
command += %W[spec/run/testparser#{options[:name]}.propane spec/run/testparser#{options[:name]}.#{options[:language]} --log spec/run/testparser#{options[:name]}.log]
|
||||
if (options[:capture])
|
||||
stdout, stderr, status = Open3.capture3(*command)
|
||||
Results.new(stdout, stderr, status)
|
||||
|
@ -1,11 +1,27 @@
|
||||
require "bundler/setup"
|
||||
require "propane"
|
||||
unless ENV["dist_specs"]
|
||||
require "bundler/setup"
|
||||
require "simplecov"
|
||||
|
||||
RSpec.configure do |config|
|
||||
SimpleCov.start do
|
||||
add_filter "/spec/"
|
||||
add_filter "/.bundle/"
|
||||
if ENV["partial_specs"]
|
||||
command_name "RSpec-partial"
|
||||
else
|
||||
command_name "RSpec"
|
||||
end
|
||||
project_name "Propane"
|
||||
merge_timeout 3600
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
# Enable flags like --only-failures and --next-failure
|
||||
config.example_status_persistence_file_path = ".rspec_status"
|
||||
|
||||
config.expect_with :rspec do |c|
|
||||
c.syntax = :expect
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
require "propane"
|
||||
|
Loading…
x
Reference in New Issue
Block a user