Skip to content

Commit

Permalink
Merge pull request #89 from Shopify/valgrind
Browse files Browse the repository at this point in the history
Add test:valgrind rake task and use it in CI
  • Loading branch information
dylanahsmith authored Oct 21, 2021
2 parents d896ccc + 0fbc0e4 commit 34d619f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ gemspec

gem "rubocop", "~> 1.22", require: false
gem "rubocop-shopify", "~> 2.3.0", require: false
gem "ruby_memcheck", require: false
18 changes: 16 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ env:
ROTOSCOPE_COMPILE_ERROR: '1'

up:
- ruby: 2.5.3
- ruby: 2.7.4
- homebrew:
- clang-format
- bundler
Expand Down
2 changes: 2 additions & 0 deletions test/rotoscope_test.rb
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 34d619f

Please sign in to comment.