mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Add an better error when a task is run and no servers match the required conditions
git-svn-id: http://svn.rubyonrails.org/rails/tools/switchtower@3396 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
a324f78020
commit
d04f90dfb2
3 changed files with 18 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
|||
*0.11.0* *SVN*
|
||||
|
||||
* Add an better error when a task is run and no servers match the required conditions
|
||||
|
||||
* Add default spinner and cold_deploy tasks, and spinner_user variable
|
||||
|
||||
* Changed restart_via variable to (boolean) use_sudo
|
||||
|
|
|
@ -364,8 +364,14 @@ module SwitchTower
|
|||
end
|
||||
|
||||
def execute_on_servers(options)
|
||||
servers = tasks[task_call_frames.last.name].servers(configuration)
|
||||
servers = servers.first if options[:once]
|
||||
task = tasks[task_call_frames.last.name]
|
||||
servers = task.servers(configuration)
|
||||
|
||||
if servers.empty?
|
||||
raise "The #{task.name} task is only run for servers matching #{task.options.inspect}, but no servers matched"
|
||||
end
|
||||
|
||||
servers = [servers.first] if options[:once]
|
||||
logger.trace "servers: #{servers.inspect}"
|
||||
|
||||
if !pretend
|
||||
|
|
|
@ -267,4 +267,12 @@ class ActorTest < Test::Unit::TestCase
|
|||
config.set :HELLO, "test"
|
||||
assert_equal "test", config.actor.instance_eval("HELLO")
|
||||
end
|
||||
|
||||
def test_connect_when_no_matching_servers
|
||||
@actor.define_task :foo, :roles => :db, :only => { :fnoofy => true } do
|
||||
run "do this"
|
||||
end
|
||||
|
||||
assert_raises(RuntimeError) { @actor.foo }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue