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 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..44fa117 100644 --- a/Rakefile +++ b/Rakefile @@ -31,10 +31,24 @@ end # ========================================================== require "rake/testtask" -Rake::TestTask.new("test") do |t| +require "ruby_memcheck" + +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"] 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/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 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"