test/runner_test.rb in dante-0.1.4 vs test/runner_test.rb in dante-0.1.5
- old
+ new
@@ -31,32 +31,34 @@
it "can properly handles aborts and starts / stops on INT" do
refute_equal 0, @pid = `cat /tmp/dante.pid`.to_i
Process.kill "INT", @pid
sleep(1) # Wait to complete
@output = File.read(@process.tmp_path)
+
assert_match /Started on 8080!!/, @output
assert_match /Interrupt!!/, @output
assert_match /Closing!!/, @output
end
it "can properly handles aborts and starts / stops on TERM" do
refute_equal 0, @pid = `cat /tmp/dante.pid`.to_i
Process.kill "TERM", @pid
sleep(1) # Wait to complete
@output = File.read(@process.tmp_path)
+
assert_match /Started on 8080!!/, @output
- assert_match /Interrupt!!/, @output
assert_match /Closing!!/, @output
+ refute_match /Interrupt!!/, @output
end
end # daemonize
describe "with daemonize flag and log file specified" do
before do
@logfile = '/tmp/dante-logging.log'
FileUtils.rm(@logfile) if File.exist?(@logfile)
@process = TestingProcess.new('c')
- @run_options = { :daemonize => true, :pid_path => "/tmp/dante.pid", :port => 8081, :log_path => @logfile, :debug => false }
+ @run_options = { :daemonize => true, :pid_path => "/tmp/dante.pid", :port => 8081, :log_path => @logfile }
@runner = Dante::Runner.new('test-process-2', @run_options) { |opts|
@process.run_c!(opts[:port]) }
@runner.execute
sleep(1)
end
@@ -64,16 +66,42 @@
it "can properly handles log to file and aborts on INT" do
refute_equal 0, @pid = `cat /tmp/dante.pid`.to_i
Process.kill "INT", @pid
sleep(1) # Wait to complete
@output = File.read(@logfile)
+
assert_match /Started on 8081!!/, @output
assert_match /Interrupt!!/, @output
assert_match /Closing!!/, @output
end
end
+ describe "with daemonize flag and logging flag enabled, and debug flag disabled" do
+ before do
+ @logfile = '/tmp/dante-logging.log'
+ FileUtils.rm(@logfile) if File.exist?(@logfile)
+ @process = TestingProcess.new('c')
+ @run_options = { :daemonize => true, :pid_path => "/tmp/dante.pid", :port => 8081, :log_path => @logfile, :debug => false }
+ @runner = Dante::Runner.new('test-process-2', @run_options) { |opts|
+ @process.run_c!(opts[:port]) }
+ @runner.execute
+ sleep(1)
+ end
+
+ it "can properly handles log to file and aborts on INT" do
+ refute_equal 0, @pid = `cat /tmp/dante.pid`.to_i
+ Process.kill "INT", @pid
+ sleep(1) # Wait to complete
+ @output = File.read(@logfile)
+
+ assert_match /Started on 8081!!/, @output
+ assert_match /Interrupt received/, @output
+ assert_match /Closing!!/, @output
+ end
+ end
+
+
describe "with execute accepting block" do
before do
@process = TestingProcess.new('b')
@run_options = { :daemonize => true, :pid_path => "/tmp/dante.pid", :port => 8080, :log_path => false }
@runner = Dante::Runner.new('test-process-2', @run_options)
@@ -84,9 +112,10 @@
it "can properly handles aborts and starts / stops on INT" do
refute_equal 0, @pid = `cat /tmp/dante.pid`.to_i
Process.kill "INT", @pid
sleep(1) # Wait to complete
@output = File.read(@process.tmp_path)
+
assert_match /Started on 8080!!/, @output
assert_match /Interrupt!!/, @output
assert_match /Closing!!/, @output
end
end # execute with block
\ No newline at end of file