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)