Skip to content

Commit 0863531

Browse files
committed
Setup ruby_memcheck
Hoping it might find the leak reported in #460
1 parent 942cd3f commit 0863531

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,26 @@ jobs:
5656

5757
- run: gem install pkg/*.gem
5858
if: ${{ matrix.ruby != '3.2' }}
59+
60+
valgrind:
61+
name: Ruby memcheck
62+
runs-on: ubuntu-latest
63+
strategy:
64+
fail-fast: false
65+
66+
steps:
67+
- uses: actions/checkout@v3
68+
69+
- name: Set up Ruby
70+
uses: ruby/setup-ruby-pkgs@v1
71+
with:
72+
ruby-version: "3.3"
73+
apt-get: ragel valgrind
74+
75+
- run: |
76+
bundle config --without benchmark
77+
bundle install
78+
79+
- run: rake compile
80+
81+
- run: rake valgrind

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ else
77
end
88

99
group :development do
10+
gem "ruby_memcheck" if RUBY_PLATFORM =~ /linux/i
1011
gem "ostruct"
1112
gem "rake"
1213
gem "rake-compiler"

Rakefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,16 @@ else
250250
t.options = '-v'
251251
end
252252

253+
begin
254+
require "ruby_memcheck"
255+
RubyMemcheck::TestTask.new(valgrind: [ :set_env_ext, :check_env, :compile, :do_test_ext ]) do |t|
256+
t.test_files = FileList['test/json/*_test.rb']
257+
t.verbose = true
258+
t.options = '-v'
259+
end
260+
rescue LoadError
261+
end
262+
253263
desc "Update the tags file"
254264
task :tags do
255265
system 'ctags', *Dir['**/*.{rb,c,h,java}']

test/json/test_helper.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
case ENV['JSON']
22
when 'pure'
33
$LOAD_PATH.unshift(File.expand_path('../../../lib', __FILE__))
4+
$stderr.puts("Testing JSON::Pure")
45
require 'json/pure'
56
when 'ext'
7+
$stderr.puts("Testing JSON::Ext")
68
$LOAD_PATH.unshift(File.expand_path('../../../ext', __FILE__), File.expand_path('../../../lib', __FILE__))
79
require 'json/ext'
810
else
911
$LOAD_PATH.unshift(File.expand_path('../../../ext', __FILE__), File.expand_path('../../../lib', __FILE__))
12+
$stderr.puts("Testing JSON")
1013
require 'json'
1114
end
1215

0 commit comments

Comments
 (0)