Skip to content

Commit

Permalink
Setup ruby_memcheck
Browse files Browse the repository at this point in the history
Hoping it might find the leak reported in #460
  • Loading branch information
byroot committed Oct 30, 2024
1 parent 942cd3f commit 0863531
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,26 @@ jobs:

- run: gem install pkg/*.gem
if: ${{ matrix.ruby != '3.2' }}

valgrind:
name: Ruby memcheck
runs-on: ubuntu-latest
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v3

- name: Set up Ruby
uses: ruby/setup-ruby-pkgs@v1
with:
ruby-version: "3.3"
apt-get: ragel valgrind

- run: |
bundle config --without benchmark
bundle install
- run: rake compile

- run: rake valgrind
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ else
end

group :development do
gem "ruby_memcheck" if RUBY_PLATFORM =~ /linux/i
gem "ostruct"
gem "rake"
gem "rake-compiler"
Expand Down
10 changes: 10 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,16 @@ else
t.options = '-v'
end

begin
require "ruby_memcheck"
RubyMemcheck::TestTask.new(valgrind: [ :set_env_ext, :check_env, :compile, :do_test_ext ]) do |t|
t.test_files = FileList['test/json/*_test.rb']
t.verbose = true
t.options = '-v'
end
rescue LoadError
end

desc "Update the tags file"
task :tags do
system 'ctags', *Dir['**/*.{rb,c,h,java}']
Expand Down
3 changes: 3 additions & 0 deletions test/json/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
case ENV['JSON']
when 'pure'
$LOAD_PATH.unshift(File.expand_path('../../../lib', __FILE__))
$stderr.puts("Testing JSON::Pure")
require 'json/pure'
when 'ext'
$stderr.puts("Testing JSON::Ext")
$LOAD_PATH.unshift(File.expand_path('../../../ext', __FILE__), File.expand_path('../../../lib', __FILE__))
require 'json/ext'
else
$LOAD_PATH.unshift(File.expand_path('../../../ext', __FILE__), File.expand_path('../../../lib', __FILE__))
$stderr.puts("Testing JSON")
require 'json'
end

Expand Down

0 comments on commit 0863531

Please sign in to comment.