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 "rdoc"
|
||||||
gem "redcarpet"
|
gem "redcarpet"
|
||||||
gem "syntax"
|
gem "syntax"
|
||||||
|
gem "simplecov"
|
||||||
|
@ -2,6 +2,7 @@ GEM
|
|||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
diff-lcs (1.5.0)
|
diff-lcs (1.5.0)
|
||||||
|
docile (1.4.0)
|
||||||
psych (5.1.0)
|
psych (5.1.0)
|
||||||
stringio
|
stringio
|
||||||
rake (13.0.6)
|
rake (13.0.6)
|
||||||
@ -21,6 +22,12 @@ GEM
|
|||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.12.0)
|
rspec-support (~> 3.12.0)
|
||||||
rspec-support (3.12.1)
|
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)
|
stringio (3.0.7)
|
||||||
syntax (1.2.2)
|
syntax (1.2.2)
|
||||||
|
|
||||||
@ -32,6 +39,7 @@ DEPENDENCIES
|
|||||||
rdoc
|
rdoc
|
||||||
redcarpet
|
redcarpet
|
||||||
rspec
|
rspec
|
||||||
|
simplecov
|
||||||
syntax
|
syntax
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
|
3
Rakefile
3
Rakefile
@ -1,5 +1,8 @@
|
|||||||
|
require "rake/clean"
|
||||||
require "rspec/core/rake_task"
|
require "rspec/core/rake_task"
|
||||||
|
|
||||||
|
CLEAN.include %w[spec/run gen .yardoc yard coverage dist]
|
||||||
|
|
||||||
task :build_dist do
|
task :build_dist do
|
||||||
sh "ruby rb/build_dist.rb"
|
sh "ruby rb/build_dist.rb"
|
||||||
end
|
end
|
||||||
|
@ -4,19 +4,52 @@ require "open3"
|
|||||||
Results = Struct.new(:stdout, :stderr, :status)
|
Results = Struct.new(:stdout, :stderr, :status)
|
||||||
|
|
||||||
describe Propane do
|
describe Propane do
|
||||||
|
before(:all) do
|
||||||
|
@statics = {}
|
||||||
|
end
|
||||||
|
|
||||||
def write_grammar(grammar, options = {})
|
def write_grammar(grammar, options = {})
|
||||||
options[:name] ||= ""
|
options[:name] ||= ""
|
||||||
File.write("spec/run/testparser#{options[:name]}.propane", grammar)
|
File.write("spec/run/testparser#{options[:name]}.propane", grammar)
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_parser(options = {})
|
def build_parser(options = {})
|
||||||
options[:name] ||= ""
|
@statics[:build_test_id] ||= 0
|
||||||
|
@statics[:build_test_id] += 1
|
||||||
if ENV["dist_specs"]
|
if ENV["dist_specs"]
|
||||||
propane = "dspec/propane"
|
command = %W[dist/propane]
|
||||||
else
|
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_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
|
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 += %W[spec/run/testparser#{options[:name]}.propane spec/run/testparser#{options[:name]}.#{options[:language]} --log spec/run/testparser#{options[:name]}.log]
|
||||||
if (options[:capture])
|
if (options[:capture])
|
||||||
stdout, stderr, status = Open3.capture3(*command)
|
stdout, stderr, status = Open3.capture3(*command)
|
||||||
Results.new(stdout, stderr, status)
|
Results.new(stdout, stderr, status)
|
||||||
|
@ -1,11 +1,27 @@
|
|||||||
require "bundler/setup"
|
unless ENV["dist_specs"]
|
||||||
require "propane"
|
require "bundler/setup"
|
||||||
|
require "simplecov"
|
||||||
|
|
||||||
RSpec.configure do |config|
|
SimpleCov.start do
|
||||||
# Enable flags like --only-failures and --next-failure
|
add_filter "/spec/"
|
||||||
config.example_status_persistence_file_path = ".rspec_status"
|
add_filter "/.bundle/"
|
||||||
|
if ENV["partial_specs"]
|
||||||
|
command_name "RSpec-partial"
|
||||||
|
else
|
||||||
|
command_name "RSpec"
|
||||||
|
end
|
||||||
|
project_name "Propane"
|
||||||
|
merge_timeout 3600
|
||||||
|
end
|
||||||
|
|
||||||
config.expect_with :rspec do |c|
|
RSpec.configure do |config|
|
||||||
c.syntax = :expect
|
# 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require "propane"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user