Sha256: 5f01ceaaab94e3a9ca726ab76901213cfe3bdb20e1e61cfa6bd589591f589da7

Contents?: true

Size: 804 Bytes

Versions: 4

Compression:

Stored size: 804 Bytes

Contents

require 'test/unit'
require 'mocha/setup'
require 'fileutils'

class SignalTest < Test::Unit::TestCase
  CMD     = File.expand_path('../../bin/clockwork', __FILE__)
  SAMPLE  = File.expand_path('../samples/signal_test.rb', __FILE__)
  LOGFILE = File.expand_path('../tmp/signal_test.log', __FILE__)

  setup do
    FileUtils.mkdir_p(File.dirname(LOGFILE))
    @pid = spawn(CMD, SAMPLE)
    until File.exist?(LOGFILE)
      sleep 0.1
    end
  end

  teardown do
    FileUtils.rm_r(File.dirname(LOGFILE))
  end

  test 'should gracefully shutdown with SIGTERM' do
    Process.kill(:TERM, @pid)
    sleep 0.2
    assert_equal 'done', File.read(LOGFILE)
  end

  test 'should forcely shutdown with SIGINT' do
    Process.kill(:INT, @pid)
    sleep 0.2
    assert_equal 'start', File.read(LOGFILE)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
clockwork-2.0.4 test/signal_test.rb
clockwork-2.0.3 test/signal_test.rb
clockwork-2.0.2 test/signal_test.rb
clockwork-2.0.1 test/signal_test.rb