zerg_support 0.0.5 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/test/test_spawn.rb CHANGED
@@ -8,7 +8,7 @@ require 'flexmock/test_unit'
8
8
 
9
9
  class TestSpawn < Test::Unit::TestCase
10
10
  def temp_file
11
- now_cookie = "zerg_test_#{Time.now.to_f}"
11
+ now_cookie = "zerg_test_#{Time.now.to_f}s"
12
12
  File.open(now_cookie, 'w') {}
13
13
  return now_cookie
14
14
  end
@@ -28,7 +28,7 @@ class TestSpawn < Test::Unit::TestCase
28
28
  def test_stdout_redirect
29
29
  pid = Zerg::Support::Process.spawn 'ruby', ['-e', 'print "1234\n"'],
30
30
  STDOUT => @out_file
31
- Process.wait pid
31
+ Process.waitpid pid
32
32
 
33
33
  assert_equal "1234\n", File.read(@out_file)
34
34
  end
@@ -38,37 +38,58 @@ class TestSpawn < Test::Unit::TestCase
38
38
 
39
39
  pid = Zerg::Support::Process.spawn 'ruby', ['-e', "print gets"],
40
40
  STDIN => @in_file, STDOUT => @out_file
41
- Process.wait pid
41
+ Process.waitpid pid
42
42
  assert_equal "1234\n", File.read(@out_file)
43
43
  end
44
44
 
45
45
  def test_stderr_redirect
46
46
  pid = Zerg::Support::Process.spawn 'ruby', ['-e', "raise 'zerg_stderr'"],
47
- STDOUT => @out_file, STDERR => STDOUT
48
- Process.wait pid
47
+ STDERR => @out_file
48
+ Process.waitpid pid
49
49
  assert_equal "-e:1: zerg_stderr (RuntimeError)\n", File.read(@out_file)
50
50
  end
51
+
52
+ def test_redirect_cascade
53
+ pid = Zerg::Support::Process.spawn 'ruby',
54
+ ['-e', "print 1; raise 'zerg_stderr'"],
55
+ STDOUT => @out_file, STDERR => STDOUT
56
+ Process.waitpid pid
57
+ assert_operator ["1-e:1: zerg_stderr (RuntimeError)\n",
58
+ "-e:1: zerg_stderr (RuntimeError)\n1"],
59
+ :include?, File.read(@out_file)
60
+ end
61
+
62
+ def test_redirect_share
63
+ pid = Zerg::Support::Process.spawn 'ruby',
64
+ ['-e', "print 1; raise 'zerg_stderr'"],
65
+ STDOUT => @out_file, STDERR => @out_file
66
+ Process.waitpid pid
67
+ assert_operator ["1-e:1: zerg_stderr (RuntimeError)\n",
68
+ "-e:1: zerg_stderr (RuntimeError)\n1"],
69
+ :include?, File.read(@out_file)
70
+ end
51
71
 
52
72
  def test_async
53
73
  t0 = Time.now
54
74
  pid = Zerg::Support::Process.spawn 'ruby', ['-e', 'sleep 0.5']
55
75
  t1 = Time.now
56
- Process.wait pid
76
+ Process.waitpid pid
57
77
  t2 = Time.now
58
78
 
59
- assert t1 - t0 < 0.2, 'Spawning is not asynchronous'
60
- assert t2 - t0 > 0.5, 'The spawned program did not sleep for 1 second'
79
+ assert_operator t1 - t0, :<, 0.2, 'Spawning is not asynchronous'
80
+ assert_operator t2 - t0, :>, 0.5,
81
+ 'The spawned program did not sleep for 1 second'
61
82
  end
62
83
 
63
84
  def test_set_environment
64
- pid = Zerg::Support::Process.spawn 'ruby', ['-e', 'print ENV["XA"]'],
85
+ pid = Zerg::Support::Process.spawn 'ruby', ['-e', 'print ENV[\'XA\']'],
65
86
  STDOUT => @out_file, :env => {'XA' => "1234\n"}
66
- Process.wait pid
87
+ Process.waitpid pid
67
88
  assert_equal "1234\n", File.read(@out_file)
68
89
 
69
- pid = Zerg::Support::Process.spawn 'ruby', ['-e', 'print ENV["PATH"]'],
90
+ pid = Zerg::Support::Process.spawn 'ruby', ['-e', 'print ENV[\'PATH\']'],
70
91
  STDOUT => @in_file, :env => {'XA' => "1234\n"}, :unsetenv_others => true
71
- Process.wait pid
92
+ Process.waitpid pid
72
93
  # clearing the environment will reset PATH, so ruby might not run at all
73
94
  output = File.read(@in_file)
74
95
  assert output == 'nil' || output == '', 'The environment was not cleared'
@@ -88,14 +109,19 @@ class TestSpawn < Test::Unit::TestCase
88
109
 
89
110
  pid = Zerg::Support::Process.spawn 'ruby', ['-e', "print #{read_fd_code}"],
