Skip to content

Commit

Permalink
test: try using ruby_memcheck to look for leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Oct 22, 2021
1 parent 2e71c19 commit 827977a
Show file tree
Hide file tree
Showing 4 changed files with 44 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 @@ -296,3 +296,26 @@ jobs:
bundle install --local || bundle install
bundle exec rake compile -- --${{matrix.sys}}-system-libraries
bundle exec rake test
memcheck:
continue-on-error: true # this is experimental!
strategy:
fail-fast: false
matrix:
sys: ["enable", "disable"]
ruby: ["3.0"]
runs-on: ubuntu-latest
container:
image: ghcr.io/sparklemotion/nokogiri-test:mri-${{matrix.ruby}}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/cache@v2
if: matrix.sys == 'disable'
with:
path: ports
key: ports-ubuntu-${{hashFiles('dependencies.yml', 'patches/**/*.patch')}}
- run: bundle install --local || bundle install
- run: bundle exec rake compile -- --${{matrix.sys}}-system-libraries
- run: bundle exec rake test:memcheck
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source "https://rubygems.org"

gemspec

gem "ruby_memcheck", git: "https://github.com/peterzhu2118/ruby_memcheck"
15 changes: 15 additions & 0 deletions rakelib/test.rake
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
require "rake/testtask"

begin
require "ruby_memcheck"
valgrind_options = RubyMemcheck::Configuration::DEFAULT_VALGRIND_OPTIONS.dup
valgrind_options << "--gen-suppressions=all"
RubyMemcheck.config(binary_name: "nokogiri", valgrind_options: valgrind_options)
rescue LoadError
warn "could not load ruby_memcheck"
end

#
# much of this was ripped out of hoe-debugging
#
Expand Down Expand Up @@ -95,4 +104,10 @@ namespace "test" do
LldbTestTask.new("lldb") do |t|
nokogiri_test_task_configuration(t)
end

if defined?(RubyMemcheck)
RubyMemcheck::TestTask.new("memcheck") do |t|
nokogiri_test_task_configuration(t)
end
end
end
4 changes: 4 additions & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
# - "stress" - run tests with GC.stress set to true
# - NOKOGIRI_GC: read more in test/test_memory_leak.rb
#

# make sure we do one final major before the process exits (for valgrind)
at_exit { GC.start(full_mark: true) } unless ::RUBY_PLATFORM == "java"

require 'simplecov'
SimpleCov.start do
add_filter "/test/"
Expand Down

0 comments on commit 827977a

Please sign in to comment.