hoe-debugging 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest ADDED
File without changes
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ === 1.1.0 / 2012-09-26
2
+
3
+ * Valgrind suppressions can be generated with `rake test:valgrind:suppression`
4
+ * If present, valgrind suppressions will be used when valgrinding.
5
+
1
6
  === 1.0.5 / 2012-06-19
2
7
 
3
8
  * RSpec support now works with TESTOPTS.
data/README.rdoc CHANGED
@@ -27,6 +27,10 @@ ruby legend, {Mike Dalessio}[http://mike.daless.io].
27
27
  $ rake test:gdb
28
28
  $ rake test:valgrind
29
29
 
30
+ # if you've got valgrind warnings you've deemed OK to suppress
31
+ $ rake test:valgrind:suppression
32
+ $ rake test:valgrind # this runs, suppressing the errors previously emitted by valgrind
33
+
30
34
 
31
35
  == Installation
32
36
 
@@ -35,11 +39,13 @@ ruby legend, {Mike Dalessio}[http://mike.daless.io].
35
39
 
36
40
  == License
37
41
 
42
+ (The MIT License)
43
+
38
44
  Copyright 2009
39
45
 
40
46
  * John Barnette (jbarnette@rubyforge.org)
41
47
  * {Aaron Patterson}[http://tenderlovemaking.com/]
42
- * {Mike Dalessio}[http://mike.daless.io]
48
+ * {Mike Dalessio}[http://mike.daless.io] (mike.dalessio@gmail.com)
43
49
 
44
50
  Permission is hereby granted, free of charge, to any person obtaining
45
51
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -3,13 +3,21 @@ require "hoe"
3
3
 
4
4
  Hoe.plugin :git
5
5
  Hoe.plugin :gemspec
6
+ Hoe.plugin :bundler
6
7
 
7
8
  Hoe.spec "hoe-debugging" do
8
9
  developer "John Barnette", "jbarnette@rubyforge.org"
10
+ developer "Mike Dalessio", "mike.dalessio@gmail.com"
9
11
 
10
12
  self.extra_rdoc_files = FileList["*.rdoc"]
11
13
  self.history_file = "CHANGELOG.rdoc"
12
14
  self.readme_file = "README.rdoc"
13
15
 
14
- extra_deps << ["hoe", ">= 2.2.0"]
16
+ license "MIT"
17
+
18
+ extra_dev_deps << ["hoe", ">= 3.1"]
19
+ extra_dev_deps << ["rspec", "~> 2.0"]
20
+ extra_dev_deps << ["hoe-git", ">= 0"]
21
+ extra_dev_deps << ["hoe-gemspec", ">= 0"]
22
+ extra_dev_deps << ["hoe-bundler", ">= 0"]
15
23
  end
data/lib/hoe/debugging.rb CHANGED
@@ -10,7 +10,7 @@ class Hoe #:nodoc:
10
10
  # * <tt>test:valgrind:mem0</tt>
11
11
 
12
12
  module Debugging
13
- VERSION = "1.0.5" #:nodoc:
13
+ VERSION = "1.1.0" #:nodoc:
14
14
 
15
15
  ##
16
16
  # Optional: Used to add flags to GDB. [default: <tt>[]</tt>]
@@ -49,29 +49,135 @@ class Hoe #:nodoc:
49
49
  cmd.join(' ')
50
50
  end
51
51
 
52
+ def hoe_debugging_command
53
+ "#{hoe_debugging_ruby} #{hoe_debugging_make_test_cmd}"
54
+ end
55
+
56
+ def hoe_debugging_run_valgrind command, cmdline_options=[]
57
+ sh "valgrind #{cmdline_options.join(' ')} #{command}"
58
+ end
59
+
60
+ def hoe_debugging_check_for_suppression_file options
61
+ if suppression_file = hoe_debugging_valgrind_helper.matching_suppression_file
62
+ puts "NOTICE: using valgrind suppressions in #{suppression_file.inspect}"
63
+ options << "--suppressions=#{suppression_file}"
64
+ end
65
+ end
66
+
67
+ def hoe_debugging_valgrind_helper
68
+ @valgrind_helper ||= ValgrindHelper.new name
69
+ end
70
+
52
71
  def define_debugging_tasks #:nodoc:
53
72
  desc "Run the test suite under GDB."
54
73
  task "test:gdb" do
55
- sh "gdb #{gdb_options.join ' '} --args #{hoe_debugging_ruby} #{hoe_debugging_make_test_cmd}"
74
+ sh "gdb #{gdb_options.join ' '} --args #{hoe_debugging_command}"
56
75
  end
57
76
 
58
77
  desc "Run the test suite under Valgrind."
59
78
  task "test:valgrind" do
60
- sh "valgrind #{valgrind_options.join ' '} #{hoe_debugging_ruby} #{hoe_debugging_make_test_cmd}"
79
+ vopts = valgrind_options
80
+ hoe_debugging_check_for_suppression_file vopts
81
+ hoe_debugging_run_valgrind hoe_debugging_command, vopts
61
82
  end
62
83
 
63
84
  desc "Run the test suite under Valgrind with memory-fill."
64
85
  task "test:valgrind:mem" do
65
- sh "valgrind #{valgrind_options.join ' '} " +
66
- "--freelist-vol=100000000 --malloc-fill=6D --free-fill=66 " +
67
- "#{hoe_debugging_ruby} #{hoe_debugging_make_test_cmd}"
86
+ vopts = valgrind_options + ["--freelist-vol=100000000", "--malloc-fill=6D", "--free-fill=66"]
87
+ hoe_debugging_check_for_suppression_file vopts
88
+ hoe_debugging_run_valgrind hoe_debugging_command, vopts
68
89
  end
69
90
 
70
91
  desc "Run the test suite under Valgrind with memory-zero."
71
92
  task "test:valgrind:mem0" do
72
- sh "valgrind #{valgrind_options.join ' '} " +
73
- "--freelist-vol=100000000 --malloc-fill=00 --free-fill=00 " +
74
- "#{hoe_debugging_ruby} #{hoe_debugging_make_test_cmd}"
93
+ vopts = valgrind_options + ["--freelist-vol=100000000", "--malloc-fill=00", "--free-fill=00"]
94
+ hoe_debugging_check_for_suppression_file vopts
95
+ hoe_debugging_run_valgrind hoe_debugging_command, vopts
96
+ end
97
+
98
+ desc "Generate a valgrind suppression file for your test suite."
99
+ task "test:valgrind:suppression" do
100
+ vopts = valgrind_options + ["--gen-suppressions=all"]
101
+ Tempfile.open "hoe_debugging_valgrind_suppression_log" do |logfile|
102
+ hoe_debugging_run_valgrind "#{hoe_debugging_ruby} #{hoe_debugging_make_test_cmd} 2> #{logfile.path}", vopts
103
+ hoe_debugging_valgrind_helper.save_suppressions_from logfile.path
104
+ end
105
+ end
106
+ end
107
+
108
+ class ValgrindHelper
109
+ DEFAULT_DIRECTORY_NAME = "suppressions"
110
+
111
+ attr_accessor :directory, :project_name
112
+
113
+ def initialize project_name, options={}
114
+ @project_name = project_name
115
+ @directory = options[:directory] || DEFAULT_DIRECTORY_NAME
116
+ end
117
+
118
+ def formatted_ruby_version
119
+ engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
120
+ %Q{#{engine}-#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}}
121
+ end
122
+
123
+ def version_matches
124
+ matches = [formatted_ruby_version]
125
+ matches << formatted_ruby_version.split(".")[0,3].join(".")
126
+ matches << formatted_ruby_version.split(".")[0,2].join(".")
127
+ matches
128
+ end
129
+
130
+ def parse_suppressions_from logfile_name
131
+ suppressions = []
132
+ File.open logfile_name do |logfile|
133
+ suppression = nil
134
+ while ! logfile.eof? do
135
+ line = logfile.readline
136
+ if suppression.nil?
137
+ if line =~ /\<insert_a_suppression_name_here\>/
138
+ suppression = "{\n"
139
+ suppression << line
140
+ end
141
+ else
142
+ suppression << line
143
+ if line =~ /^\}$/
144
+ suppressions << suppression
145
+ suppression = nil
146
+ end
147
+ end
148
+ end
149
+ end
150
+ suppressions.uniq.join
151
+ end
152
+
153
+ def save_suppressions_from logfile, options={}
154
+ ensure_directory_exists
155
+ suppressions = parse_suppressions_from logfile
156
+ filename = File.join directory, "#{project_name}_#{formatted_ruby_version}.supp"
157
+ File.open(filename, "w") { |out| out.write suppressions }
158
+ filename
159
+ end
160
+
161
+ def matching_suppression_file
162
+ version_matches.each do |version_string|
163
+ matches = Dir[File.join(directory, "#{project_name}_#{version_string}*.supp")]
164
+ return matches[0] if matches[0]
165
+ end
166
+ nil
167
+ end
168
+
169
+ def valgrind command, options={}
170
+ sh "valgrind #{vopts.join ' '} #{hoe_debugging_ruby} #{hoe_debugging_make_test_cmd}"
171
+ end
172
+
173
+ private
174
+
175
+ def ensure_directory_exists
176
+ return if File.directory? directory
177
+ FileUtils.mkdir_p directory
178
+ File.open(File.join(directory, "README.txt"), "w") do |readme|
179
+ readme.puts "This directory contains valgrind suppression files generated by the hoe-debugging gem."
180
+ end
75
181
  end
76
182
  end
77
183
  end
metadata CHANGED
@@ -1,38 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoe-debugging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - John Barnette
9
+ - Mike Dalessio
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2012-06-19 00:00:00.000000000 Z
13
+ date: 2012-09-26 00:00:00.000000000 Z
13
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rdoc
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '3.10'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '3.10'
14
31
  - !ruby/object:Gem::Dependency
15
32
  name: hoe
16
- requirement: &16990920 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
17
34
  none: false
18
35
  requirements:
19
36
  - - ! '>='
20
37
  - !ruby/object:Gem::Version
21
- version: 2.2.0
22
- type: :runtime
38
+ version: '3.1'
39
+ type: :development
23
40
  prerelease: false
24
- version_requirements: *16990920
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '3.1'
25
47
  - !ruby/object:Gem::Dependency
26
- name: rdoc
27
- requirement: &16990480 !ruby/object:Gem::Requirement
48
+ name: rspec
49
+ requirement: !ruby/object:Gem::Requirement
28
50
  none: false
29
51
  requirements:
30
52
  - - ~>
31
53
  - !ruby/object:Gem::Version
32
- version: '3.10'
54
+ version: '2.0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '2.0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: hoe-git
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: hoe-gemspec
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: hoe-bundler
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
33
103
  type: :development
34
104
  prerelease: false
35
- version_requirements: *16990480
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
36
111
  description: ! 'A Hoe plugin to help you debug your C extensions. This plugin provides
37
112
 
38
113
  <tt>test:gdb</tt> and <tt>test:valgrind</tt> tasks (plus a few
@@ -53,20 +128,23 @@ description: ! 'A Hoe plugin to help you debug your C extensions. This plugin pr
53
128
  ruby legend, {Mike Dalessio}[http://mike.daless.io].'
54
129
  email:
55
130
  - jbarnette@rubyforge.org
131
+ - mike.dalessio@gmail.com
56
132
  executables: []
57
133
  extensions: []
58
134
  extra_rdoc_files:
135
+ - CHANGELOG.rdoc
59
136
  - Manifest.txt
60
137
  - README.rdoc
61
- - CHANGELOG.rdoc
62
138
  files:
63
139
  - CHANGELOG.rdoc
64
140
  - Manifest.txt
65
141
  - README.rdoc
66
142
  - Rakefile
67
143
  - lib/hoe/debugging.rb
144
+ - .gemtest
68
145
  homepage: http://github.com/jbarnette/hoe-debugging
69
- licenses: []
146
+ licenses:
147
+ - MIT
70
148
  post_install_message:
71
149
  rdoc_options:
72
150
  - --main
@@ -79,6 +157,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
157
  - - ! '>='
80
158
  - !ruby/object:Gem::Version
81
159
  version: '0'
160
+ segments:
161
+ - 0
162
+ hash: -2243994185650622134
82
163
  required_rubygems_version: !ruby/object:Gem::Requirement
83
164
  none: false
84
165
  requirements:
@@ -87,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
168
  version: '0'
88
169
  requirements: []
89
170
  rubyforge_project: hoe-debugging
90
- rubygems_version: 1.8.15
171
+ rubygems_version: 1.8.24
91
172
  signing_key:
92
173
  specification_version: 3
93
174
  summary: A Hoe plugin to help you debug your C extensions