ruby_process 0.0.9 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,19 +0,0 @@
1
- = ruby_process
2
-
3
- Description goes here.
4
-
5
- == Contributing to ruby_process
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
- * Fork the project.
10
- * Start a feature/bugfix branch.
11
- * Commit and push until you are happy with your contribution.
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2012 Kasper Johansen. See LICENSE.txt for
18
- further details.
19
-
@@ -1,101 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "RubyProcess" do
4
- it "should be able to do quick in-and-outs without leaking" do
5
- ts = []
6
-
7
- 1.upto(2) do |tcount|
8
- ts << Thread.new do
9
- 1.upto(10) do
10
- Ruby_process::Cproxy.run do |data|
11
- sp = data[:subproc]
12
- str = sp.new(:String, "Wee")
13
- res1 = str.include?("Kasper")
14
- end
15
- end
16
- end
17
- end
18
-
19
- ts.each do |thread|
20
- thread.join
21
- end
22
- end
23
-
24
- it "should be able to do basic stuff" do
25
- require "stringio"
26
-
27
- Ruby_process::Cproxy.run do |data|
28
- data[:subproc].static(:Object, :require, "rubygems")
29
- data[:subproc].static(:Object, :require, "rexml/document")
30
-
31
- doc = Ruby_process::Cproxy::REXML::Document.new
32
- doc.add_element("test")
33
-
34
- strio = StringIO.new
35
- doc.write(strio)
36
-
37
- raise "Didnt expect REXML to be defined in host process." if Kernel.const_defined?(:REXML)
38
- raise "Expected strio to contain '<test/>' but it didnt: '#{strio.string}'." if strio.string != "<test/>"
39
- end
40
- end
41
-
42
- it "should be able to do multiple calls at once" do
43
- ts = []
44
-
45
- 0.upto(9) do |tcount|
46
- ts << Thread.new do
47
- Ruby_process::Cproxy.run do |data|
48
- sp = data[:subproc]
49
- sp.new(:String, "Wee")
50
-
51
- 1.upto(250) do
52
- str = sp.new(:String, "Kasper Johansen")
53
-
54
- res1 = str.include?("Kasper")
55
- str << " More"
56
-
57
- res2 = str.include?("Johansen")
58
- str << " Even more"
59
-
60
- res3 = str.include?("Christina")
61
- str << " Much more"
62
-
63
- raise "Expected res1 to be true but it wasnt: '#{res1}'." if res1 != true
64
- raise "Expected res2 to be true but it wasnt: '#{res2}'." if res2 != true
65
- raise "Expected res3 to be false but it wasnt: '#{res3}'." if res3 != false
66
-
67
- #print tcount
68
- end
69
- end
70
- end
71
- end
72
-
73
- count = 0
74
- ts.each do |t|
75
- count += 1
76
- #puts "Thread #{count}"
77
- t.join
78
- end
79
- end
80
-
81
- it "should not leak" do
82
- str = "kasper"
83
- str = nil
84
- sleep 0.1
85
- GC.start
86
- sleep 0.1
87
-
88
- count_objs = 0
89
- ObjectSpace.each_object(Ruby_process) do |obj|
90
- count_objs += 1
91
- end
92
-
93
- count_proxy_objs = 0
94
- ObjectSpace.each_object(Ruby_process::Proxyobj) do |obj|
95
- count_proxy_objs += 1
96
- end
97
-
98
- raise "Expected 1 or less 'Ruby_process' to be left but it wasnt like that: #{count_objs} (proxy objects: #{count_proxy_objs})" if count_objs > 1
99
- raise "Expected 0 constants to be left on cproxy." if !Ruby_process::Cproxy.constants.empty?
100
- end
101
- end