Add --cron option #43

Closed
wants to merge 5 commits into
from
View
@@ -12,3 +12,4 @@ r19.diff
temp_*
testdata
x
+.redcar
@@ -144,13 +144,13 @@ def standard_exception_handling
def display_error_message(ex)
$stderr.puts "#{name} aborted!"
$stderr.puts ex.message
- if options.trace
+ if options.trace or options.cron
$stderr.puts ex.backtrace.join("\n")
else
$stderr.puts rakefile_location(ex.backtrace)
end
$stderr.puts "Tasks: #{ex.chain}" if has_chain?(ex)
- $stderr.puts "(See full trace by running task with --trace)" unless options.trace
+ $stderr.puts "(See full trace by running task with --trace)" unless options.trace or options.cron
end
# Warn about deprecated usage.
@@ -388,6 +388,13 @@ def standard_rake_options
Rake.verbose(true)
}
],
+ ['--cron', '-c', "Like -s and -X, but full backtraces are printed on errors (useful for cronjobs)",
+ lambda { |value|
+ options.cron = true
+ options.silent = true
+ options.ignore_deprecate = true
+ }
+ ],
['--verbose', '-v', "Log message to standard output.",
lambda { |value| Rake.verbose(true) }
],
View
@@ -35,7 +35,7 @@ def ignore_deprecations
ensure
Rake.application.options.ignore_deprecate = false
end
-
+
end
# workarounds for 1.8
@@ -319,10 +319,10 @@ def test_bad_run
@app.intern(Rake::Task, "default").enhance { fail }
ARGV.clear
ARGV << '-f' << '-s' << '--rakelib=""'
- assert_raises(SystemExit) {
- _, err = capture_io { @app.run }
- assert_match(/see full trace/, err)
+ _, err = capture_io {
+ assert_raises(SystemExit) { @app.run }
}
+ assert_match(/See full trace/, err)
ensure
ARGV.clear
end
@@ -331,10 +331,24 @@ def test_bad_run_with_trace
@app.intern(Rake::Task, "default").enhance { fail }
ARGV.clear
ARGV << '-f' << '-s' << '-t'
- assert_raises(SystemExit) {
- _, err = capture_io { @app.run }
- refute_match(/see full trace/, err)
+ _, err = capture_io {
+ assert_raises(SystemExit) { @app.run }
+ }
+ refute_match(/See full trace/, err)
+ assert_match(/application.rb/, err)
+ ensure
+ ARGV.clear
+ end
+
+ def test_bad_run_with_cron
+ @app.intern(Rake::Task, "default").enhance { fail }
+ ARGV.clear
+ ARGV << '-f' << '-s' << '-c'
+ _, err = capture_io {
+ assert_raises(SystemExit) { @app.run }
}
+ refute_match(/See full trace/, err)
+ assert_match(/application.rb/, err)
ensure
ARGV.clear
end
@@ -234,6 +234,16 @@ def test_trace
end
end
+ def test_cron
+ in_environment do
+ flags('--cron', '-c') do |opts|
+ assert opts.cron
+ assert opts.silent
+ assert opts.ignore_deprecate
+ end
+ end
+ end
+
def test_trace_rules
in_environment do
flags('--rules') do |opts|