diff options
author | Ian Chard <ian@mysociety.org> | 2014-01-14 10:12:29 +0000 |
---|---|---|
committer | Ian Chard <ian@mysociety.org> | 2014-01-14 10:12:29 +0000 |
commit | 96ec5176baace46dd0c5cc6b3e9e080d52297674 (patch) | |
tree | 5ab37769a70d1eb7a56f7d33cbbb7d26df96f38e /spec/lib/external_command.rb | |
parent | 3f33ccf5cf9dc1c9735cb4830198ccf1e6242e3b (diff) |
Tests for abnormal exit detection
Diffstat (limited to 'spec/lib/external_command.rb')
-rw-r--r-- | spec/lib/external_command.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/lib/external_command.rb b/spec/lib/external_command.rb new file mode 100644 index 000000000..5ce1102b8 --- /dev/null +++ b/spec/lib/external_command.rb @@ -0,0 +1,23 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +require 'alaveteli_external_command' + +script_dir = File.join(File.dirname(__FILE__), 'external_command_scripts') +segfault_script = File.join(script_dir, 'segfault.sh') +error_script = File.join(script_dir, 'error.sh') + +describe "when running external commands" do + + it "should detect a non-zero exit status" do + $stderr.should_receive(:puts).with(/Error from/) + t = AlaveteliExternalCommand.run(error_script) + assert_nil t + end + + it "should detect when an external command crashes" do + $stderr.should_receive(:puts).with(/exited abnormally/) + t = AlaveteliExternalCommand.run(segfault_script) + assert_nil t + end + +end |