90
111
  STDOUT => @out_file, STDERR => STDOUT
91
- Process.wait pid
112
+ Process.waitpid pid
92
113
  in_file.close
93
114
 
94
115
  assert_equal "-e:1:", File.read(@out_file)[0, 5],
95
116
  'Spawn does not close file descriptors'
96
117
  end
97
-
118
+
98
119
  def test_rlimit_processing
120
+ if RUBY_PLATFORM =~ /win/ and RUBY_PLATFORM !~ /darwin/
121
+ Process.const_set :RLIMIT_CPU, 'rlimit_cpu'
122
+ Process.const_set :RLIMIT_RSS, 'rlimit_rss'
123
+ end
124
+
99
125
  flexmock(Process).should_receive(:setrlimit).
100
126
  with(Process::RLIMIT_CPU, 1, 5).once.and_return(nil)
101
127
  flexmock(Process).should_receive(:setrlimit).
@@ -118,7 +144,7 @@ class TestSpawn < Test::Unit::TestCase
118
144
  pid = Zerg::Support::Process.spawn 'ruby', ['-e', "sleep 0.5"],
119
145
  :pgroup => true
120
146
  pinfo = Zerg::Support::Process::process_info pid
121
- Process.wait pid
147
+ Process.waitpid pid
122
148
 
123
149
  assert pinfo[:state].index('s'), 'Failed to become session leader'
124
150
  end
@@ -128,10 +154,10 @@ class TestSpawn < Test::Unit::TestCase
128
154
  pid = Zerg::Support::Process.spawn 'ruby',
129
155
  ['-e', "i = 0; t0 = Time.now; i += 1 while Time.now - t0 < 3.0"],
130
156
  :rlimit_cpu => 1
131
- Process.wait pid
157
+ Process.waitpid pid
132
158
  t1 = Time.now
133
159
 
134
- assert t1 - t0 >= 1.0, 'Spawning failed'
135
- assert t1 - t0 <= 2.0, 'Failed to apply rlimit_cpu'
160
+ assert_operator t1 - t0, :>=, 0.95, 'Spawning failed'
161
+ assert_operator t1 - t0, :<=, 2.0, 'Failed to apply rlimit_cpu'
136
162
  end
137
163
  end
data/zerg_support.gemspec CHANGED
@@ -1,33 +1,41 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = %q{zerg_support}
3
- s.version = "0.0.5"
5
+ s.version = "0.0.8"
4
6
 
5
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
6
8
  s.authors = ["Victor Costan"]
7
- s.date = %q{2008-11-19}
8
- s.description = %q{Support libraries used by the Zerg system.}
9
+ s.date = %q{2009-02-24}
10
+ s.description = %q{Support libraries used by Zergling.Net deployment code.}
9
11
  s.email = %q{victor@zergling.net}
10
- s.extra_rdoc_files = ["CHANGELOG", "lib/zerg_support/gems.rb", "lib/zerg_support/process.rb", "lib/zerg_support/spawn.rb", "lib/zerg_support.rb", "LICENSE", "README"]
11
- s.files = ["CHANGELOG", "lib/zerg_support/gems.rb", "lib/zerg_support/process.rb", "lib/zerg_support/spawn.rb", "lib/zerg_support.rb", "LICENSE", "Manifest", "Rakefile", "README", "test/test_gems.rb", "test/test_process.rb", "test/test_spawn.rb", "zerg_support.gemspec"]
12
+ s.extra_rdoc_files = ["CHANGELOG", "lib/zerg_support/event_machine/connection_mocks.rb", "lib/zerg_support/event_machine/frame_protocol.rb", "lib/zerg_support/event_machine/object_protocol.rb", "lib/zerg_support/gems.rb", "lib/zerg_support/open_ssh.rb", "lib/zerg_support/process.rb", "lib/zerg_support/spawn.rb", "lib/zerg_support.rb", "LICENSE", "README"]
13
+ s.files = ["CHANGELOG", "lib/zerg_support/event_machine/connection_mocks.rb", "lib/zerg_support/event_machine/frame_protocol.rb", "lib/zerg_support/event_machine/object_protocol.rb", "lib/zerg_support/gems.rb", "lib/zerg_support/open_ssh.rb", "lib/zerg_support/process.rb", "lib/zerg_support/spawn.rb", "lib/zerg_support.rb", "LICENSE", "Manifest", "Rakefile", "README", "RUBYFORGE", "test/fork_tree.rb", "test/test_connection_mocks.rb", "test/test_frame_protocol.rb", "test/test_gems.rb", "test/test_object_protocol.rb", "test/test_open_ssh.rb", "test/test_process.rb", "test/test_spawn.rb", "zerg_support.gemspec"]
12
14
  s.has_rdoc = true
