living_dead 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.travis.yml +5 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +108 -0
  7. data/Rakefile +17 -0
  8. data/changelog.md +5 -0
  9. data/ext/living_dead/extconf.rb +2 -0
  10. data/ext/living_dead/living_dead.c +217 -0
  11. data/lib/living_dead.rb +96 -0
  12. data/lib/living_dead/version.rb +3 -0
  13. data/living_dead.gemspec +28 -0
  14. data/scratch.rb +20 -0
  15. data/spec/fixtures/singleton_class/in_class.rb +24 -0
  16. data/spec/fixtures/singleton_class/in_proc.rb +23 -0
  17. data/spec/fixtures/singleton_class/method_in_proc.rb +21 -0
  18. data/spec/fixtures/singleton_class/retained.rb +20 -0
  19. data/spec/fixtures/singleton_class/simple.rb +21 -0
  20. data/spec/fixtures/singleton_class_instance_eval/in_class.rb +24 -0
  21. data/spec/fixtures/singleton_class_instance_eval/in_proc.rb +24 -0
  22. data/spec/fixtures/singleton_class_instance_eval/method_in_proc.rb +22 -0
  23. data/spec/fixtures/singleton_class_instance_eval/retained.rb +21 -0
  24. data/spec/fixtures/singleton_class_instance_eval/simple.rb +22 -0
  25. data/spec/fixtures/string/not_retained.rb +19 -0
  26. data/spec/fixtures/string/retained.rb +19 -0
  27. data/spec/fixtures/string/string_in_class.rb +22 -0
  28. data/spec/fixtures/string/string_in_proc.rb +21 -0
  29. data/spec/fixtures/string/string_method_in_proc.rb +20 -0
  30. data/spec/fixtures/times_map/in_class.rb +24 -0
  31. data/spec/fixtures/times_map/in_proc.rb +25 -0
  32. data/spec/fixtures/times_map/method_in_proc.rb +22 -0
  33. data/spec/fixtures/times_map/retained.rb +22 -0
  34. data/spec/fixtures/times_map/simple.rb +22 -0
  35. data/spec/living_dead/singleton_class_instance_eval_spec.rb +30 -0
  36. data/spec/living_dead/singleton_class_spec.rb +30 -0
  37. data/spec/living_dead/string_spec.rb +24 -0
  38. data/spec/living_dead/times_map_spec.rb +30 -0
  39. data/spec/living_dead_spec.rb +24 -0
  40. data/spec/spec_helper.rb +28 -0
  41. metadata +168 -0
