Do not run simplecov on dspec specs

This commit is contained in:
Josh Holtrop 2021-10-22 13:55:51 -04:00
parent 556c821cc6
commit 87a6d9f04f
3 changed files with 41 additions and 34 deletions

View File

@ -17,12 +17,16 @@ task :build_dist do
end end
RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args| RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args|
ENV["specs"] = "1"
if args.example_string if args.example_string
ENV["partial_specs"] = "1" ENV["partial_specs"] = "1"
task.rspec_opts = %W[-e "#{args.example_string}" -f documentation] task.rspec_opts = %W[-e "#{args.example_string}" -f documentation]
end end
end end
task :spec => :build_dist task :spec => :build_dist
task :spec do
ENV.delete("specs")
end
# dspec task is useful to test the distributable release script, but is not # dspec task is useful to test the distributable release script, but is not
# useful for coverage information. # useful for coverage information.
@ -31,7 +35,7 @@ task :dspec, [:example_string] => :build_dist do |task, args|
FileUtils.mkdir_p("test") FileUtils.mkdir_p("test")
FileUtils.cp("dist/rscons", "test/rscons.rb") FileUtils.cp("dist/rscons", "test/rscons.rb")
ENV["dist_specs"] = "1" ENV["dist_specs"] = "1"
Rake::Task["spec"].invoke(args.example_string) Rake::Task["spec"].execute(args.example_string)
ENV.delete("dist_specs") ENV.delete("dist_specs")
FileUtils.rm_f(Dir.glob(".rscons-*")) FileUtils.rm_f(Dir.glob(".rscons-*"))
end end
@ -99,6 +103,7 @@ task :default => :spec
task :all => [ task :all => [
:build_dist, :build_dist,
:spec, :spec,
:dspec,
:yard, :yard,
:user_guide, :user_guide,
] ]

View File

@ -118,21 +118,23 @@ describe Rscons do
command_name = "#{command_prefix}#{@statics[:build_test_id]}" command_name = "#{command_prefix}#{@statics[:build_test_id]}"
File.open("_simplecov_setup.rb", "w") do |fh| File.open("_simplecov_setup.rb", "w") do |fh|
fh.puts <<EOF fh.puts <<EOF
require "bundler" unless ENV["dist_specs"]
Bundler.setup require "bundler"
require "simplecov" Bundler.setup
class MyFormatter require "simplecov"
def format(*args) class MyFormatter
def format(*args)
end
end end
end SimpleCov.start do
SimpleCov.start do root(#{@owd.inspect})
root(#{@owd.inspect}) command_name(#{command_name.inspect})
command_name(#{command_name.inspect}) filters.clear
filters.clear add_filter do |src|
add_filter do |src| !(src.filename[SimpleCov.root])
!(src.filename[SimpleCov.root]) end
formatter(MyFormatter)
end end
formatter(MyFormatter)
end end
# force color off # force color off
ENV["TERM"] = nil ENV["TERM"] = nil

View File

@ -1,25 +1,25 @@
require "simplecov"
SimpleCov.start do
add_filter "/spec/"
add_filter "/.bundle/"
if ENV["partial_specs"]
command_name "RSpec-partial"
else
command_name "RSpec"
end
if ENV["dist_specs"]
add_filter "/bin/"
add_filter "/lib/"
else
add_filter "test/rscons.rb"
end
project_name "Rscons"
merge_timeout 3600
end
if ENV["dist_specs"] if ENV["dist_specs"]
require_relative "../test/rscons" require_relative "../test/rscons"
else else
require "simplecov"
SimpleCov.start do
add_filter "/spec/"
add_filter "/.bundle/"
if ENV["partial_specs"]
command_name "RSpec-partial"
else
command_name "RSpec"
end
if ENV["dist_specs"]
add_filter "/bin/"
add_filter "/lib/"
else
add_filter "test/rscons.rb"
end
project_name "Rscons"
merge_timeout 3600
end
require "rscons" require "rscons"
end end