fix STDERR output redirection to file to append instead of overwrite.
This commit is contained in:
parent
cd92f1f4f1
commit
1069cb7c48
@ -32,11 +32,17 @@ module Whenever
|
|||||||
def redirect_from_hash
|
def redirect_from_hash
|
||||||
case
|
case
|
||||||
when stdout == '/dev/null' && stderr == '/dev/null'
|
when stdout == '/dev/null' && stderr == '/dev/null'
|
||||||
">> /dev/null 2>&1"
|
"> /dev/null 2>&1"
|
||||||
|
when stdout && stderr == '/dev/null'
|
||||||
|
">> #{stdout} 2> /dev/null"
|
||||||
when stdout && stderr
|
when stdout && stderr
|
||||||
">> #{stdout} 2> #{stderr}"
|
">> #{stdout} 2>> #{stderr}"
|
||||||
|
when stderr == '/dev/null'
|
||||||
|
"2> /dev/null"
|
||||||
when stderr
|
when stderr
|
||||||
"2> #{stderr}"
|
"2>> #{stderr}"
|
||||||
|
when stdout == '/dev/null'
|
||||||
|
"> /dev/null"
|
||||||
when stdout
|
when stdout
|
||||||
">> #{stdout}"
|
">> #{stdout}"
|
||||||
else
|
else
|
||||||
|
@ -46,7 +46,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "output the command without the log syntax appended" do
|
should "output the command without the log syntax appended" do
|
||||||
assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2> dev_err$/, @output
|
assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, @output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|||||||
|
|
||||||
should "output the command with the overridden redirection syntax appended" do
|
should "output the command with the overridden redirection syntax appended" do
|
||||||
assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
|
assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
|
||||||
assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2> dev_err$/, @output
|
assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, @output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "output the command without the redirection syntax appended" do
|
should "output the command without the redirection syntax appended" do
|
||||||
assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2> dev_err$/, @output
|
assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, @output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -145,8 +145,8 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|||||||
file
|
file
|
||||||
end
|
end
|
||||||
|
|
||||||
should "output the command without the standard errror syntax appended" do
|
should "output the command without the standard error syntax appended" do
|
||||||
assert_match /^.+ .+ .+ .+ blahblah 2> dev_null$/, @output
|
assert_match /^.+ .+ .+ .+ blahblah 2>> dev_null$/, @output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "output the command without the log syntax appended" do
|
should "output the command without the log syntax appended" do
|
||||||
assert_match /^.+ .+ .+ .+ blahblah 2> dev_err$/, @output
|
assert_match /^.+ .+ .+ .+ blahblah 2>> dev_err$/, @output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "output the command with stdout directed to /dev/null" do
|
should "output the command with stdout directed to /dev/null" do
|
||||||
assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null$/, @output
|
assert_match /^.+ .+ .+ .+ blahblah > \/dev\/null$/, @output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "output the command with stderr directed to /dev/null" do
|
should "output the command with stderr directed to /dev/null" do
|
||||||
assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null 2>&1$/, @output
|
assert_match /^.+ .+ .+ .+ blahblah > \/dev\/null 2>&1$/, @output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "output the command with stderr directed to /dev/null" do
|
should "output the command with stderr directed to /dev/null" do
|
||||||
assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null 2> my_error.log$/, @output
|
assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null 2>> my_error.log$/, @output
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user