From 26a20e2cb646a0954b72ee13b8e8d105d6db5433 Mon Sep 17 00:00:00 2001 From: David Kellum Date: Wed, 18 Oct 2017 09:46:19 -0700 Subject: [PATCH] SignalException test \w more docs, flush for ruby 1.8 --- spec/commands/exec_spec.rb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index 98456792bf7..f17c2a915ce 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -538,9 +538,23 @@ def bin_path(a,b,c) end end - context "the executable exits by signal" do - let(:executable) { super() << "\nraise SignalException, 'SIGTERM'\n" } - let(:exit_code) { 128 + 15 } + context "the executable exits by SignalException" do + let(:executable) do + ex = super() + ex << "\n" + if LessThanProc.with(RUBY_VERSION).call( "1.9" ) + # Ruby < 1.9 needs a flush for a exit by signal, later + # rubies do not + ex << "STDOUT.flush\n" + end + ex << "raise SignalException, 'SIGTERM'\n" + ex + end + let(:exit_code) do + # signal mask 128 + plus signal 15 -> TERM + # this is specified by C99 + 128 + 15 + end it_behaves_like "it runs" end