Permalink
Browse files

all tests passing and no extraneous output!

  • Loading branch information...
1 parent f0c22dc commit 68a07c1f9b7ee371bd12a20ddfbe874a67d13918 @mojombo mojombo committed Jan 28, 2008
Showing with 16 additions and 98 deletions.
  1. +0 −10 lib/god/process.rb
  2. +11 −0 test/test_driver.rb
  3. +5 −0 test/test_god.rb
  4. +0 −16 test/test_metric.rb
  5. +0 −12 test/test_task.rb
  6. +0 −60 test/test_timer.rb
View
@@ -181,8 +181,6 @@ def call_action(action)
::Process.kill('KILL', pid) rescue nil
end
end
-
- print "a - #{System::Process.new(::Process.pid).memory}\n"; sleep 1
if command.kind_of?(String)
pid = nil
@@ -199,20 +197,14 @@ def call_action(action)
puts pid.to_s # send pid back to forker
end
- print "b - #{System::Process.new(::Process.pid).memory}\n"; sleep 1
-
::Process.waitpid(opid, 0)
w.close
pid = r.gets.chomp
-
- print "c - #{System::Process.new(::Process.pid).memory}\n"; sleep 1
ensure
# make sure the file descriptors get closed no matter what
r.close rescue nil
w.close rescue nil
end
-
- print "d - #{System::Process.new(::Process.pid).memory}\n"; sleep 1
else
# single fork self-daemonizing processes
# we want to wait for them to finish
@@ -227,8 +219,6 @@ def call_action(action)
ensure_stop if action == :stop
end
- print "e - #{System::Process.new(::Process.pid).memory}\n"
-
if @tracking_pid or (@pid_file.nil? and WRITES_PID.include?(action))
File.open(default_pid_file, 'w') do |f|
f.write pid
View
@@ -0,0 +1,11 @@
+require File.dirname(__FILE__) + '/helper'
+
+class TestDriver < Test::Unit::TestCase
+ def setup
+
+ end
+
+ def test_
+
+ end
+end
View
@@ -11,6 +11,11 @@ def setup
def teardown
God.main && God.main.kill
+ if God.watches
+ God.watches.each do |k, w|
+ w.driver.thread.kill
+ end
+ end
end
# applog
View
@@ -69,20 +69,4 @@ def test_condition_should_abort_on_no_such_condition
@metric.condition(:invalid) { }
end
end
-
- # enable
-
- def test_enable_should_attach_conditions
- @metric.condition(:fake_poll_condition)
- Hub.expects(:attach).with(@metric.conditions.first, @metric)
- @metric.enable
- end
-
- # disable
-
- def test_disable_should_detach_conditions
- @metric.condition(:fake_poll_condition)
- Hub.expects(:detach).with(@metric.conditions.first)
- @metric.disable
- end
end
View
@@ -2,19 +2,7 @@
class TestTask < Test::Unit::TestCase
def setup
- God::Socket.stubs(:new).returns(true)
God.internal_init
- God.reset
-
- God.watch do |w|
- w.name = 'foo'
- w.start = 'bar'
- w.interval = 10
- end
-
- @watch = God.watches['foo']
-
-
@task = Task.new
@task.name = 'foo'
@task.valid_states = [:foo, :bar]
View
@@ -1,60 +0,0 @@
-require File.dirname(__FILE__) + '/helper'
-
-class TestTimer < Test::Unit::TestCase
- def setup
- Timer.reset
- @t = Timer.get
- end
-
- def test_new_timer_should_have_no_events
- assert_equal 0, @t.events.size
- end
-
- def test_schedule_should_queue_event
- w = Watch.new
- @t.schedule(stub(:interval => 20, :watch => w))
- sleep(0.3)
- assert_equal 1, @t.events.size
- end
-
- def test_timer_should_remove_expired_events
- @t.schedule(stub(:interval => -1, :watch => Watch.new))
- sleep(0.3)
- assert_equal 0, @t.events.size
- end
-
- def test_timer_should_remove_only_expired_events
- w = Watch.new
- @t.schedule(stub(:interval => -1, :watch => w))
- @t.schedule(stub(:interval => 1000, :watch => w))
- sleep(0.3)
- assert_equal 1, @t.events.size
- end
-
- def test_timer_should_sort_timer_events
- w = Watch.new
- @t.schedule(stub(:interval => 1000, :watch => w))
- @t.schedule(stub(:interval => 800, :watch => w))
- @t.schedule(stub(:interval => 900, :watch => w))
- @t.schedule(stub(:interval => 100, :watch => w))
- sleep(0.3)
- assert_equal [100, 800, 900, 1000], @t.events.map { |x| x.condition.interval }
- end
-
- def test_time_should_recover_from_exceptions
- w = Watch.new
- @t.expects(:trigger).raises(Exception.new)
- no_stdout do
- @t.schedule(stub(:interval => -1, :watch => w))
- sleep(0.3)
- @t.schedule(stub(:interval => 0, :watch => w))
- end
- end
-
- # join
-
- def test_join_should_join
- Thread.any_instance.expects(:join)
- @t.join
- end
-end

0 comments on commit 68a07c1

Please sign in to comment.