summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-12-06 09:26:21 -0800
committerdanielsdeleo <dan@opscode.com>2013-12-06 12:43:24 -0800
commitc195a3f69d9182e52b57eed5eb6ffea24c974ef8 (patch)
tree8e2f539b8f9dab5336c0fcb6b29b1c5dad4b32b1 /spec
parent28f2d211fae20abf30f7c3dc7e8ee26a933743b9 (diff)
downloadmixlib-shellout-c195a3f69d9182e52b57eed5eb6ffea24c974ef8.tar.gz
Run timeout tests without a subshell
/bin/sh on Ubuntu is dash, which does not support bash's behavior of using exec to run a command (instead of fork) when possible. This means that, when given a single string command, instead of an array of command plus arguments, the process created by fork/exec is dash, and the ruby program is a child process of dash. When shellout signals the child to exit after a timeout, it will signal dash instead of the ruby program. To avoid this issue, the command needs to be given as an Array to avoid creating a subshell.
Diffstat (limited to 'spec')
-rw-r--r--spec/mixlib/shellout_spec.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb
index 71ecfef..5e92a54 100644
--- a/spec/mixlib/shellout_spec.rb
+++ b/spec/mixlib/shellout_spec.rb
@@ -825,9 +825,16 @@ describe Mixlib::ShellOut do
end
end
- context 'with subprocess that takes longer than timeout' do
+ context 'with subprocess that takes longer than timeout', :focus do
+ def ruby_wo_shell(code)
+ parts = %w[ruby]
+ parts << "--disable-gems" if ruby_19?
+ parts << "-e"
+ parts << code
+ end
+
let(:cmd) do
- ruby_eval.call(<<-CODE)
+ ruby_wo_shell(<<-CODE)
STDOUT.sync = true
trap(:TERM) { puts "got term"; exit!(123) }
sleep 10
@@ -849,7 +856,7 @@ describe Mixlib::ShellOut do
context "and the child is unresponsive" do
let(:cmd) do
- ruby_eval.call(<<-CODE)
+ ruby_wo_shell(<<-CODE)
STDOUT.sync = true
trap(:TERM) { puts "nanana cant hear you" }
sleep 10