mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
Strip trailing whitespace from all files
(That is [spaceliteraltab] to type a tab on the CLI do Ctrl+v, tab) git ls-files | xargs sed -i '' -e 's/[ ]*$//' ]'
This commit is contained in:
parent
d8325fbb10
commit
4acea20beb
32 changed files with 89 additions and 89 deletions
2
Gemfile
2
Gemfile
|
@ -4,7 +4,7 @@ source "http://rubygems.org"
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
#
|
#
|
||||||
# Development Dependencies from the Gemfile
|
# Development Dependencies from the Gemfile
|
||||||
# are merged here.
|
# are merged here.
|
||||||
#
|
#
|
||||||
group :development do
|
group :development do
|
||||||
|
|
|
@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
||||||
]
|
]
|
||||||
|
|
||||||
s.specification_version = 3 if s.respond_to? :specification_version
|
s.specification_version = 3 if s.respond_to? :specification_version
|
||||||
|
|
||||||
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
||||||
s.add_runtime_dependency(%q<highline>, [">= 0"])
|
s.add_runtime_dependency(%q<highline>, [">= 0"])
|
||||||
s.add_runtime_dependency(%q<net-ssh>, [">= 2.0.14"])
|
s.add_runtime_dependency(%q<net-ssh>, [">= 2.0.14"])
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Capistrano
|
||||||
# Capistrano::CLI.parse(%W(-vvvv -f config/deploy update_code)).execute!
|
# Capistrano::CLI.parse(%W(-vvvv -f config/deploy update_code)).execute!
|
||||||
#
|
#
|
||||||
# Note that you can also embed cap directly by creating a new Configuration
|
# Note that you can also embed cap directly by creating a new Configuration
|
||||||
# instance and setting it up, The above snippet, redone using the
|
# instance and setting it up, The above snippet, redone using the
|
||||||
# Configuration class directly, would look like:
|
# Configuration class directly, would look like:
|
||||||
#
|
#
|
||||||
# require 'capistrano'
|
# require 'capistrano'
|
||||||
|
|
|
@ -55,10 +55,10 @@ module Capistrano
|
||||||
def load_recipes(config) #:nodoc:
|
def load_recipes(config) #:nodoc:
|
||||||
# load the standard recipe definition
|
# load the standard recipe definition
|
||||||
config.load "standard"
|
config.load "standard"
|
||||||
|
|
||||||
# load systemwide config/recipe definition
|
# load systemwide config/recipe definition
|
||||||
config.load(options[:sysconf]) if options[:sysconf] && File.file?(options[:sysconf])
|
config.load(options[:sysconf]) if options[:sysconf] && File.file?(options[:sysconf])
|
||||||
|
|
||||||
# load user config/recipe definition
|
# load user config/recipe definition
|
||||||
config.load(options[:dotfile]) if options[:dotfile] && File.file?(options[:dotfile])
|
config.load(options[:dotfile]) if options[:dotfile] && File.file?(options[:dotfile])
|
||||||
|
|
||||||
|
|
|
@ -111,14 +111,14 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
def output_columns #:nodoc:
|
def output_columns #:nodoc:
|
||||||
if ( @output_columns.nil? )
|
if ( @output_columns.nil? )
|
||||||
if ( self.class.ui.output_cols.nil? )
|
if ( self.class.ui.output_cols.nil? )
|
||||||
@output_columns = 80
|
@output_columns = 80
|
||||||
else
|
else
|
||||||
@output_columns = self.class.ui.output_cols
|
@output_columns = self.class.ui.output_cols
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@output_columns
|
@output_columns
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,8 +27,8 @@ module Capistrano
|
||||||
def task_call_frames
|
def task_call_frames
|
||||||
Thread.current[:task_call_frames] ||= []
|
Thread.current[:task_call_frames] ||= []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# The stack of tasks that have registered rollback handlers within the
|
# The stack of tasks that have registered rollback handlers within the
|
||||||
# current transaction. If this is nil, then there is no transaction
|
# current transaction. If this is nil, then there is no transaction
|
||||||
# that is currently active.
|
# that is currently active.
|
||||||
|
|
|
@ -141,9 +141,9 @@ module Capistrano
|
||||||
# look to see if this specific configuration instance has ever seen
|
# look to see if this specific configuration instance has ever seen
|
||||||
# these arguments to require before
|
# these arguments to require before
|
||||||
if @loaded_features.include?(args)
|
if @loaded_features.include?(args)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@loaded_features << args
|
@loaded_features << args
|
||||||
begin
|
begin
|
||||||
original_instance, self.class.instance = self.class.instance, self
|
original_instance, self.class.instance = self.class.instance, self
|
||||||
|
|
|
@ -68,7 +68,7 @@ module Capistrano
|
||||||
raise ArgumentError, "you must associate a server with at least one role" if roles.empty?
|
raise ArgumentError, "you must associate a server with at least one role" if roles.empty?
|
||||||
roles.each { |name| role(name, host, options) }
|
roles.each { |name| role(name, host, options) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def role_names_for_host(host)
|
def role_names_for_host(host)
|
||||||
roles.map {|role_name, role| role_name if role.include?(host) }.compact || []
|
roles.map {|role_name, role| role_name if role.include?(host) }.compact || []
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,8 +13,8 @@ module Capistrano
|
||||||
# The options hash may include a :hosts option (which should specify
|
# The options hash may include a :hosts option (which should specify
|
||||||
# an array of host names or ServerDefinition instances), a :roles
|
# an array of host names or ServerDefinition instances), a :roles
|
||||||
# option (specifying an array of roles), an :only option (specifying
|
# option (specifying an array of roles), an :only option (specifying
|
||||||
# a hash of key/value pairs that any matching server must match),
|
# a hash of key/value pairs that any matching server must match),
|
||||||
# an :exception option (like :only, but the inverse), and a
|
# an :exception option (like :only, but the inverse), and a
|
||||||
# :skip_hostfilter option to ignore the HOSTFILTER environment variable
|
# :skip_hostfilter option to ignore the HOSTFILTER environment variable
|
||||||
# described below.
|
# described below.
|
||||||
#
|
#
|
||||||
|
@ -27,7 +27,7 @@ module Capistrano
|
||||||
# will limit the result to hosts found in that (comma-separated) list.
|
# will limit the result to hosts found in that (comma-separated) list.
|
||||||
#
|
#
|
||||||
# If the HOSTROLEFILTER environment variable is set, it will limit the
|
# If the HOSTROLEFILTER environment variable is set, it will limit the
|
||||||
# result to hosts found in that (comma-separated) list of roles
|
# result to hosts found in that (comma-separated) list of roles
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
#
|
#
|
||||||
|
@ -44,9 +44,9 @@ module Capistrano
|
||||||
def find_servers(options={})
|
def find_servers(options={})
|
||||||
return [] if options.key?(:hosts) && (options[:hosts].nil? || [] == options[:hosts])
|
return [] if options.key?(:hosts) && (options[:hosts].nil? || [] == options[:hosts])
|
||||||
return [] if options.key?(:roles) && (options[:roles].nil? || [] == options[:roles])
|
return [] if options.key?(:roles) && (options[:roles].nil? || [] == options[:roles])
|
||||||
|
|
||||||
hosts = server_list_from(ENV['HOSTS'] || options[:hosts])
|
hosts = server_list_from(ENV['HOSTS'] || options[:hosts])
|
||||||
|
|
||||||
if hosts.any?
|
if hosts.any?
|
||||||
if options[:skip_hostfilter]
|
if options[:skip_hostfilter]
|
||||||
hosts.uniq
|
hosts.uniq
|
||||||
|
@ -59,7 +59,7 @@ module Capistrano
|
||||||
|
|
||||||
only = options[:only] || {}
|
only = options[:only] || {}
|
||||||
except = options[:except] || {}
|
except = options[:except] || {}
|
||||||
|
|
||||||
# If we don't have a def for a role it means its bogus, skip it so higher level can handle
|
# If we don't have a def for a role it means its bogus, skip it so higher level can handle
|
||||||
servers = roles.inject([]) { |list, role| list.concat(self.roles[role] || []) }
|
servers = roles.inject([]) { |list, role| list.concat(self.roles[role] || []) }
|
||||||
servers = servers.select { |server| only.all? { |key,value| server.options[key] == value } }
|
servers = servers.select { |server| only.all? { |key,value| server.options[key] == value } }
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
module Capistrano
|
module Capistrano
|
||||||
|
|
||||||
Error = Class.new(RuntimeError)
|
Error = Class.new(RuntimeError)
|
||||||
|
|
||||||
CaptureError = Class.new(Capistrano::Error)
|
CaptureError = Class.new(Capistrano::Error)
|
||||||
NoSuchTaskError = Class.new(Capistrano::Error)
|
NoSuchTaskError = Class.new(Capistrano::Error)
|
||||||
NoMatchingServersError = Class.new(Capistrano::Error)
|
NoMatchingServersError = Class.new(Capistrano::Error)
|
||||||
|
|
||||||
class RemoteError < Error
|
class RemoteError < Error
|
||||||
attr_accessor :hosts
|
attr_accessor :hosts
|
||||||
end
|
end
|
||||||
|
@ -13,7 +13,7 @@ module Capistrano
|
||||||
ConnectionError = Class.new(Capistrano::RemoteError)
|
ConnectionError = Class.new(Capistrano::RemoteError)
|
||||||
TransferError = Class.new(Capistrano::RemoteError)
|
TransferError = Class.new(Capistrano::RemoteError)
|
||||||
CommandError = Class.new(Capistrano::RemoteError)
|
CommandError = Class.new(Capistrano::RemoteError)
|
||||||
|
|
||||||
LocalArgumentError = Class.new(Capistrano::Error)
|
LocalArgumentError = Class.new(Capistrano::Error)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,7 +39,7 @@ Capistrano::Configuration.instance.load do
|
||||||
else
|
else
|
||||||
abort "No stage specified. Please specify one of: #{stages.join(', ')} (e.g. `cap #{stages.first} #{ARGV.last}')"
|
abort "No stage specified. Please specify one of: #{stages.join(', ')} (e.g. `cap #{stages.first} #{ARGV.last}')"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Stub out the staging config files."
|
desc "Stub out the staging config files."
|
||||||
|
|
|
@ -18,7 +18,7 @@ module Capistrano
|
||||||
yield self
|
yield self
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def remote
|
def remote
|
||||||
dep = RemoteDependency.new(configuration)
|
dep = RemoteDependency.new(configuration)
|
||||||
@dependencies << dep
|
@dependencies << dep
|
||||||
|
|
|
@ -58,31 +58,31 @@ module Capistrano
|
||||||
def match(command, expect, options={})
|
def match(command, expect, options={})
|
||||||
expect = Regexp.new(Regexp.escape(expect.to_s)) unless expect.is_a?(Regexp)
|
expect = Regexp.new(Regexp.escape(expect.to_s)) unless expect.is_a?(Regexp)
|
||||||
|
|
||||||
output_per_server = {}
|
output_per_server = {}
|
||||||
try("#{command} ", options) do |ch, stream, out|
|
try("#{command} ", options) do |ch, stream, out|
|
||||||
output_per_server[ch[:server]] ||= ''
|
output_per_server[ch[:server]] ||= ''
|
||||||
output_per_server[ch[:server]] += out
|
output_per_server[ch[:server]] += out
|
||||||
end
|
end
|
||||||
|
|
||||||
# It is possible for some of these commands to return a status != 0
|
# It is possible for some of these commands to return a status != 0
|
||||||
# (for example, rake --version exits with a 1). For this check we
|
# (for example, rake --version exits with a 1). For this check we
|
||||||
# just care if the output matches, so we reset the success flag.
|
# just care if the output matches, so we reset the success flag.
|
||||||
@success = true
|
@success = true
|
||||||
|
|
||||||
errored_hosts = []
|
errored_hosts = []
|
||||||
output_per_server.each_pair do |server, output|
|
output_per_server.each_pair do |server, output|
|
||||||
next if output =~ expect
|
next if output =~ expect
|
||||||
errored_hosts << server
|
errored_hosts << server
|
||||||
end
|
end
|
||||||
|
|
||||||
if errored_hosts.any?
|
if errored_hosts.any?
|
||||||
@hosts = errored_hosts.join(', ')
|
@hosts = errored_hosts.join(', ')
|
||||||
output = output_per_server[errored_hosts.first]
|
output = output_per_server[errored_hosts.first]
|
||||||
@message = "the output #{output.inspect} from #{command.inspect} did not match #{expect.inspect}"
|
@message = "the output #{output.inspect} from #{command.inspect} did not match #{expect.inspect}"
|
||||||
@success = false
|
@success = false
|
||||||
end
|
end
|
||||||
|
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
def or(message)
|
def or(message)
|
||||||
|
|
|
@ -14,9 +14,9 @@ module Capistrano
|
||||||
# * :repository - This should match the depot that code lives in. If your code
|
# * :repository - This should match the depot that code lives in. If your code
|
||||||
# exists in a subdirectory, you can append the path depot.
|
# exists in a subdirectory, you can append the path depot.
|
||||||
# eg. foo-depot/bar_dir
|
# eg. foo-depot/bar_dir
|
||||||
# * :stream - The stream in the depot that code should be pulled from. If
|
# * :stream - The stream in the depot that code should be pulled from. If
|
||||||
# left blank, the depot stream will be used
|
# left blank, the depot stream will be used
|
||||||
# * :revision - Should be in the form 'stream/transaction'.
|
# * :revision - Should be in the form 'stream/transaction'.
|
||||||
class Accurev < Base
|
class Accurev < Base
|
||||||
include REXML
|
include REXML
|
||||||
default_command 'accurev'
|
default_command 'accurev'
|
||||||
|
@ -54,10 +54,10 @@ module Capistrano
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Pops a copy of the code for the specified Accurev revision identifier.
|
# Pops a copy of the code for the specified Accurev revision identifier.
|
||||||
# The revision identifier is represented as a stream & transaction ID combo.
|
# The revision identifier is represented as a stream & transaction ID combo.
|
||||||
# Accurev can only pop a particular transaction if a stream is created on the server
|
# Accurev can only pop a particular transaction if a stream is created on the server
|
||||||
# with a time basis of that transaction id. Therefore, we will create a stream with
|
# with a time basis of that transaction id. Therefore, we will create a stream with
|
||||||
# the required criteria and pop that.
|
# the required criteria and pop that.
|
||||||
def export(revision_id, destination)
|
def export(revision_id, destination)
|
||||||
revision = InternalRevision.parse(revision_id)
|
revision = InternalRevision.parse(revision_id)
|
||||||
|
@ -89,7 +89,7 @@ module Capistrano
|
||||||
].join(' | ')
|
].join(' | ')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the command needed to show the diff between what is deployed and what is
|
# Returns the command needed to show the diff between what is deployed and what is
|
||||||
# pending. Because Accurev can not do this task without creating some streams,
|
# pending. Because Accurev can not do this task without creating some streams,
|
||||||
# two time basis streams will be created for the purposes of doing the diff.
|
# two time basis streams will be created for the purposes of doing the diff.
|
||||||
def diff(from, to=head)
|
def diff(from, to=head)
|
||||||
|
@ -156,7 +156,7 @@ module Capistrano
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
"#{stream}/#{transaction_id}"
|
"#{stream}/#{transaction_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def ==(other)
|
def ==(other)
|
||||||
|
|
|
@ -63,7 +63,7 @@ module Capistrano
|
||||||
scm cvs_root, :log, range_arg
|
scm cvs_root, :log, range_arg
|
||||||
end
|
end
|
||||||
|
|
||||||
# Unfortunately, cvs doesn't support the concept of a revision number like
|
# Unfortunately, cvs doesn't support the concept of a revision number like
|
||||||
# subversion and other SCM's do. For now, we'll rely on getting the timestamp
|
# subversion and other SCM's do. For now, we'll rely on getting the timestamp
|
||||||
# of the latest checkin under the revision that's passed to us.
|
# of the latest checkin under the revision that's passed to us.
|
||||||
def query_revision(revision)
|
def query_revision(revision)
|
||||||
|
@ -99,7 +99,7 @@ module Capistrano
|
||||||
root << "-d #{repository} " if repository
|
root << "-d #{repository} " if repository
|
||||||
root
|
root
|
||||||
end
|
end
|
||||||
|
|
||||||
# Constructs the destination dir command-line option
|
# Constructs the destination dir command-line option
|
||||||
def cvs_destination(destination)
|
def cvs_destination(destination)
|
||||||
dest = ""
|
dest = ""
|
||||||
|
@ -109,7 +109,7 @@ module Capistrano
|
||||||
end
|
end
|
||||||
dest
|
dest
|
||||||
end
|
end
|
||||||
|
|
||||||
# attempts to guess what type of revision we're working with
|
# attempts to guess what type of revision we're working with
|
||||||
def revision_type(rev)
|
def revision_type(rev)
|
||||||
return :date if rev =~ /^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2} UTC$/ # i.e 2007-05-15 08:13:25 UTC
|
return :date if rev =~ /^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2} UTC$/ # i.e 2007-05-15 08:13:25 UTC
|
||||||
|
@ -117,7 +117,7 @@ module Capistrano
|
||||||
return :revision if rev =~ /^\d/ # i.e. 1.2.1
|
return :revision if rev =~ /^\d/ # i.e. 1.2.1
|
||||||
return :tag # i.e. RELEASE_1_2
|
return :tag # i.e. RELEASE_1_2
|
||||||
end
|
end
|
||||||
|
|
||||||
# constructs the appropriate command-line switch for specifying a
|
# constructs the appropriate command-line switch for specifying a
|
||||||
# "revision" in CVS. This could be a tag, branch, revision (i.e. 1.3)
|
# "revision" in CVS. This could be a tag, branch, revision (i.e. 1.3)
|
||||||
# or a date (to be used with -d)
|
# or a date (to be used with -d)
|
||||||
|
|
|
@ -25,13 +25,13 @@ module Capistrano
|
||||||
"--to-match='hash #{revision}'"
|
"--to-match='hash #{revision}'"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the command that will check out the given revision to the
|
# Returns the command that will check out the given revision to the
|
||||||
# given destination. The 'revision' parameter must be the 'hash' value
|
# given destination. The 'revision' parameter must be the 'hash' value
|
||||||
# for the revision in question, as given by 'darcs changes --xml-output'.
|
# for the revision in question, as given by 'darcs changes --xml-output'.
|
||||||
def checkout(revision, destination)
|
def checkout(revision, destination)
|
||||||
scm :get, *[verbose,
|
scm :get, *[verbose,
|
||||||
"--repo-name=#{destination}",
|
"--repo-name=#{destination}",
|
||||||
to_match(revision),
|
to_match(revision),
|
||||||
repository].compact
|
repository].compact
|
||||||
end
|
end
|
||||||
|
|
|
@ -133,7 +133,7 @@ module Capistrano
|
||||||
git = command
|
git = command
|
||||||
remote = origin
|
remote = origin
|
||||||
|
|
||||||
args = []
|
args = []
|
||||||
|
|
||||||
# Add an option for the branch name so :git_shallow_clone works with branches
|
# Add an option for the branch name so :git_shallow_clone works with branches
|
||||||
args << "-b #{variable(:branch)}" unless variable(:branch).nil?
|
args << "-b #{variable(:branch)}" unless variable(:branch).nil?
|
||||||
|
|
|
@ -89,11 +89,11 @@ module Capistrano
|
||||||
"yes\n"
|
"yes\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Fine grained mercurial commands
|
# Fine grained mercurial commands
|
||||||
def clone(destination)
|
def clone(destination)
|
||||||
scm :clone,
|
scm :clone,
|
||||||
verbose,
|
verbose,
|
||||||
"--noupdate", # do not update to tip when cloning is done
|
"--noupdate", # do not update to tip when cloning is done
|
||||||
|
@ -124,7 +124,7 @@ module Capistrano
|
||||||
else "--verbose"
|
else "--verbose"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# honor Cap 2.1+'s :scm_prefer_prompt if present
|
# honor Cap 2.1+'s :scm_prefer_prompt if present
|
||||||
def scm_password_or_prompt
|
def scm_password_or_prompt
|
||||||
@scm_password_or_prompt ||= variable(:scm_password) ||
|
@scm_password_or_prompt ||= variable(:scm_password) ||
|
||||||
|
|
|
@ -19,7 +19,7 @@ module Capistrano
|
||||||
# set :scm, :none
|
# set :scm, :none
|
||||||
# set :deploy_via, :copy
|
# set :deploy_via, :copy
|
||||||
#
|
#
|
||||||
# Dereference symbolic links. Copy files instead. Handy when you
|
# Dereference symbolic links. Copy files instead. Handy when you
|
||||||
# reference files and directory outside of your deployment root.
|
# reference files and directory outside of your deployment root.
|
||||||
# set :copy_dereference_symlink, true
|
# set :copy_dereference_symlink, true
|
||||||
|
|
||||||
|
@ -41,13 +41,13 @@ module Capistrano
|
||||||
def query_revision(revision)
|
def query_revision(revision)
|
||||||
revision
|
revision
|
||||||
end
|
end
|
||||||
|
|
||||||
# log: There's no log, so it just echos from and to.
|
# log: There's no log, so it just echos from and to.
|
||||||
|
|
||||||
def log(from="", to="")
|
def log(from="", to="")
|
||||||
"No SCM: #{from} - #{to}"
|
"No SCM: #{from} - #{to}"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -113,7 +113,7 @@ module Capistrano
|
||||||
def p4passwd
|
def p4passwd
|
||||||
variable(:p4passwd) || variable(:scm_password)
|
variable(:p4passwd) || variable(:scm_password)
|
||||||
end
|
end
|
||||||
|
|
||||||
def p4charset
|
def p4charset
|
||||||
variable(:p4charset)
|
variable(:p4charset)
|
||||||
end
|
end
|
||||||
|
|
|
@ -70,7 +70,7 @@ module Capistrano
|
||||||
port = server.port || options[:port] || ssh_options[:port]
|
port = server.port || options[:port] || ssh_options[:port]
|
||||||
|
|
||||||
# the .ssh/config file might have changed the host-name on us
|
# the .ssh/config file might have changed the host-name on us
|
||||||
host = ssh_options.fetch(:host_name, server.host)
|
host = ssh_options.fetch(:host_name, server.host)
|
||||||
|
|
||||||
ssh_options[:port] = port if port
|
ssh_options[:port] = port if port
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ class CLIOptionsTest < Test::Unit::TestCase
|
||||||
@cli.expects(:exit).raises(ExitException)
|
@cli.expects(:exit).raises(ExitException)
|
||||||
assert_raises(ExitException) { @cli.parse_options! }
|
assert_raises(ExitException) { @cli.parse_options! }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parse_options_with_d_should_set_debug_option
|
def test_parse_options_with_d_should_set_debug_option
|
||||||
@cli.args << "-d"
|
@cli.args << "-d"
|
||||||
@cli.parse_options!
|
@cli.parse_options!
|
||||||
|
|
|
@ -126,7 +126,7 @@ class ConfigurationCallbacksTest < Test::Unit::TestCase
|
||||||
assert_equal 1, @config.callbacks[:before].length
|
assert_equal 1, @config.callbacks[:before].length
|
||||||
assert_equal %w(primary), @config.callbacks[:before].first.except
|
assert_equal %w(primary), @config.callbacks[:before].first.except
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_on_without_tasks_or_block_should_raise_error
|
def test_on_without_tasks_or_block_should_raise_error
|
||||||
assert_raises(ArgumentError) { @config.on(:before) }
|
assert_raises(ArgumentError) { @config.on(:before) }
|
||||||
end
|
end
|
||||||
|
|
|
@ -146,7 +146,7 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_parent_for_namespace_should_be_the_top_level
|
def test_parent_for_namespace_should_be_the_top_level
|
||||||
@config.namespace(:outer) {}
|
@config.namespace(:outer) {}
|
||||||
assert_equal @config, @config.namespaces[:outer].parent
|
assert_equal @config, @config.namespaces[:outer].parent
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fqn_for_nested_namespace_should_be_color_delimited
|
def test_fqn_for_nested_namespace_should_be_color_delimited
|
||||||
|
@ -238,7 +238,7 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
|
||||||
ns = @config.namespaces[:outer]
|
ns = @config.namespaces[:outer]
|
||||||
assert ns.respond_to?(:original_initialize_called)
|
assert ns.respond_to?(:original_initialize_called)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_namespace_should_accept_respond_to_with_include_priv_parameter
|
def test_namespace_should_accept_respond_to_with_include_priv_parameter
|
||||||
@config.namespace(:outer) {}
|
@config.namespace(:outer) {}
|
||||||
ns = @config.namespaces[:outer]
|
ns = @config.namespaces[:outer]
|
||||||
|
@ -308,16 +308,16 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
assert_nil @config.find_task("outer::inner")
|
assert_nil @config.find_task("outer::inner")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_kernel_method_clashing_should_not_affect_method_delegation_to_parent
|
def test_kernel_method_clashing_should_not_affect_method_delegation_to_parent
|
||||||
@config.class.class_eval do
|
@config.class.class_eval do
|
||||||
def some_weird_method() 'config' end
|
def some_weird_method() 'config' end
|
||||||
end
|
end
|
||||||
|
|
||||||
@config.namespace(:clash) {}
|
@config.namespace(:clash) {}
|
||||||
namespace = @config.namespaces[:clash]
|
namespace = @config.namespaces[:clash]
|
||||||
assert_equal 'config', namespace.some_weird_method
|
assert_equal 'config', namespace.some_weird_method
|
||||||
|
|
||||||
Kernel.module_eval do
|
Kernel.module_eval do
|
||||||
def some_weird_method() 'kernel' end
|
def some_weird_method() 'kernel' end
|
||||||
end
|
end
|
||||||
|
@ -325,7 +325,7 @@ class ConfigurationNamespacesDSLTest < Test::Unit::TestCase
|
||||||
@config.namespace(:clash2) {}
|
@config.namespace(:clash2) {}
|
||||||
namespace = @config.namespaces[:clash2]
|
namespace = @config.namespaces[:clash2]
|
||||||
assert_equal 'config', namespace.some_weird_method
|
assert_equal 'config', namespace.some_weird_method
|
||||||
|
|
||||||
Kernel.send :remove_method, :some_weird_method
|
Kernel.send :remove_method, :some_weird_method
|
||||||
@config.class.send :remove_method, :some_weird_method
|
@config.class.send :remove_method, :some_weird_method
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,14 +21,14 @@ class ConfigurationRolesTest < Test::Unit::TestCase
|
||||||
assert @config.original_initialize_called
|
assert @config.original_initialize_called
|
||||||
assert @config.roles.empty?
|
assert @config.roles.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_roles_for_host_with_one_role
|
def test_roles_for_host_with_one_role
|
||||||
@config.role :app, "app1.capistrano.test"
|
@config.role :app, "app1.capistrano.test"
|
||||||
@config.role :not_app, "not-app.capistrano.test"
|
@config.role :not_app, "not-app.capistrano.test"
|
||||||
app_server = @config.roles[:app].servers.first
|
app_server = @config.roles[:app].servers.first
|
||||||
assert @config.role_names_for_host(app_server)==[ :app ]
|
assert @config.role_names_for_host(app_server)==[ :app ]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_roles_for_host_with_multiple_roles
|
def test_roles_for_host_with_multiple_roles
|
||||||
@config.server "www.capistrano.test", :db, :worker
|
@config.server "www.capistrano.test", :db, :worker
|
||||||
db_server = @config.roles[:db].servers.first
|
db_server = @config.roles[:db].servers.first
|
||||||
|
|
|
@ -163,7 +163,7 @@ class ConfigurationServersTest < Test::Unit::TestCase
|
||||||
assert_equal %w(app1 app2 app3), @config.find_servers(:roles => lambda { :app }).map { |s| s.host }.sort
|
assert_equal %w(app1 app2 app3), @config.find_servers(:roles => lambda { :app }).map { |s| s.host }.sort
|
||||||
assert_equal %w(app2 file), @config.find_servers(:roles => lambda { [:report, :file] }).map { |s| s.host }.sort
|
assert_equal %w(app2 file), @config.find_servers(:roles => lambda { [:report, :file] }).map { |s| s.host }.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_find_servers_with_hosts_nil_or_empty
|
def test_find_servers_with_hosts_nil_or_empty
|
||||||
assert_equal [], @config.find_servers(:hosts => nil)
|
assert_equal [], @config.find_servers(:hosts => nil)
|
||||||
assert_equal [], @config.find_servers(:hosts => [])
|
assert_equal [], @config.find_servers(:hosts => [])
|
||||||
|
@ -172,12 +172,12 @@ class ConfigurationServersTest < Test::Unit::TestCase
|
||||||
result = @config.find_servers(:hosts => "app1")
|
result = @config.find_servers(:hosts => "app1")
|
||||||
assert_equal 1, result.size
|
assert_equal 1, result.size
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_find_servers_with_rolees_nil_or_empty
|
def test_find_servers_with_rolees_nil_or_empty
|
||||||
assert_equal [], @config.find_servers(:roles => nil)
|
assert_equal [], @config.find_servers(:roles => nil)
|
||||||
assert_equal [], @config.find_servers(:roles => [])
|
assert_equal [], @config.find_servers(:roles => [])
|
||||||
result = @config.find_servers(:roles => :report)
|
result = @config.find_servers(:roles => :report)
|
||||||
assert_equal 1, result.size
|
assert_equal 1, result.size
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,13 +53,13 @@ class ConfigurationVariablesTest < Test::Unit::TestCase
|
||||||
@config[:sample] = :value
|
@config[:sample] = :value
|
||||||
assert @config.respond_to?(:sample)
|
assert @config.respond_to?(:sample)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_respond_to_should_be_true_when_passed_a_string
|
def test_respond_to_should_be_true_when_passed_a_string
|
||||||
assert !@config.respond_to?('sample')
|
assert !@config.respond_to?('sample')
|
||||||
@config[:sample] = :value
|
@config[:sample] = :value
|
||||||
assert @config.respond_to?('sample')
|
assert @config.respond_to?('sample')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_respond_to_with_include_priv_paramter
|
def test_respond_to_with_include_priv_paramter
|
||||||
assert !@config.respond_to?(:sample, true)
|
assert !@config.respond_to?(:sample, true)
|
||||||
end
|
end
|
||||||
|
|
|
@ -41,7 +41,7 @@ class DeploySCMBzrTest < Test::Unit::TestCase
|
||||||
'before:revid:aaaa@bbbb-1234567890',
|
'before:revid:aaaa@bbbb-1234567890',
|
||||||
'last:3',
|
'last:3',
|
||||||
nil, {}, [], true, false, 1.34, ]
|
nil, {}, [], true, false, 1.34, ]
|
||||||
|
|
||||||
revision_samples.each do |revivsion_spec|
|
revision_samples.each do |revivsion_spec|
|
||||||
assert_equal(revivsion_spec,
|
assert_equal(revivsion_spec,
|
||||||
@source.query_revision(revivsion_spec),
|
@source.query_revision(revivsion_spec),
|
||||||
|
|
|
@ -15,7 +15,7 @@ class DeploySCMDarcsTest < Test::Unit::TestCase
|
||||||
# We should be able to pick a specific hash.
|
# We should be able to pick a specific hash.
|
||||||
def test_checkout_hash
|
def test_checkout_hash
|
||||||
hsh = "*version_hash*"
|
hsh = "*version_hash*"
|
||||||
assert_match(%r{--to-match=.hash #{Regexp.quote(hsh)}},
|
assert_match(%r{--to-match=.hash #{Regexp.quote(hsh)}},
|
||||||
@source.checkout(hsh, "*foo_location*"),
|
@source.checkout(hsh, "*foo_location*"),
|
||||||
"Specifying a revision hash got the --to-match option wrong.")
|
"Specifying a revision hash got the --to-match option wrong.")
|
||||||
end
|
end
|
||||||
|
@ -31,7 +31,7 @@ class DeploySCMDarcsTest < Test::Unit::TestCase
|
||||||
# Leaving the revision as nil shouldn't break anything.
|
# Leaving the revision as nil shouldn't break anything.
|
||||||
def test_checkout_nil
|
def test_checkout_nil
|
||||||
assert_no_match(%r{--to-match}, @source.checkout(nil, "*foo_location*"),
|
assert_no_match(%r{--to-match}, @source.checkout(nil, "*foo_location*"),
|
||||||
"Leaving the revision as nil incorrectly produced a --to-match option.")
|
"Leaving the revision as nil incorrectly produced a --to-match option.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -62,19 +62,19 @@ class DeploySCMMercurialTest < Test::Unit::TestCase
|
||||||
@config[:scm_command] = "/opt/local/bin/hg"
|
@config[:scm_command] = "/opt/local/bin/hg"
|
||||||
assert_equal "/opt/local/bin/hg pull --repository /var/www && /opt/local/bin/hg update --repository /var/www --clean 8a8e00b8f11b", @source.sync('8a8e00b8f11b', dest)
|
assert_equal "/opt/local/bin/hg pull --repository /var/www && /opt/local/bin/hg update --repository /var/www --clean 8a8e00b8f11b", @source.sync('8a8e00b8f11b', dest)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_export
|
def test_export
|
||||||
dest = "/var/www"
|
dest = "/var/www"
|
||||||
assert_raise(NotImplementedError) { @source.export('8a8e00b8f11b', dest) }
|
assert_raise(NotImplementedError) { @source.export('8a8e00b8f11b', dest) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_sends_password_if_set
|
def test_sends_password_if_set
|
||||||
require 'capistrano/logger'
|
require 'capistrano/logger'
|
||||||
text = "password:"
|
text = "password:"
|
||||||
@config[:scm_password] = "opensesame"
|
@config[:scm_password] = "opensesame"
|
||||||
assert_equal "opensesame\n", @source.handle_data(mock_state, :test_stream, text)
|
assert_equal "opensesame\n", @source.handle_data(mock_state, :test_stream, text)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_prompts_for_password_if_preferred
|
def test_prompts_for_password_if_preferred
|
||||||
require 'capistrano/logger'
|
require 'capistrano/logger'
|
||||||
require 'capistrano/cli'
|
require 'capistrano/cli'
|
||||||
|
|
|
@ -62,11 +62,11 @@ class ServerDefinitionTest < Test::Unit::TestCase
|
||||||
server = Capistrano::ServerDefinition.new("www.capistrano.test", :primary => true)
|
server = Capistrano::ServerDefinition.new("www.capistrano.test", :primary => true)
|
||||||
assert_equal true, server.options[:primary]
|
assert_equal true, server.options[:primary]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_default_user_should_try_to_guess_username
|
def test_default_user_should_try_to_guess_username
|
||||||
ENV.stubs(:[]).returns(nil)
|
ENV.stubs(:[]).returns(nil)
|
||||||
assert_equal "not-specified", Capistrano::ServerDefinition.default_user
|
assert_equal "not-specified", Capistrano::ServerDefinition.default_user
|
||||||
|
|
||||||
ENV.stubs(:[]).returns(nil)
|
ENV.stubs(:[]).returns(nil)
|
||||||
ENV.stubs(:[]).with("USERNAME").returns("ryan")
|
ENV.stubs(:[]).with("USERNAME").returns("ryan")
|
||||||
assert_equal "ryan", Capistrano::ServerDefinition.default_user
|
assert_equal "ryan", Capistrano::ServerDefinition.default_user
|
||||||
|
|
|
@ -67,7 +67,7 @@ class ShellTest < Test::Unit::TestCase
|
||||||
@shell.expects(:process_command).with("on", "app,db", "hello world")
|
@shell.expects(:process_command).with("on", "app,db", "hello world")
|
||||||
assert @shell.read_and_execute
|
assert @shell.read_and_execute
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_task_command_with_bang_gets_processed_by_exec_tasks
|
def test_task_command_with_bang_gets_processed_by_exec_tasks
|
||||||
while_testing_post_exec_commands do
|
while_testing_post_exec_commands do
|
||||||
@shell.expects(:read_line).returns("!deploy")
|
@shell.expects(:read_line).returns("!deploy")
|
||||||
|
@ -75,7 +75,7 @@ class ShellTest < Test::Unit::TestCase
|
||||||
assert @shell.read_and_execute
|
assert @shell.read_and_execute
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_normal_command_gets_processed_by_exec_command
|
def test_normal_command_gets_processed_by_exec_command
|
||||||
while_testing_post_exec_commands do
|
while_testing_post_exec_commands do
|
||||||
@shell.expects(:read_line).returns("uptime")
|
@shell.expects(:read_line).returns("uptime")
|
||||||
|
@ -84,13 +84,13 @@ class ShellTest < Test::Unit::TestCase
|
||||||
assert @shell.read_and_execute
|
assert @shell.read_and_execute
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def while_testing_post_exec_commands(&block)
|
def while_testing_post_exec_commands(&block)
|
||||||
@shell.instance_variable_set(:@mutex,Mutex.new)
|
@shell.instance_variable_set(:@mutex,Mutex.new)
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue