Skip to content

Commit

Permalink
Merge branch 'integration' of github.com:javan/whenever into integration
Browse files Browse the repository at this point in the history
  • Loading branch information
javan committed Apr 26, 2010
2 parents 19c9bbd + 1069cb7 commit bfbc62e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
12 changes: 9 additions & 3 deletions lib/whenever/outputs/cron/output_redirection.rb
Expand Up @@ -32,11 +32,17 @@ def stderr
def redirect_from_hash
case
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
">> #{stdout} 2> #{stderr}"
">> #{stdout} 2>> #{stderr}"
when stderr == '/dev/null'
"2> /dev/null"
when stderr
"2> #{stderr}"
"2>> #{stderr}"
when stdout == '/dev/null'
"> /dev/null"
when stdout
">> #{stdout}"
else
Expand Down
20 changes: 10 additions & 10 deletions test/output_redirection_test.rb
Expand Up @@ -46,7 +46,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
end

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

Expand Down Expand Up @@ -80,7 +80,7 @@ class OutputRedirectionTest < Test::Unit::TestCase

should "output the command with the overridden redirection syntax appended" do
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

Expand Down Expand Up @@ -130,7 +130,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
end

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

Expand All @@ -145,8 +145,8 @@ class OutputRedirectionTest < Test::Unit::TestCase
file
end

should "output the command without the standard errror syntax appended" do
assert_match /^.+ .+ .+ .+ blahblah 2> dev_null$/, @output
should "output the command without the standard error syntax appended" do
assert_match /^.+ .+ .+ .+ blahblah 2>> dev_null$/, @output
end
end

Expand Down Expand Up @@ -177,7 +177,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
end

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

Expand Down Expand Up @@ -207,7 +207,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
end

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

Expand Down Expand Up @@ -237,7 +237,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
end

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

Expand Down Expand Up @@ -267,7 +267,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
end

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

Expand All @@ -286,4 +286,4 @@ class OutputRedirectionTest < Test::Unit::TestCase
assert_match /^.+ .+ .+ .+ blahblah >> cron.log 2>&1$/, @output
end
end
end
end

0 comments on commit bfbc62e

Please sign in to comment.