13
15
  s.homepage = %q{http://www.zergling.net}
14
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Zerg_support", "--main", "README"]
15
17
  s.require_paths = ["lib"]
16
- s.rubyforge_project = %q{rails-pwnage}
17
- s.rubygems_version = %q{1.2.0}
18
- s.summary = %q{Support libraries used by the Zerg system.}
19
- s.test_files = ["test/test_gems.rb", "test/test_process.rb", "test/test_spawn.rb"]
18
+ s.rubyforge_project = %q{zerglings}
19
+ s.rubygems_version = %q{1.3.1}
20
+ s.summary = %q{Support libraries used by Zergling.Net deployment code.}
21
+ s.test_files = ["test/test_connection_mocks.rb", "test/test_frame_protocol.rb", "test/test_gems.rb", "test/test_object_protocol.rb", "test/test_open_ssh.rb", "test/test_process.rb", "test/test_spawn.rb"]
20
22
 
21
23
  if s.respond_to? :specification_version then
22
24
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
25
  s.specification_version = 2
24
26
 
25
- if current_version >= 3 then
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_development_dependency(%q<echoe>, [">= 3.0.2"])
29
+ s.add_development_dependency(%q<event_machine>, [">= 0.12.2"])
26
30
  s.add_development_dependency(%q<flexmock>, [">= 0.8.3"])
27
31
  else
32
+ s.add_dependency(%q<echoe>, [">= 3.0.2"])
33
+ s.add_dependency(%q<event_machine>, [">= 0.12.2"])
28
34
  s.add_dependency(%q<flexmock>, [">= 0.8.3"])
29
35
  end
30
36
  else
37
+ s.add_dependency(%q<echoe>, [">= 3.0.2"])
38
+ s.add_dependency(%q<event_machine>, [">= 0.12.2"])
31
39
  s.add_dependency(%q<flexmock>, [">= 0.8.3"])
32
40
  end
33
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zerg_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Costan
@@ -9,9 +9,29 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-19 00:00:00 -05:00
12
+ date: 2009-02-24 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: echoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 3.0.2
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: event_machine
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.12.2
34
+ version:
15
35
  - !ruby/object:Gem::Dependency
16
36
  name: flexmock
17
37
  type: :development
@@ -22,7 +42,7 @@ dependencies:
22
42
  - !ruby/object:Gem::Version
23
43
  version: 0.8.3
24
44
  version:
25
- description: Support libraries used by the Zerg system.
45
+ description: Support libraries used by Zergling.Net deployment code.
26
46
  email: victor@zergling.net
27
47
  executables: []
28
48
 
@@ -30,7 +50,11 @@ extensions: []
30
50
 
31
51
  extra_rdoc_files:
32
52
  - CHANGELOG
53
+ - lib/zerg_support/event_machine/connection_mocks.rb
54
+ - lib/zerg_support/event_machine/frame_protocol.rb
55
+ - lib/zerg_support/event_machine/object_protocol.rb
33
56
  - lib/zerg_support/gems.rb
57
+ - lib/zerg_support/open_ssh.rb
34
58
  - lib/zerg_support/process.rb
35
59
  - lib/zerg_support/spawn.rb
36
60
  - lib/zerg_support.rb
@@ -38,7 +62,11 @@ extra_rdoc_files:
38
62
  - README
39
63
  files:
40
64
  - CHANGELOG
65
+ - lib/zerg_support/event_machine/connection_mocks.rb
66
+ - lib/zerg_support/event_machine/frame_protocol.rb
67
+ - lib/zerg_support/event_machine/object_protocol.rb
41
68
  - lib/zerg_support/gems.rb
69
+ - lib/zerg_support/open_ssh.rb
42
70
  - lib/zerg_support/process.rb
43
71
  - lib/zerg_support/spawn.rb
44
72
  - lib/zerg_support.rb
@@ -46,7 +74,13 @@ files:
46
74
  - Manifest
47
75
  - Rakefile
48
76
  - README
77
+ - RUBYFORGE
78
+ - test/fork_tree.rb
79
+ - test/test_connection_mocks.rb
80
+ - test/test_frame_protocol.rb
49
81
  - test/test_gems.rb
82
+ - test/test_object_protocol.rb
83
+ - test/test_open_ssh.rb
50
84
  - test/test_process.rb
51
85
  - test/test_spawn.rb
52
86
  - zerg_support.gemspec
@@ -76,12 +110,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
110
  version:
77
111
  requirements: []
78
112
 
79
- rubyforge_project: rails-pwnage
80
- rubygems_version: 1.2.0
113
+ rubyforge_project: zerglings
114
+ rubygems_version: 1.3.1
81
115
  signing_key:
82
116
  specification_version: 2
83
- summary: Support libraries used by the Zerg system.
117
+ summary: Support libraries used by Zergling.Net deployment code.
84
118
  test_files:
119
+ - test/test_connection_mocks.rb
120
+ - test/test_frame_protocol.rb
85
121
  - test/test_gems.rb
122
+ - test/test_object_protocol.rb
123
+ - test/test_open_ssh.rb
86
124
  - test/test_process.rb
87
125
  - test/test_spawn.rb