zerg_support 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.0.3. Preliminary implementation of process spawning.
2
+
1
3
  v0.0.2. Process management.
2
4
 
3
5
  v0.0.1. Initial release. Support code for zerg* gem installation.
data/lib/zerg_support.rb CHANGED
@@ -8,3 +8,4 @@ end
8
8
 
9
9
  require 'zerg_support/gems.rb'
10
10
  require 'zerg_support/process.rb'
11
+ require 'zerg_support/spawn.rb'
@@ -1,8 +1,6 @@
1
- # process management
2
- # extends Base with process management features
3
-
4
1
  require 'time'
5
2
 
3
+ # process management
6
4
  module Zerg::Support::Process
7
5
  @@no_multiple_pids = false
8
6
 
@@ -0,0 +1,41 @@
1
+ require 'digest/sha1'
2
+ require 'test/unit'
3
+
4
+ require 'zerg_support'
5
+
6
+ class TestSpawn < Test::Unit::TestCase
7
+ def temp_file
8
+ now_cookie = "zerg_test_#{Time.now.to_f}"
9
+ File.open(now_cookie, 'w') {}
10
+ return now_cookie
11
+ end
12
+
13
+ def setup
14
+ @in_file = temp_file
15
+ @out_file = temp_file
16
+ end
17
+
18
+ def teardown
19
+ File.delete @in_file rescue nil
20
+ File.delete @out_file rescue nil
21
+ end
22
+
23
+ def test_stdout_redirect
24
+ pid = Zerg::Support::Process.spawn 'ruby', ['-e', 'print "1234\n"'],
25
+ STDOUT => @out_file
26
+ Process.wait pid
27
+
28
+ assert_equal "1234\n", File.read(@out_file)
29
+ end
30
+
31
+ def test_async
32
+ t0 = Time.now
33
+ pid = Zerg::Support::Process.spawn 'ruby', ['-e', 'sleep 0.5']
34
+ t1 = Time.now
35
+ Process.wait pid
36
+ t2 = Time.now
37
+
38
+ assert t1 - t0 < 0.2, 'Spawning is not asynchronous'
39
+ assert t2 - t0 > 0.5, 'The spawned program did not sleep for 1 second'
40
+ end
41
+ end
data/zerg_support.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{zerg_support}
3
- s.version = "0.0.2"
3
+ s.version = "0.0.3"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Victor Costan"]
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.description = %q{Support libraries used by the Zerg system.}
9
9
  s.email = %q{victor@zergling.net}
10
10
  s.extra_rdoc_files = ["CHANGELOG", "lib/zerg_support/gems.rb", "lib/zerg_support/process.rb", "lib/zerg_support.rb", "LICENSE", "README"]
11
- s.files = ["CHANGELOG", "lib/zerg_support/gems.rb", "lib/zerg_support/process.rb", "lib/zerg_support.rb", "LICENSE", "Manifest", "Rakefile", "README", "test/test_gems.rb", "test/test_process.rb", "zerg_support.gemspec"]
11
+ s.files = ["CHANGELOG", "lib/zerg_support/gems.rb", "lib/zerg_support/process.rb", "lib/zerg_support.rb", "LICENSE", "Manifest", "Rakefile", "README", "test/test_gems.rb", "test/test_process.rb", "zerg_support.gemspec", "test/test_spawn.rb"]
12
12
  s.has_rdoc = true
13
13
  s.homepage = %q{http://www.zergling.net}
14
14
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Zerg_support", "--main", "README"]
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.rubyforge_project = %q{rails-pwnage}
17
17
  s.rubygems_version = %q{1.2.0}
18
18
  s.summary = %q{Support libraries used by the Zerg system.}
19
- s.test_files = ["test/test_gems.rb", "test/test_process.rb"]
19
+ s.test_files = ["test/test_gems.rb", "test/test_process.rb", "test/test_spawn.rb"]
20
20
 
21
21
  if s.respond_to? :specification_version then
22
22
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Costan
@@ -81,3 +81,4 @@ summary: Support libraries used by the Zerg system.
81
81
  test_files:
82
82
  - test/test_gems.rb
83
83
  - test/test_process.rb
84
+ - test/test_spawn.rb