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
This commit is contained in:
josh committed 2026-08-19 09:24:03 -04:00
1 parent 8c92d442bb
commit 6c66c90426
2 files changed
+12 -2

No files matched your search

+11 -1
View File
@@ -26,6 +26,16 @@ task :spec do |task, args|
end end
end end
end end
task :spec => :clean
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 # dspec task is useful to test the distributable release script, but is not
# useful for coverage information. # useful for coverage information.
@@ -43,4 +53,4 @@ task :user_guide do
system("ruby", "-Ilib", "rb/gen_user_guide.rb") system("ruby", "-Ilib", "rb/gen_user_guide.rb")
end end
task :all => [:spec, :dspec, :user_guide] task :all => [:valgrind, :dspec, :user_guide]
+1 -1
View File
@@ -119,7 +119,7 @@ EOF
results = Results.new(stdout, stderr, status) results = Results.new(stdout, stderr, status)
# Valgrind is only reliably available on Linux, so limit the leak check to # Valgrind is only reliably available on Linux, so limit the leak check to
# Linux platforms. # Linux platforms.
if RUBY_PLATFORM =~ /linux/ if RUBY_PLATFORM =~ /linux/ && ENV["spec-valgrind"]
stdout, stderr, status = Open3.capture3("valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose spec/run/testparser") stdout, stderr, status = Open3.capture3("valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose spec/run/testparser")
vgout = stdout + stderr vgout = stdout + stderr
File.binwrite("spec/run/.vgout", vgout) File.binwrite("spec/run/.vgout", vgout)