@@ -0,0 +1,22 @@
1
+ $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../../lib")))
2
+
3
+ require 'living_dead'
4
+
5
+ def run
6
+ array = 1.times.map {
7
+ obj = Object.new
8
+ LivingDead.trace(obj)
9
+ obj
10
+ }
11
+ array = nil
12
+ return nil
13
+ end
14
+
15
+ -> { run }.call
16
+
17
+ alive_count = LivingDead.traced_objects.select { |tracer| tracer.retained? }.length
18
+
19
+ expected = Integer(ENV["EXPECTED_OUT"] || 0)
20
+ actual = alive_count
21
+ result = expected == actual ? "PASS" : "FAIL"
22
+ puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -0,0 +1,22 @@
1
+ $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../../lib")))
2
+
3
+ require 'living_dead'
4
+
5
+ def run
6
+ array = 1.times.map {
7
+ @obj = Object.new
8
+ LivingDead.trace(@obj)
9
+ @obj
10
+ }
11
+ array = nil
12
+ return nil
13
+ end
14
+
15
+ run
16
+
17
+ alive_count = LivingDead.traced_objects.select { |tracer| tracer.retained? }.length
18
+
19
+ expected = Integer(ENV["EXPECTED_OUT"] || 1)
20
+ actual = alive_count
21
+ result = expected == actual ? "PASS" : "FAIL"
22
+ puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -0,0 +1,22 @@
1
+ $LOAD_PATH.unshift(File.expand_path(File.join(__FILE__, "../../../../lib")))
2
+
3
+ require 'living_dead'
4
+
5
+ def run
6
+ array = 1.times.map {
7
+ obj = Object.new
8
+ LivingDead.trace(obj)
9
+ obj
10
+ }
11
+ array = nil
12
+ return nil
13
+ end
14
+
15
+ run
16
+
17
+ alive_count = LivingDead.traced_objects.select { |tracer| tracer.retained? }.length
18
+
19
+ expected = Integer(ENV["EXPECTED_OUT"] || 0)
20
+ actual = alive_count
21
+ result = expected == actual ? "PASS" : "FAIL"
22
+ puts "#{result}: expected: #{expected}, actual: #{actual}"
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe LivingDead do
4
+ context "calling `singleton_class.instance_eval` " do
5
+ it "does not retain in the simple case" do
6
+ out = run("env ruby #{ fixtures('singleton_class_instance_eval/simple.rb') }")
7
+ expect(out).to match("PASS")
8
+ end
9
+
10
+ it "does retain objects when used with a instance variable" do
11
+ out = run("env ruby #{ fixtures('singleton_class_instance_eval/retained.rb') }")
12
+ expect(out).to match("PASS")
13
+ end
14
+
15
+ it "does not retain in a class" do
16
+ out = run("env ruby #{ fixtures('singleton_class_instance_eval/in_class.rb') }")
17
+ expect(out).to match("PASS")
18
+ end
19
+
20
+ it "does not retain in a proc" do
21
+ out = run("env ruby #{ fixtures('singleton_class_instance_eval/in_proc.rb') }")
22
+ expect(out).to match("PASS")
23
+ end
24
+
25
+ it "does not retain in method in proc" do
26
+ out = run("env ruby #{ fixtures('singleton_class_instance_eval/method_in_proc.rb') }")
27
+ expect(out).to match("PASS")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe LivingDead do
4
+ context "calling `singleton_class` " do
5
+ it "does not retain in the simple case" do
6
+ out = run("env ruby #{ fixtures('singleton_class/simple.rb') }")
7
+ expect(out).to match("PASS")
8
+ end
9
+
10
+ it "does retain objects when used with a instance variable" do
11
+ out = run("env ruby #{ fixtures('singleton_class/retained.rb') }")
12
+ expect(out).to match("PASS")
13
+ end
14
+
15
+ it "does not retain in a class" do
16
+ out = run("env ruby #{ fixtures('singleton_class/in_class.rb') }")
17
+ expect(out).to match("PASS")
18
+ end
19
+
20
+ it "does not retain in a proc" do
21
+ out = run("env ruby #{ fixtures('singleton_class/in_proc.rb') }")
22
+ expect(out).to match("PASS")
23
+ end
24
+
25
+ it "does not retain in method in proc" do
26
+ out = run("env ruby #{ fixtures('singleton_class/method_in_proc.rb') }")
27
+ expect(out).to match("PASS")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe LivingDead do
4
+ context "tracing strings" do
5
+ it "determines objects are NOT retained" do
6
+ out = run("env ruby #{ fixtures('string/not_retained.rb') }")
7
+ expect(out).to match("PASS")
8
+
9
+ out = run("env ruby #{ fixtures('string/string_in_class.rb') }")
10
+ expect(out).to match("PASS")
11
+
12
+ out = run("env ruby #{ fixtures('string/string_in_proc.rb') }")
13
+ expect(out).to match("PASS")
14
+
15
+ out = run("env ruby #{ fixtures('string/string_method_in_proc.rb') }")
16
+ expect(out).to match("PASS")
17
+ end
18
+
19
+ it "determines objects ARE retained" do
20
+ out = run("env ruby #{ fixtures('string/retained.rb') }")
21
+ expect(out).to match("PASS")
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe LivingDead do
4
+ context "calling `times.map` " do
5
+ it "does not retain in the simple case" do
6
+ out = run("env ruby #{ fixtures('times_map/simple.rb') }")
7
+ expect(out).to match("PASS")
8
+ end
9
+
10
+ it "does retain objects when used with a instance variable" do
11
+ out = run("env ruby #{ fixtures('times_map/retained.rb') }")
12
+ expect(out).to match("PASS")
13
+ end
14
+
15
+ it "does not retain in a class" do
16
+ out = run("env ruby #{ fixtures('times_map/in_class.rb') }")
17
+ expect(out).to match("PASS")
18
+ end
19
+
20
+ it "does not retain in a proc" do
21
+ out = run("env ruby #{ fixtures('times_map/in_proc.rb') }")
22
+ expect(out).to match("PASS")
23
+ end
24
+
25
+ it "does not retain in method in proc" do
26
+ out = run("env ruby #{ fixtures('times_map/method_in_proc.rb') }")
27
+ expect(out).to match("PASS")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe LivingDead do
4
+ context "tracing strings" do
5
+ it "determines objects are NOT retained" do
6
+ out = run("env ruby #{ fixtures('string/not_retained.rb') }")
7
+ expect(out).to match("PASS")
8
+
9
+ out = run("env ruby #{ fixtures('string/string_in_class.rb') }")
10
+ expect(out).to match("PASS")
11
+
12
+ out = run("env ruby #{ fixtures('string/string_in_proc.rb') }")
13
+ expect(out).to match("PASS")
14
+
15
+ out = run("env ruby #{ fixtures('string/string_method_in_proc.rb') }")
16
+ expect(out).to match("PASS")
17
+ end
18
+
19
+ it "determines objects ARE retained" do
20
+ out = run("env ruby #{ fixtures('string/retained.rb') }")
21
+ expect(out).to match("PASS")
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,28 @@
1
+ require 'pathname'
2
+ require "open3"
3
+ require 'tempfile'
4
+ require 'tmpdir'
5
+ require 'fileutils'
6
+
7
+ require 'rubygems'
8
+ require 'bundler/setup'
9
+ require 'living_dead'
10
+
11
+ RSpec.configure do |config|
12
+ config.mock_framework = :rspec
13
+ end
14
+
15
+
16
+ def fixtures(name)
17
+ Pathname.new(File.expand_path("../fixtures", __FILE__)).join(name)
18
+ end
19
+
20
+ def run(cmd)
21
+ out = ""
22
+ Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
23
+ err = stderr.read
24
+ raise err unless err.empty?
25
+ out = stdout.read
26
+ end
27
+ out
28
+ end
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: living_dead
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Richard Schneeman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake-compiler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: LivingDead traces objects to see if they are retained or freed by MRI
70
+ email:
71
+ - richard.schneeman+rubygems@gmail.com
72
+ executables: []
73
+ extensions:
74
+ - ext/living_dead/extconf.rb
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - changelog.md
84
+ - ext/living_dead/.DS_Store
85
+ - ext/living_dead/extconf.rb
86
+ - ext/living_dead/living_dead.c
87
+ - lib/living_dead.rb
88
+ - lib/living_dead/version.rb
89
+ - living_dead.gemspec
90
+ - scratch.rb
91
+ - spec/fixtures/singleton_class/in_class.rb
92
+ - spec/fixtures/singleton_class/in_proc.rb
93
+ - spec/fixtures/singleton_class/method_in_proc.rb
94
+ - spec/fixtures/singleton_class/retained.rb
95
+ - spec/fixtures/singleton_class/simple.rb
96
+ - spec/fixtures/singleton_class_instance_eval/in_class.rb
97
+ - spec/fixtures/singleton_class_instance_eval/in_proc.rb
98
+ - spec/fixtures/singleton_class_instance_eval/method_in_proc.rb
99
+ - spec/fixtures/singleton_class_instance_eval/retained.rb
100
+ - spec/fixtures/singleton_class_instance_eval/simple.rb
101
+ - spec/fixtures/string/not_retained.rb
102
+ - spec/fixtures/string/retained.rb
103
+ - spec/fixtures/string/string_in_class.rb
104
+ - spec/fixtures/string/string_in_proc.rb
105
+ - spec/fixtures/string/string_method_in_proc.rb
106
+ - spec/fixtures/times_map/in_class.rb
107
+ - spec/fixtures/times_map/in_proc.rb
108
+ - spec/fixtures/times_map/method_in_proc.rb
109
+ - spec/fixtures/times_map/retained.rb
110
+ - spec/fixtures/times_map/simple.rb
111
+ - spec/living_dead/singleton_class_instance_eval_spec.rb
112
+ - spec/living_dead/singleton_class_spec.rb
113
+ - spec/living_dead/string_spec.rb
114
+ - spec/living_dead/times_map_spec.rb
115
+ - spec/living_dead_spec.rb
116
+ - spec/spec_helper.rb
117
+ homepage: https://github.com/schneems/living_dead
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: 2.1.0
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.6.8
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: LivingDead traces objects to see if they are retained or freed by MRI
141
+ test_files:
142
+ - spec/fixtures/singleton_class/in_class.rb
143
+ - spec/fixtures/singleton_class/in_proc.rb
144
+ - spec/fixtures/singleton_class/method_in_proc.rb
145
+ - spec/fixtures/singleton_class/retained.rb
146
+ - spec/fixtures/singleton_class/simple.rb
147
+ - spec/fixtures/singleton_class_instance_eval/in_class.rb
148
+ - spec/fixtures/singleton_class_instance_eval/in_proc.rb
149
+ - spec/fixtures/singleton_class_instance_eval/method_in_proc.rb
150
+ - spec/fixtures/singleton_class_instance_eval/retained.rb
151
+ - spec/fixtures/singleton_class_instance_eval/simple.rb
152
+ - spec/fixtures/string/not_retained.rb
153
+ - spec/fixtures/string/retained.rb
154
+ - spec/fixtures/string/string_in_class.rb
155
+ - spec/fixtures/string/string_in_proc.rb
156
+ - spec/fixtures/string/string_method_in_proc.rb
157
+ - spec/fixtures/times_map/in_class.rb
158
+ - spec/fixtures/times_map/in_proc.rb
159
+ - spec/fixtures/times_map/method_in_proc.rb
160
+ - spec/fixtures/times_map/retained.rb
161
+ - spec/fixtures/times_map/simple.rb
162
+ - spec/living_dead/singleton_class_instance_eval_spec.rb
163
+ - spec/living_dead/singleton_class_spec.rb
164
+ - spec/living_dead/string_spec.rb
165
+ - spec/living_dead/times_map_spec.rb
166
+ - spec/living_dead_spec.rb
167
+ - spec/spec_helper.rb
168
+ has_rdoc: