From 8a984b125fe4b146c4e1c7c7233cf77073b9a237 Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Thu, 21 Oct 2021 09:28:09 -0400 Subject: [PATCH 1/4] Add test:valgrind rake task --- Gemfile | 1 + Rakefile | 13 +++++++++++-- test/rotoscope_test.rb | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 876374c..8b9b7f6 100644 --- a/Gemfile +++ b/Gemfile @@ -5,3 +5,4 @@ gemspec gem "rubocop", "~> 1.22", require: false gem "rubocop-shopify", "~> 2.3.0", require: false +gem "ruby_memcheck", require: false diff --git a/Rakefile b/Rakefile index eaa778b..c95348b 100644 --- a/Rakefile +++ b/Rakefile @@ -31,10 +31,19 @@ end # ========================================================== require "rake/testtask" -Rake::TestTask.new("test") do |t| +require "ruby_memcheck" + +RubyMemcheck.config(binary_name: "rotoscope") + +test_config = lambda do |t| t.test_files = FileList["test/*_test.rb"] end -task(test: :build) + +Rake::TestTask.new(test: :build, &test_config) + +namespace :test do + RubyMemcheck::TestTask.new(valgrind: :build, &test_config) +end task :rubocop do require "rubocop/rake_task" diff --git a/test/rotoscope_test.rb b/test/rotoscope_test.rb index b2c3e03..6d3a0fb 100644 --- a/test/rotoscope_test.rb +++ b/test/rotoscope_test.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +at_exit { GC.start } # to reduce false positives in the test:valgrind rake task + $LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__)) $LOAD_PATH.unshift(File.expand_path("../", __FILE__)) require "rotoscope" From 8048b843a118daf060c0faedcf6ffe1d598a8a82 Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Thu, 21 Oct 2021 09:28:56 -0400 Subject: [PATCH 2/4] Use ruby 2.7.4 in dev.yml --- dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev.yml b/dev.yml index 49b064b..ece1374 100644 --- a/dev.yml +++ b/dev.yml @@ -5,7 +5,7 @@ env: ROTOSCOPE_COMPILE_ERROR: '1' up: - - ruby: 2.5.3 + - ruby: 2.7.4 - homebrew: - clang-format - bundler From 64531a5f36169018ee13a3083793988142589217 Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Thu, 21 Oct 2021 09:33:19 -0400 Subject: [PATCH 3/4] Add valgrind CI task --- .github/workflows/ci.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f49c46d..d618a55 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,3 +13,14 @@ jobs: ruby-version: 2.7 bundler-cache: true - run: bundle exec rake + + valgrind: + runs-on: ubuntu-latest + steps: + - run: sudo apt-get install -y valgrind + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + bundler-cache: true + - run: bundle exec rake test:valgrind From 0fbc0e4907e9c668d30b46a7bf4bee3246210feb Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Thu, 21 Oct 2021 12:23:35 -0400 Subject: [PATCH 4/4] Suppress rb_tracepoint_new leak so other leaks can be caught --- Rakefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index c95348b..44fa117 100644 --- a/Rakefile +++ b/Rakefile @@ -33,7 +33,12 @@ end require "rake/testtask" require "ruby_memcheck" -RubyMemcheck.config(binary_name: "rotoscope") +RubyMemcheck.config( + binary_name: "rotoscope", + skipped_ruby_functions: RubyMemcheck::Configuration::DEFAULT_SKIPPED_RUBY_FUNCTIONS + [ + /\Arb_tracepoint_new\z/, # TODO: Fix this upstream ruby bug + ], +) test_config = lambda do |t| t.test_files = FileList["test/*_test.rb"]