From 6c66c9042659aeecead72abd5231dd5a1f2a9a13 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 19 Aug 2026 09:24:03 -0400 Subject: [PATCH] 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 --- Rakefile.rb | 12 +++++++++++- spec/propane_spec.rb | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Rakefile.rb b/Rakefile.rb index 64762a7..b788ace 100644 --- a/Rakefile.rb +++ b/Rakefile.rb @@ -26,6 +26,16 @@ task :spec do |task, args| 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 # useful for coverage information. @@ -43,4 +53,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] diff --git a/spec/propane_spec.rb b/spec/propane_spec.rb index e2b167c..1995f41 100644 --- a/spec/propane_spec.rb +++ b/spec/propane_spec.rb @@ -119,7 +119,7 @@ EOF results = Results.new(stdout, stderr, status) # Valgrind is only reliably available on Linux, so limit the leak check to # 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") vgout = stdout + stderr File.binwrite("spec/run/.vgout", vgout)