minmb-capistrano 2.15.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/.travis.yml +7 -0
- data/CHANGELOG +1170 -0
- data/Gemfile +13 -0
- data/README.md +94 -0
- data/Rakefile +11 -0
- data/bin/cap +4 -0
- data/bin/capify +92 -0
- data/capistrano.gemspec +40 -0
- data/lib/capistrano.rb +5 -0
- data/lib/capistrano/callback.rb +45 -0
- data/lib/capistrano/cli.rb +47 -0
- data/lib/capistrano/cli/execute.rb +85 -0
- data/lib/capistrano/cli/help.rb +125 -0
- data/lib/capistrano/cli/help.txt +81 -0
- data/lib/capistrano/cli/options.rb +243 -0
- data/lib/capistrano/cli/ui.rb +40 -0
- data/lib/capistrano/command.rb +303 -0
- data/lib/capistrano/configuration.rb +57 -0
- data/lib/capistrano/configuration/actions/file_transfer.rb +50 -0
- data/lib/capistrano/configuration/actions/inspect.rb +46 -0
- data/lib/capistrano/configuration/actions/invocation.rb +329 -0
- data/lib/capistrano/configuration/alias_task.rb +26 -0
- data/lib/capistrano/configuration/callbacks.rb +147 -0
- data/lib/capistrano/configuration/connections.rb +237 -0
- data/lib/capistrano/configuration/execution.rb +142 -0
- data/lib/capistrano/configuration/loading.rb +205 -0
- data/lib/capistrano/configuration/log_formatters.rb +75 -0
- data/lib/capistrano/configuration/namespaces.rb +223 -0
- data/lib/capistrano/configuration/roles.rb +77 -0
- data/lib/capistrano/configuration/servers.rb +116 -0
- data/lib/capistrano/configuration/variables.rb +127 -0
- data/lib/capistrano/errors.rb +19 -0
- data/lib/capistrano/ext/multistage.rb +64 -0
- data/lib/capistrano/ext/string.rb +5 -0
- data/lib/capistrano/extensions.rb +57 -0
- data/lib/capistrano/fix_rake_deprecated_dsl.rb +8 -0
- data/lib/capistrano/logger.rb +166 -0
- data/lib/capistrano/processable.rb +57 -0
- data/lib/capistrano/recipes/compat.rb +32 -0
- data/lib/capistrano/recipes/deploy.rb +625 -0
- data/lib/capistrano/recipes/deploy/assets.rb +201 -0
- data/lib/capistrano/recipes/deploy/dependencies.rb +44 -0
- data/lib/capistrano/recipes/deploy/local_dependency.rb +54 -0
- data/lib/capistrano/recipes/deploy/remote_dependency.rb +117 -0
- data/lib/capistrano/recipes/deploy/scm.rb +19 -0
- data/lib/capistrano/recipes/deploy/scm/accurev.rb +169 -0
- data/lib/capistrano/recipes/deploy/scm/base.rb +200 -0
- data/lib/capistrano/recipes/deploy/scm/bzr.rb +86 -0
- data/lib/capistrano/recipes/deploy/scm/cvs.rb +153 -0
- data/lib/capistrano/recipes/deploy/scm/darcs.rb +96 -0
- data/lib/capistrano/recipes/deploy/scm/git.rb +293 -0
- data/lib/capistrano/recipes/deploy/scm/mercurial.rb +137 -0
- data/lib/capistrano/recipes/deploy/scm/none.rb +55 -0
- data/lib/capistrano/recipes/deploy/scm/perforce.rb +152 -0
- data/lib/capistrano/recipes/deploy/scm/subversion.rb +121 -0
- data/lib/capistrano/recipes/deploy/strategy.rb +19 -0
- data/lib/capistrano/recipes/deploy/strategy/base.rb +92 -0
- data/lib/capistrano/recipes/deploy/strategy/checkout.rb +20 -0
- data/lib/capistrano/recipes/deploy/strategy/copy.rb +338 -0
- data/lib/capistrano/recipes/deploy/strategy/export.rb +20 -0
- data/lib/capistrano/recipes/deploy/strategy/remote.rb +52 -0
- data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +57 -0
- data/lib/capistrano/recipes/deploy/strategy/unshared_remote_cache.rb +21 -0
- data/lib/capistrano/recipes/standard.rb +37 -0
- data/lib/capistrano/recipes/templates/maintenance.rhtml +53 -0
- data/lib/capistrano/role.rb +102 -0
- data/lib/capistrano/server_definition.rb +56 -0
- data/lib/capistrano/shell.rb +265 -0
- data/lib/capistrano/ssh.rb +95 -0
- data/lib/capistrano/task_definition.rb +77 -0
- data/lib/capistrano/transfer.rb +218 -0
- data/lib/capistrano/version.rb +11 -0
- data/test/cli/execute_test.rb +132 -0
- data/test/cli/help_test.rb +165 -0
- data/test/cli/options_test.rb +329 -0
- data/test/cli/ui_test.rb +28 -0
- data/test/cli_test.rb +17 -0
- data/test/command_test.rb +322 -0
- data/test/configuration/actions/file_transfer_test.rb +61 -0
- data/test/configuration/actions/inspect_test.rb +76 -0
- data/test/configuration/actions/invocation_test.rb +288 -0
- data/test/configuration/alias_task_test.rb +118 -0
- data/test/configuration/callbacks_test.rb +201 -0
- data/test/configuration/connections_test.rb +439 -0
- data/test/configuration/execution_test.rb +175 -0
- data/test/configuration/loading_test.rb +148 -0
- data/test/configuration/namespace_dsl_test.rb +332 -0
- data/test/configuration/roles_test.rb +157 -0
- data/test/configuration/servers_test.rb +183 -0
- data/test/configuration/variables_test.rb +190 -0
- data/test/configuration_test.rb +77 -0
- data/test/deploy/local_dependency_test.rb +76 -0
- data/test/deploy/remote_dependency_test.rb +146 -0
- data/test/deploy/scm/accurev_test.rb +23 -0
- data/test/deploy/scm/base_test.rb +55 -0
- data/test/deploy/scm/bzr_test.rb +51 -0
- data/test/deploy/scm/darcs_test.rb +37 -0
- data/test/deploy/scm/git_test.rb +221 -0
- data/test/deploy/scm/mercurial_test.rb +134 -0
- data/test/deploy/scm/none_test.rb +35 -0
- data/test/deploy/scm/perforce_test.rb +23 -0
- data/test/deploy/scm/subversion_test.rb +40 -0
- data/test/deploy/strategy/copy_test.rb +360 -0
- data/test/extensions_test.rb +69 -0
- data/test/fixtures/cli_integration.rb +5 -0
- data/test/fixtures/config.rb +5 -0
- data/test/fixtures/custom.rb +3 -0
- data/test/logger_formatting_test.rb +149 -0
- data/test/logger_test.rb +134 -0
- data/test/recipes_test.rb +25 -0
- data/test/role_test.rb +11 -0
- data/test/server_definition_test.rb +121 -0
- data/test/shell_test.rb +96 -0
- data/test/ssh_test.rb +113 -0
- data/test/task_definition_test.rb +117 -0
- data/test/transfer_test.rb +168 -0
- data/test/utils.rb +37 -0
- metadata +316 -0
@@ -0,0 +1,77 @@
|
|
1
|
+
require "utils"
|
2
|
+
require 'capistrano/configuration'
|
3
|
+
|
4
|
+
# These tests are only for testing the integration of the various components
|
5
|
+
# of the Configuration class. To test specific features, please look at the
|
6
|
+
# tests under test/configuration.
|
7
|
+
|
8
|
+
class ConfigurationTest < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@config = Capistrano::Configuration.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_connections_execution_loading_namespaces_roles_and_variables_modules_should_integrate_correctly
|
14
|
+
Capistrano::SSH.expects(:connect).with { |s,c| s.host == "www.capistrano.test" && c == @config }.returns(:session)
|
15
|
+
|
16
|
+
process_args = Proc.new do |tree, session, opts|
|
17
|
+
tree.fallback.command == "echo 'hello world'" &&
|
18
|
+
session == [:session] &&
|
19
|
+
opts == { :logger => @config.logger, :eof => true }
|
20
|
+
end
|
21
|
+
|
22
|
+
Capistrano::Command.expects(:process).with(&process_args)
|
23
|
+
|
24
|
+
@config.load do
|
25
|
+
role :test, "www.capistrano.test"
|
26
|
+
set :message, "hello world"
|
27
|
+
namespace :testing do
|
28
|
+
task :example, :roles => :test do
|
29
|
+
run "echo '#{message}'"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
@config.testing.example
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_tasks_in_nested_namespace_should_be_able_to_call_tasks_in_same_namespace
|
38
|
+
@config.namespace(:outer) do
|
39
|
+
task(:first) { set :called_first, true }
|
40
|
+
namespace(:inner) do
|
41
|
+
task(:first) { set :called_inner_first, true }
|
42
|
+
task(:second) { first }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
@config.outer.inner.second
|
47
|
+
assert !@config[:called_first]
|
48
|
+
assert @config[:called_inner_first]
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_tasks_in_nested_namespace_should_be_able_to_call_tasks_in_parent_namespace
|
52
|
+
@config.namespace(:outer) do
|
53
|
+
task(:first) { set :called_first, true }
|
54
|
+
namespace(:inner) do
|
55
|
+
task(:second) { first }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
@config.outer.inner.second
|
60
|
+
assert @config[:called_first]
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_tasks_in_nested_namespace_should_be_able_to_call_shadowed_tasks_in_parent_namespace
|
64
|
+
@config.namespace(:outer) do
|
65
|
+
task(:first) { set :called_first, true }
|
66
|
+
namespace(:inner) do
|
67
|
+
task(:first) { set :called_inner_first, true }
|
68
|
+
task(:second) { parent.first }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
@config.outer.inner.second
|
73
|
+
assert @config[:called_first]
|
74
|
+
assert !@config[:called_inner_first]
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require "utils"
|
2
|
+
require 'capistrano/recipes/deploy/local_dependency'
|
3
|
+
|
4
|
+
class LocalDependencyTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@config = { }
|
7
|
+
@dependency = Capistrano::Deploy::LocalDependency.new(@config)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_should_use_standard_error_message
|
11
|
+
setup_for_one_path_entry(false)
|
12
|
+
@dependency.command("cat")
|
13
|
+
assert_equal "`cat' could not be found in the path on the local host", @dependency.message
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_should_use_alternative_message_if_provided
|
17
|
+
setup_for_one_path_entry(false)
|
18
|
+
@dependency.command("cat").or("Sorry")
|
19
|
+
assert_equal "Sorry", @dependency.message
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_env_with_no_path_should_never_find_command
|
23
|
+
ENV.expects(:[]).with("PATH").returns(nil)
|
24
|
+
assert !@dependency.command("cat").pass?
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_env_with_one_path_entry_should_fail_if_command_not_found
|
28
|
+
setup_for_one_path_entry(false)
|
29
|
+
assert !@dependency.command("cat").pass?
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_env_with_one_path_entry_should_pass_if_command_found
|
33
|
+
setup_for_one_path_entry(true)
|
34
|
+
assert @dependency.command("cat").pass?
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_env_with_three_path_entries_should_fail_if_command_not_found
|
38
|
+
setup_for_three_path_entries(false)
|
39
|
+
assert !@dependency.command("cat").pass?
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_env_with_three_path_entries_should_pass_if_command_found
|
43
|
+
setup_for_three_path_entries(true)
|
44
|
+
assert @dependency.command("cat").pass?
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_env_with_one_path_entry_on_windows_should_pass_if_command_found_with_extension
|
48
|
+
setup_for_one_path_entry_on_windows(true)
|
49
|
+
assert @dependency.command("cat").pass?
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def setup_for_one_path_entry(command_found)
|
55
|
+
Capistrano::Deploy::LocalDependency.expects(:on_windows?).returns(false)
|
56
|
+
ENV.expects(:[]).with("PATH").returns("/bin")
|
57
|
+
File.expects(:executable?).with("/bin/cat").returns(command_found)
|
58
|
+
end
|
59
|
+
|
60
|
+
def setup_for_three_path_entries(command_found)
|
61
|
+
Capistrano::Deploy::LocalDependency.expects(:on_windows?).returns(false)
|
62
|
+
path = %w(/bin /usr/bin /usr/local/bin).join(File::PATH_SEPARATOR)
|
63
|
+
ENV.expects(:[]).with("PATH").returns(path)
|
64
|
+
File.expects(:executable?).with("/usr/bin/cat").returns(command_found)
|
65
|
+
File.expects(:executable?).at_most(1).with("/bin/cat").returns(false)
|
66
|
+
File.expects(:executable?).at_most(1).with("/usr/local/bin/cat").returns(false)
|
67
|
+
end
|
68
|
+
|
69
|
+
def setup_for_one_path_entry_on_windows(command_found)
|
70
|
+
Capistrano::Deploy::LocalDependency.expects(:on_windows?).returns(true)
|
71
|
+
ENV.expects(:[]).with("PATH").returns("/cygwin/bin")
|
72
|
+
File.stubs(:executable?).returns(false)
|
73
|
+
first_executable_extension = Capistrano::Deploy::LocalDependency.windows_executable_extensions.first
|
74
|
+
File.expects(:executable?).with("/cygwin/bin/cat#{first_executable_extension}").returns(command_found)
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require "utils"
|
2
|
+
require 'capistrano/recipes/deploy/remote_dependency'
|
3
|
+
|
4
|
+
class RemoteDependencyTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@config = { }
|
7
|
+
@dependency = Capistrano::Deploy::RemoteDependency.new(@config)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_should_use_standard_error_message_for_directory
|
11
|
+
setup_for_a_configuration_run("test -d /data", false)
|
12
|
+
@dependency.directory("/data")
|
13
|
+
assert_equal "`/data' is not a directory (host)", @dependency.message
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_should_use_standard_error_message_for_file
|
17
|
+
setup_for_a_configuration_run("test -f /data/foo.txt", false)
|
18
|
+
@dependency.file("/data/foo.txt")
|
19
|
+
assert_equal "`/data/foo.txt' is not a file (host)", @dependency.message
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_should_use_standard_error_message_for_writable
|
23
|
+
setup_for_a_configuration_run("test -w /data/foo.txt", false)
|
24
|
+
@dependency.writable("/data/foo.txt")
|
25
|
+
assert_equal "`/data/foo.txt' is not writable (host)", @dependency.message
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_should_use_standard_error_message_for_command
|
29
|
+
setup_for_a_configuration_run("which cat", false)
|
30
|
+
@dependency.command("cat")
|
31
|
+
assert_equal "`cat' could not be found in the path (host)", @dependency.message
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_should_use_standard_error_message_for_gem
|
35
|
+
setup_for_a_configuration_gem_run("capistrano", "9.9", false)
|
36
|
+
@dependency.gem("capistrano", 9.9)
|
37
|
+
assert_equal "gem `capistrano' 9.9 could not be found (host)", @dependency.message
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_should_use_standard_error_message_for_deb
|
41
|
+
setup_for_a_configuration_deb_run("dpkg", "1.15", false)
|
42
|
+
@dependency.deb("dpkg", "1.15")
|
43
|
+
assert_equal "package `dpkg' 1.15 could not be found (host)", @dependency.message
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_should_use_standard_error_message_for_rpm
|
47
|
+
setup_for_a_configuration_rpm_run("rpm", "4.8", false)
|
48
|
+
@dependency.rpm("rpm", "4.8")
|
49
|
+
assert_equal "package `rpm' 4.8 could not be found (host)", @dependency.message
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_should_fail_if_directory_not_found
|
53
|
+
setup_for_a_configuration_run("test -d /data", false)
|
54
|
+
assert !@dependency.directory("/data").pass?
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_should_pass_if_directory_found
|
58
|
+
setup_for_a_configuration_run("test -d /data", true)
|
59
|
+
assert @dependency.directory("/data").pass?
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_should_fail_if_file_not_found
|
63
|
+
setup_for_a_configuration_run("test -f /data/foo.txt", false)
|
64
|
+
assert !@dependency.file("/data/foo.txt").pass?
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_should_pass_if_file_found
|
68
|
+
setup_for_a_configuration_run("test -f /data/foo.txt", true)
|
69
|
+
assert @dependency.file("/data/foo.txt").pass?
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_should_fail_if_writable_not_found
|
73
|
+
setup_for_a_configuration_run("test -w /data/foo.txt", false)
|
74
|
+
assert !@dependency.writable("/data/foo.txt").pass?
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_should_pass_if_writable_found
|
78
|
+
setup_for_a_configuration_run("test -w /data/foo.txt", true)
|
79
|
+
assert @dependency.writable("/data/foo.txt").pass?
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_should_fail_if_command_not_found
|
83
|
+
setup_for_a_configuration_run("which cat", false)
|
84
|
+
assert !@dependency.command("cat").pass?
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_should_pass_if_command_found
|
88
|
+
setup_for_a_configuration_run("which cat", true)
|
89
|
+
assert @dependency.command("cat").pass?
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_should_fail_if_gem_not_found
|
93
|
+
setup_for_a_configuration_gem_run("capistrano", "9.9", false)
|
94
|
+
assert !@dependency.gem("capistrano", 9.9).pass?
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_should_pass_if_gem_found
|
98
|
+
setup_for_a_configuration_gem_run("capistrano", "9.9", true)
|
99
|
+
assert @dependency.gem("capistrano", 9.9).pass?
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_should_pass_if_deb_found
|
103
|
+
setup_for_a_configuration_deb_run("dpkg", "1.15", true)
|
104
|
+
assert @dependency.deb("dpkg", "1.15").pass?
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_should_fail_if_deb_not_found
|
108
|
+
setup_for_a_configuration_deb_run("dpkg", "1.15", false)
|
109
|
+
assert !@dependency.deb("dpkg", "1.15").pass?
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_should_use_alternative_message_if_provided
|
113
|
+
setup_for_a_configuration_run("which cat", false)
|
114
|
+
@dependency.command("cat").or("Sorry")
|
115
|
+
assert_equal "Sorry (host)", @dependency.message
|
116
|
+
end
|
117
|
+
|
118
|
+
private
|
119
|
+
|
120
|
+
def setup_for_a_configuration_run(command, passing)
|
121
|
+
expectation = @config.expects(:invoke_command).with(command, {})
|
122
|
+
if passing
|
123
|
+
expectation.returns(true)
|
124
|
+
else
|
125
|
+
error = Capistrano::CommandError.new
|
126
|
+
error.expects(:hosts).returns(["host"])
|
127
|
+
expectation.raises(error)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def setup_for_a_configuration_gem_run(name, version, passing)
|
132
|
+
@config.expects(:fetch).with(:gem_command, "gem").returns("gem")
|
133
|
+
find_gem_cmd = "gem specification --version '#{version}' #{name} 2>&1 | awk 'BEGIN { s = 0 } /^name:/ { s = 1; exit }; END { if(s == 0) exit 1 }'"
|
134
|
+
setup_for_a_configuration_run(find_gem_cmd, passing)
|
135
|
+
end
|
136
|
+
|
137
|
+
def setup_for_a_configuration_deb_run(name, version, passing)
|
138
|
+
find_deb_cmd = "dpkg -s #{name} | grep '^Version: #{version}'"
|
139
|
+
setup_for_a_configuration_run(find_deb_cmd, passing)
|
140
|
+
end
|
141
|
+
|
142
|
+
def setup_for_a_configuration_rpm_run(name, version, passing)
|
143
|
+
find_rpm_cmd = "rpm -q #{name} | grep '#{version}'"
|
144
|
+
setup_for_a_configuration_run(find_rpm_cmd, passing)
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "utils"
|
2
|
+
require 'capistrano/recipes/deploy/scm/accurev'
|
3
|
+
|
4
|
+
class AccurevTest < Test::Unit::TestCase
|
5
|
+
include Capistrano::Deploy::SCM
|
6
|
+
|
7
|
+
def test_internal_revision_to_s
|
8
|
+
assert_equal 'foo/1', Accurev::InternalRevision.new('foo', 1).to_s
|
9
|
+
assert_equal 'foo/highest', Accurev::InternalRevision.new('foo', 'highest').to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_internal_revision_parse
|
13
|
+
revision = Accurev::InternalRevision.parse('foo')
|
14
|
+
assert_equal 'foo', revision.stream
|
15
|
+
assert_equal 'highest', revision.transaction_id
|
16
|
+
assert_equal 'foo/highest', revision.to_s
|
17
|
+
|
18
|
+
revision = Accurev::InternalRevision.parse('foo/1')
|
19
|
+
assert_equal 'foo', revision.stream
|
20
|
+
assert_equal '1', revision.transaction_id
|
21
|
+
assert_equal 'foo/1', revision.to_s
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "utils"
|
2
|
+
require 'capistrano/recipes/deploy/scm/base'
|
3
|
+
|
4
|
+
class DeploySCMBaseTest < Test::Unit::TestCase
|
5
|
+
class TestSCM < Capistrano::Deploy::SCM::Base
|
6
|
+
default_command "floopy"
|
7
|
+
end
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@config = { }
|
11
|
+
def @config.exists?(name); key?(name); end
|
12
|
+
|
13
|
+
@source = TestSCM.new(@config)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_command_should_default_to_default_command
|
17
|
+
assert_equal "floopy", @source.command
|
18
|
+
@source.local { assert_equal "floopy", @source.command }
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_command_should_use_scm_command_if_available
|
22
|
+
@config[:scm_command] = "/opt/local/bin/floopy"
|
23
|
+
assert_equal "/opt/local/bin/floopy", @source.command
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_command_should_use_scm_command_in_local_mode_if_local_scm_command_not_set
|
27
|
+
@config[:scm_command] = "/opt/local/bin/floopy"
|
28
|
+
@source.local { assert_equal "/opt/local/bin/floopy", @source.command }
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_command_should_use_local_scm_command_in_local_mode_if_local_scm_command_is_set
|
32
|
+
@config[:scm_command] = "/opt/local/bin/floopy"
|
33
|
+
@config[:local_scm_command] = "/usr/local/bin/floopy"
|
34
|
+
assert_equal "/opt/local/bin/floopy", @source.command
|
35
|
+
@source.local { assert_equal "/usr/local/bin/floopy", @source.command }
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_command_should_use_default_if_scm_command_is_default
|
39
|
+
@config[:scm_command] = :default
|
40
|
+
assert_equal "floopy", @source.command
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_command_should_use_default_in_local_mode_if_local_scm_command_is_default
|
44
|
+
@config[:scm_command] = "/foo/bar/floopy"
|
45
|
+
@config[:local_scm_command] = :default
|
46
|
+
@source.local { assert_equal "floopy", @source.command }
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_local_mode_proxy_should_treat_messages_as_being_in_local_mode
|
50
|
+
@config[:scm_command] = "/foo/bar/floopy"
|
51
|
+
@config[:local_scm_command] = :default
|
52
|
+
assert_equal "floopy", @source.local.command
|
53
|
+
assert_equal "/foo/bar/floopy", @source.command
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "utils"
|
2
|
+
require 'capistrano/recipes/deploy/scm/bzr'
|
3
|
+
|
4
|
+
class DeploySCMBzrTest < Test::Unit::TestCase
|
5
|
+
class TestSCM < Capistrano::Deploy::SCM::Bzr
|
6
|
+
default_command "bzr"
|
7
|
+
end
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@config = { :repository => "." }
|
11
|
+
|
12
|
+
def @config.exists?(name); key?(name); end # is this actually needed?
|
13
|
+
|
14
|
+
@source = TestSCM.new(@config)
|
15
|
+
end
|
16
|
+
|
17
|
+
# The bzr scm does not support pseudo-ids. The bzr adapter uses symbol :head
|
18
|
+
# to refer to the recently committed revision.
|
19
|
+
def test_head_revision
|
20
|
+
assert_equal(:head,
|
21
|
+
@source.head,
|
22
|
+
"Since bzr doesn't know a real head revision, symbol :head is used instead.")
|
23
|
+
end
|
24
|
+
|
25
|
+
# The bzr scm does support many different ways to specify a revision. Only
|
26
|
+
# symbol :head triggers the bzr command 'revno'.
|
27
|
+
def test_query_revision
|
28
|
+
assert_equal("bzr revno #{@config[:repository]}",
|
29
|
+
@source.query_revision(:head) { |o| o },
|
30
|
+
"Query for :head revision should call bzr command 'revno' in repository directory.")
|
31
|
+
|
32
|
+
# Many valid revision specifications, some invalid on the last line
|
33
|
+
revision_samples = [ 5, -7, '2', '-4',
|
34
|
+
'revid:revid:aaaa@bbbb-123456789',
|
35
|
+
'submit:',
|
36
|
+
'ancestor:/path/to/branch',
|
37
|
+
'date:yesterday',
|
38
|
+
'branch:/path/to/branch',
|
39
|
+
'tag:trunk',
|
40
|
+
'revno:3:/path/to/branch',
|
41
|
+
'before:revid:aaaa@bbbb-1234567890',
|
42
|
+
'last:3',
|
43
|
+
nil, {}, [], true, false, 1.34, ]
|
44
|
+
|
45
|
+
revision_samples.each do |revivsion_spec|
|
46
|
+
assert_equal(revivsion_spec,
|
47
|
+
@source.query_revision(revivsion_spec),
|
48
|
+
"Any revision specification other than symbol :head should simply by returned.")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "utils"
|
2
|
+
require 'capistrano/recipes/deploy/scm/darcs'
|
3
|
+
|
4
|
+
class DeploySCMDarcsTest < Test::Unit::TestCase
|
5
|
+
class TestSCM < Capistrano::Deploy::SCM::Darcs
|
6
|
+
default_command "darcs"
|
7
|
+
end
|
8
|
+
def setup
|
9
|
+
@config = { :repository => "." }
|
10
|
+
# def @config.exists?(name); key?(name); end
|
11
|
+
|
12
|
+
@source = TestSCM.new(@config)
|
13
|
+
end
|
14
|
+
|
15
|
+
# We should be able to pick a specific hash.
|
16
|
+
def test_checkout_hash
|
17
|
+
hsh = "*version_hash*"
|
18
|
+
assert_match(%r{--to-match=.hash #{Regexp.quote(hsh)}},
|
19
|
+
@source.checkout(hsh, "*foo_location*"),
|
20
|
+
"Specifying a revision hash got the --to-match option wrong.")
|
21
|
+
end
|
22
|
+
|
23
|
+
# Picking the head revision should leave out the hash, because head is the
|
24
|
+
# default and we don't have a HEAD pseudotag
|
25
|
+
def test_checkout_head
|
26
|
+
hsh = @source.head
|
27
|
+
assert_no_match(%r{--to-match}, @source.checkout(hsh, "*foo_location*"),
|
28
|
+
"Selecting the head revision incorrectly produced a --to-match option.")
|
29
|
+
end
|
30
|
+
|
31
|
+
# Leaving the revision as nil shouldn't break anything.
|
32
|
+
def test_checkout_nil
|
33
|
+
assert_no_match(%r{--to-match}, @source.checkout(nil, "*foo_location*"),
|
34
|
+
"Leaving the revision as nil incorrectly produced a --to-match option.")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|