From c2e597a7362fd0b497da7c622717406bb70cd360 Mon Sep 17 00:00:00 2001 From: Jay Hayes Date: Sun, 26 Apr 2015 22:21:54 -0500 Subject: 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`. * :warning: 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. --- railties/test/application/rake/dbs_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'railties') diff --git a/railties/test/application/rake/dbs_test.rb b/railties/test/application/rake/dbs_test.rb index bd885b520e..f94d08673a 100644 --- a/railties/test/application/rake/dbs_test.rb +++ b/railties/test/application/rake/dbs_test.rb @@ -91,6 +91,16 @@ module ApplicationTests 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; -- cgit v1.2.3