Improve rake tasks for specs

- clean coverage directory before running specs to avoid simplecov
  slowdowns
- add valgrind task to run valgrind; normal spec does not run it
- delay combining and reporting simplecov results until end of task to
  speed up task execution
This commit is contained in:
josh committed 2026-08-19 13:14:53 -04:00
1 parent 8c92d442bb
commit 4a4647159e
3 files changed
+25 -3

No files matched your search

+15 -2
View File
@@ -1,3 +1,4 @@
require "fileutils"
require "rake/clean"
require "rspec/core/rake_task"
require "simplecov"
@@ -11,7 +12,10 @@ end
RSpec::Core::RakeTask.new(:spec, :example_pattern) do |task, args|
if args.example_pattern
ENV["partial_specs"] = "1"
task.rspec_opts = %W[-e "#{args.example_pattern}" -f documentation]
else
FileUtils.rm_rf("coverage")
end
end
task :spec do |task, args|
@@ -19,7 +23,7 @@ task :spec do |task, args|
original_stdout = $stdout
sio = StringIO.new
$stdout = sio
SimpleCov.collate Dir["coverage/.resultset.json"]
SimpleCov.collate Dir["coverage/parts/*/.resultset.json"]
$stdout = original_stdout
sio.string.lines.each do |line|
$stdout.write(line) unless line =~ /Coverage report generated for/
@@ -27,6 +31,15 @@ task :spec do |task, args|
end
end
task :valgrind do
begin
ENV["spec-valgrind"] = "1"
Rake::Task[:spec].execute
ensure
ENV.delete("spec-valgrind")
end
end
# dspec task is useful to test the distributable release script, but is not
# useful for coverage information.
desc "Dist Specs"
@@ -43,4 +56,4 @@ task :user_guide do
system("ruby", "-Ilib", "rb/gen_user_guide.rb")
end
task :all => [:spec, :dspec, :user_guide]
task :all => [:valgrind, :dspec, :user_guide]