ruby_memcheck 2.0.1 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 597a64c7109c460a09cfaa57715d6f26a50104e8137c5184d9bf5f658954d07f
4
- data.tar.gz: e9524cbead271b0a5eb8abf85213c59d97d6629d1b6e2e2e3c03d0e94beb7970
3
+ metadata.gz: '0228bfb7a5cb25e9186f0e2702d4ce746b401ce580d8dfaa83af218a513fca8e'
4
+ data.tar.gz: 35e58e193c25c4d27aecdf46b962b115f443c52d1431c39deb53cb5ddc7c3e6d
5
5
  SHA512:
6
- metadata.gz: 2b38c33923e1370245b6184b5b4f16b993819bf02dc3fc76a4fc152c2ae10f50d4597b507983b5fafbbcc09933fd63e06c2c057f55f30c613ece717c68e74e45
7
- data.tar.gz: 30a0d75f4268ee39cc34cf865bfb7a0414f4bb89ce10995fd8e55517cc8090761c4d21356e908b2d93adf97a5e8200019e577cb4ba61d2361e7caca5097b6049
6
+ metadata.gz: e8fc3da2b1795fd7bde1a0e91b75c918540d194d875cbd9e8633de442859ac0d3c1eb10d70d1cb6d97655eba5c8262d8ec01e9d9dd8003ba75852bfa4e22314d
7
+ data.tar.gz: 936e627d62f56650fa074cd904922d154631bc08047ea8c6e1516481e895fa2c40001db02b1335feb287d919b6c06ce119d17bca7533af4ed8f25d12be437692
data/README.md CHANGED
@@ -9,7 +9,8 @@ This gem provides a sane way to use Valgrind's memcheck on your native extension
9
9
  1. [How does it work?](#how-does-it-work)
10
10
  1. [Limitations](#limitations)
11
11
  1. [Installation](#installation)
12
- 1. [Setup](#setup)
12
+ 1. [Running a Ruby script](#running-a-ruby-script)
13
+ 1. [Setup for test suites](#setup-for-test-suites)
13
14
  1. [Configuration](#configuration)
14
15
  1. [Suppression files](#suppression-files)
15
16
  1. [License](#license)
@@ -48,7 +49,16 @@ Because of the aggressive heuristics used to filter out false positives, there a
48
49
  gem install ruby_memcheck
49
50
  ```
50
51
 
51
- ## Setup
52
+ ## Running a Ruby script
53
+
54
+ You can run a Ruby script under ruby_memcheck. This will report all memory leaks in all native extensions found in your Ruby script. Simply replace the `ruby` part of your command with `ruby_memcheck`. For example:
55
+
56
+ ```sh
57
+ $ ruby_memcheck -e "puts 'Hello world'"
58
+ Hello world
59
+ ```
60
+
61
+ ## Setup for test suites
52
62
 
53
63
  > **Note**
54
64
  > If you encounter errors from Valgrind that looks like this:
@@ -69,7 +79,7 @@ gem install ruby_memcheck
69
79
  > sudo make install
70
80
  > ```
71
81
 
72
- The easiest way to use this gem is to use it on your test suite (minitest or RSpec) using rake.
82
+ You can use ruby_memcheck on your test suite (Minitest or RSpec) using rake.
73
83
 
74
84
  0. Install Valgrind.
75
85
  1. In your Rakefile, require this gem.
data/exe/ruby_memcheck ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift("#{__dir__}/../lib")
5
+
6
+ require "ruby_memcheck"
7
+
8
+ runner = RubyMemcheck::RubyRunner.new
9
+ exit(runner.run(*ARGV))
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyMemcheck
4
+ class RubyRunner
5
+ attr_reader :configuration
6
+ attr_reader :reporter
7
+
8
+ def initialize(*args)
9
+ @configuration =
10
+ if !args.empty? && args[0].is_a?(Configuration)
11
+ args.shift
12
+ else
13
+ RubyMemcheck.default_configuration
14
+ end
15
+ end
16
+
17
+ def run(*args, **options)
18
+ command = configuration.command(args.map { |a| Shellwords.escape(a) })
19
+
20
+ @reporter = TestTaskReporter.new(configuration)
21
+
22
+ @reporter.setup
23
+
24
+ system(command, options)
25
+ exit_code = $CHILD_STATUS.exitstatus
26
+
27
+ @reporter.report_valgrind_errors
28
+
29
+ exit_code
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyMemcheck
4
- VERSION = "2.0.1"
4
+ VERSION = "2.1.1"
5
5
  end
data/lib/ruby_memcheck.rb CHANGED
@@ -1,10 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "English"
4
+ require "shellwords"
3
5
  require "tempfile"
4
6
  require "rake/testtask"
5
7
 
6
8
  require "ruby_memcheck/configuration"
7
9
  require "ruby_memcheck/frame"
10
+ require "ruby_memcheck/ruby_runner"
8
11
  require "ruby_memcheck/stack"
9
12
  require "ruby_memcheck/test_task_reporter"
10
13
  require "ruby_memcheck/test_task"
@@ -60,3 +60,12 @@
60
60
  fun:rb_callable_method_entry
61
61
  ...
62
62
  }
63
+ {
64
+ The date library lazily initializes Regexps using static local variables through the function `regcomp`. The Regexp will end up being reported as a memory leak.
65
+ Memcheck:Leak
66
+ ...
67
+ fun:rb_enc_reg_new
68
+ ...
69
+ fun:date__parse
70
+ ...
71
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_memcheck
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Zhu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-09 00:00:00.000000000 Z
11
+ date: 2023-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -125,7 +125,8 @@ dependencies:
125
125
  description:
126
126
  email:
127
127
  - peter@peterzhu.ca
128
- executables: []
128
+ executables:
129
+ - ruby_memcheck
129
130
  extensions: []
130
131
  extra_rdoc_files: []
131
132
  files:
@@ -138,10 +139,12 @@ files:
138
139
  - LICENSE.txt
139
140
  - README.md
140
141
  - Rakefile
142
+ - exe/ruby_memcheck
141
143
  - lib/ruby_memcheck.rb
142
144
  - lib/ruby_memcheck/configuration.rb
143
145
  - lib/ruby_memcheck/frame.rb
144
146
  - lib/ruby_memcheck/rspec/rake_task.rb
147
+ - lib/ruby_memcheck/ruby_runner.rb
145
148
  - lib/ruby_memcheck/stack.rb
146
149
  - lib/ruby_memcheck/suppression.rb
147
150
  - lib/ruby_memcheck/test_helper.rb