Skip to content

Commit

Permalink
Log test output on SIGINT and SIGTERM
Browse files Browse the repository at this point in the history
  • Loading branch information
tiwilliam committed Jun 25, 2020
1 parent ec6e61c commit 696e308
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,19 @@ def load_fixture(filename)
File.read(File.join(FIXTURE_PATH, filename))
end

def setup_signal_watcher
Signal.trap("INT") { self.on_term }
Signal.trap("TERM") { self.on_term }
end

##############
# Test Hooks #
##############

def before_all
@log_capturer = LogCapturer.new
initialize_db_connections
setup_signal_watcher
end

def before_setup
Expand Down Expand Up @@ -101,6 +107,11 @@ def after_teardown
@log_capturer.reset
end

def on_term
@log_capturer.print_output
exit
end

def after_all
teardown_connections
end
Expand Down

0 comments on commit 696e308

Please sign in to comment.