提交 c2e597a7 编写于 作者: J Jay Hayes

Exit with non-zero status when db:drop fails

* If the drop task fails for a reason other than the database not
  existing, processing should end. This is indicated by a non-zero
  exit status.
* Since the backtrace is already printed to screen, we forgo
  printing it again by using an explicit call to `exit`.
*  This modifies the behavior of the db:create task slightly in
  that the stack trace is no longer printed by default. If the `--trace`
  option is used, it will print the trace _after_ the error message.
上级 2893e6c0
......@@ -116,8 +116,9 @@ def drop(*arguments)
rescue ActiveRecord::NoDatabaseError
$stderr.puts "Database '#{configuration['database']}' does not exist"
rescue Exception => error
$stderr.puts error, *(error.backtrace)
$stderr.puts error
$stderr.puts "Couldn't drop #{configuration['database']}"
raise
end
def drop_all
......
......@@ -91,6 +91,16 @@ def with_bad_permissions
end
end
test 'db:drop failure because bad permissions' do
with_database_existing do
with_bad_permissions do
output = `bin/rake db:drop 2>&1`
assert_match /Couldn't drop/, output
assert_equal 1, $?.exitstatus
end
end
end
def db_migrate_and_status(expected_database)
Dir.chdir(app_path) do
`bin/rails generate model book title:string;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册