capistrano 2.8.0 → 3.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.docker/Dockerfile +7 -0
- data/.docker/ssh_key_rsa +49 -0
- data/.docker/ssh_key_rsa.pub +1 -0
- data/.docker/ubuntu_setup.sh +23 -0
- data/.github/issue_template.md +19 -0
- data/.github/pull_request_template.md +22 -0
- data/.github/release-drafter.yml +25 -0
- data/.github/workflows/ci.yml +80 -0
- data/.github/workflows/release-drafter.yml +18 -0
- data/.gitignore +23 -8
- data/.rubocop.yml +62 -0
- data/CHANGELOG.md +1 -0
- data/CONTRIBUTING.md +63 -0
- data/DEVELOPMENT.md +112 -0
- data/Gemfile +42 -9
- data/LICENSE.txt +21 -0
- data/README.md +221 -0
- data/RELEASING.md +17 -0
- data/Rakefile +17 -8
- data/UPGRADING-3.7.md +86 -0
- data/bin/cap +2 -3
- data/bin/capify +7 -89
- data/capistrano.gemspec +29 -43
- data/docker-compose.yml +8 -0
- data/features/configuration.feature +28 -0
- data/features/deploy.feature +92 -0
- data/features/deploy_failure.feature +17 -0
- data/features/doctor.feature +11 -0
- data/features/installation.feature +21 -0
- data/features/sshconnect.feature +11 -0
- data/features/stage_failure.feature +9 -0
- data/features/step_definitions/assertions.rb +162 -0
- data/features/step_definitions/cap_commands.rb +21 -0
- data/features/step_definitions/setup.rb +91 -0
- data/features/subdirectory.feature +9 -0
- data/features/support/docker_gateway.rb +53 -0
- data/features/support/env.rb +1 -0
- data/features/support/remote_command_helpers.rb +29 -0
- data/features/support/remote_ssh_helpers.rb +33 -0
- data/lib/Capfile +3 -0
- data/lib/capistrano/all.rb +17 -0
- data/lib/capistrano/application.rb +153 -0
- data/lib/capistrano/configuration/empty_filter.rb +9 -0
- data/lib/capistrano/configuration/filter.rb +26 -0
- data/lib/capistrano/configuration/host_filter.rb +29 -0
- data/lib/capistrano/configuration/null_filter.rb +9 -0
- data/lib/capistrano/configuration/plugin_installer.rb +51 -0
- data/lib/capistrano/configuration/question.rb +76 -0
- data/lib/capistrano/configuration/role_filter.rb +29 -0
- data/lib/capistrano/configuration/scm_resolver.rb +149 -0
- data/lib/capistrano/configuration/server.rb +137 -0
- data/lib/capistrano/configuration/servers.rb +56 -96
- data/lib/capistrano/configuration/validated_variables.rb +110 -0
- data/lib/capistrano/configuration/variables.rb +79 -94
- data/lib/capistrano/configuration.rb +178 -33
- data/lib/capistrano/console.rb +1 -0
- data/lib/capistrano/defaults.rb +36 -0
- data/lib/capistrano/deploy.rb +3 -0
- data/lib/capistrano/doctor/environment_doctor.rb +19 -0
- data/lib/capistrano/doctor/gems_doctor.rb +45 -0
- data/lib/capistrano/doctor/output_helpers.rb +79 -0
- data/lib/capistrano/doctor/servers_doctor.rb +105 -0
- data/lib/capistrano/doctor/variables_doctor.rb +74 -0
- data/lib/capistrano/doctor.rb +6 -0
- data/lib/capistrano/dotfile.rb +2 -0
- data/lib/capistrano/dsl/env.rb +43 -0
- data/lib/capistrano/dsl/paths.rb +89 -0
- data/lib/capistrano/dsl/stages.rb +31 -0
- data/lib/capistrano/dsl/task_enhancements.rb +61 -0
- data/lib/capistrano/dsl.rb +95 -0
- data/lib/capistrano/framework.rb +2 -0
- data/lib/capistrano/i18n.rb +46 -0
- data/lib/capistrano/immutable_task.rb +30 -0
- data/lib/capistrano/install.rb +1 -0
- data/lib/capistrano/plugin.rb +95 -0
- data/lib/capistrano/proc_helpers.rb +13 -0
- data/lib/capistrano/scm/git.rb +105 -0
- data/lib/capistrano/scm/hg.rb +55 -0
- data/lib/capistrano/scm/plugin.rb +13 -0
- data/lib/capistrano/scm/svn.rb +56 -0
- data/lib/capistrano/scm/tasks/git.rake +84 -0
- data/lib/capistrano/scm/tasks/hg.rake +53 -0
- data/lib/capistrano/scm/tasks/svn.rake +53 -0
- data/lib/capistrano/scm.rb +115 -0
- data/lib/capistrano/setup.rb +36 -0
- data/lib/capistrano/tasks/console.rake +25 -0
- data/lib/capistrano/tasks/deploy.rake +280 -0
- data/lib/capistrano/tasks/doctor.rake +24 -0
- data/lib/capistrano/tasks/framework.rake +67 -0
- data/lib/capistrano/tasks/install.rake +41 -0
- data/lib/capistrano/templates/Capfile +38 -0
- data/lib/capistrano/templates/deploy.rb.erb +39 -0
- data/lib/capistrano/templates/stage.rb.erb +61 -0
- data/lib/capistrano/upload_task.rb +9 -0
- data/lib/capistrano/version.rb +1 -14
- data/lib/capistrano/version_validator.rb +32 -0
- data/lib/capistrano.rb +0 -3
- data/spec/integration/dsl_spec.rb +632 -0
- data/spec/integration_spec_helper.rb +5 -0
- data/spec/lib/capistrano/application_spec.rb +60 -0
- data/spec/lib/capistrano/configuration/empty_filter_spec.rb +17 -0
- data/spec/lib/capistrano/configuration/filter_spec.rb +109 -0
- data/spec/lib/capistrano/configuration/host_filter_spec.rb +71 -0
- data/spec/lib/capistrano/configuration/null_filter_spec.rb +17 -0
- data/spec/lib/capistrano/configuration/plugin_installer_spec.rb +98 -0
- data/spec/lib/capistrano/configuration/question_spec.rb +92 -0
- data/spec/lib/capistrano/configuration/role_filter_spec.rb +80 -0
- data/spec/lib/capistrano/configuration/scm_resolver_spec.rb +56 -0
- data/spec/lib/capistrano/configuration/server_spec.rb +309 -0
- data/spec/lib/capistrano/configuration/servers_spec.rb +331 -0
- data/spec/lib/capistrano/configuration_spec.rb +357 -0
- data/spec/lib/capistrano/doctor/environment_doctor_spec.rb +44 -0
- data/spec/lib/capistrano/doctor/gems_doctor_spec.rb +67 -0
- data/spec/lib/capistrano/doctor/output_helpers_spec.rb +47 -0
- data/spec/lib/capistrano/doctor/servers_doctor_spec.rb +86 -0
- data/spec/lib/capistrano/doctor/variables_doctor_spec.rb +89 -0
- data/spec/lib/capistrano/dsl/paths_spec.rb +228 -0
- data/spec/lib/capistrano/dsl/task_enhancements_spec.rb +108 -0
- data/spec/lib/capistrano/dsl_spec.rb +125 -0
- data/spec/lib/capistrano/immutable_task_spec.rb +31 -0
- data/spec/lib/capistrano/plugin_spec.rb +84 -0
- data/spec/lib/capistrano/scm/git_spec.rb +194 -0
- data/spec/lib/capistrano/scm/hg_spec.rb +109 -0
- data/spec/lib/capistrano/scm/svn_spec.rb +137 -0
- data/spec/lib/capistrano/scm_spec.rb +103 -0
- data/spec/lib/capistrano/upload_task_spec.rb +19 -0
- data/spec/lib/capistrano/version_validator_spec.rb +118 -0
- data/spec/lib/capistrano_spec.rb +7 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/support/matchers.rb +5 -0
- data/spec/support/tasks/database.rake +11 -0
- data/spec/support/tasks/fail.rake +8 -0
- data/spec/support/tasks/failed.rake +5 -0
- data/spec/support/tasks/plugin.rake +6 -0
- data/spec/support/tasks/root.rake +11 -0
- data/spec/support/test_app.rb +205 -0
- metadata +234 -208
- data/.rvmrc +0 -1
- data/CHANGELOG +0 -954
- data/README.mdown +0 -76
- data/lib/capistrano/callback.rb +0 -45
- data/lib/capistrano/cli/execute.rb +0 -85
- data/lib/capistrano/cli/help.rb +0 -125
- data/lib/capistrano/cli/help.txt +0 -81
- data/lib/capistrano/cli/options.rb +0 -243
- data/lib/capistrano/cli/ui.rb +0 -40
- data/lib/capistrano/cli.rb +0 -47
- data/lib/capistrano/command.rb +0 -286
- data/lib/capistrano/configuration/actions/file_transfer.rb +0 -51
- data/lib/capistrano/configuration/actions/inspect.rb +0 -46
- data/lib/capistrano/configuration/actions/invocation.rb +0 -298
- data/lib/capistrano/configuration/callbacks.rb +0 -148
- data/lib/capistrano/configuration/connections.rb +0 -230
- data/lib/capistrano/configuration/execution.rb +0 -143
- data/lib/capistrano/configuration/loading.rb +0 -197
- data/lib/capistrano/configuration/namespaces.rb +0 -197
- data/lib/capistrano/configuration/roles.rb +0 -73
- data/lib/capistrano/errors.rb +0 -19
- data/lib/capistrano/ext/string.rb +0 -5
- data/lib/capistrano/extensions.rb +0 -57
- data/lib/capistrano/logger.rb +0 -59
- data/lib/capistrano/processable.rb +0 -53
- data/lib/capistrano/recipes/compat.rb +0 -32
- data/lib/capistrano/recipes/deploy/assets.rb +0 -57
- data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
- data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -54
- data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -111
- data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
- data/lib/capistrano/recipes/deploy/scm/base.rb +0 -196
- data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
- data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -153
- data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -96
- data/lib/capistrano/recipes/deploy/scm/git.rb +0 -282
- data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -137
- data/lib/capistrano/recipes/deploy/scm/none.rb +0 -44
- data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -138
- data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -121
- data/lib/capistrano/recipes/deploy/scm.rb +0 -19
- data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -88
- data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
- data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -224
- data/lib/capistrano/recipes/deploy/strategy/export.rb +0 -20
- data/lib/capistrano/recipes/deploy/strategy/remote.rb +0 -52
- data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +0 -57
- data/lib/capistrano/recipes/deploy/strategy.rb +0 -19
- data/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +0 -53
- data/lib/capistrano/recipes/deploy.rb +0 -568
- data/lib/capistrano/recipes/standard.rb +0 -37
- data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
- data/lib/capistrano/role.rb +0 -102
- data/lib/capistrano/server_definition.rb +0 -56
- data/lib/capistrano/shell.rb +0 -260
- data/lib/capistrano/ssh.rb +0 -101
- data/lib/capistrano/task_definition.rb +0 -75
- data/lib/capistrano/transfer.rb +0 -216
- data/rvmrc.sample +0 -1
- data/test/cli/execute_test.rb +0 -132
- data/test/cli/help_test.rb +0 -165
- data/test/cli/options_test.rb +0 -329
- data/test/cli/ui_test.rb +0 -28
- data/test/cli_test.rb +0 -17
- data/test/command_test.rb +0 -289
- data/test/configuration/actions/file_transfer_test.rb +0 -61
- data/test/configuration/actions/inspect_test.rb +0 -65
- data/test/configuration/actions/invocation_test.rb +0 -247
- data/test/configuration/callbacks_test.rb +0 -220
- data/test/configuration/connections_test.rb +0 -420
- data/test/configuration/execution_test.rb +0 -175
- data/test/configuration/loading_test.rb +0 -132
- data/test/configuration/namespace_dsl_test.rb +0 -311
- data/test/configuration/roles_test.rb +0 -144
- data/test/configuration/servers_test.rb +0 -183
- data/test/configuration/variables_test.rb +0 -190
- data/test/configuration_test.rb +0 -88
- data/test/deploy/local_dependency_test.rb +0 -76
- data/test/deploy/remote_dependency_test.rb +0 -135
- data/test/deploy/scm/accurev_test.rb +0 -23
- data/test/deploy/scm/base_test.rb +0 -55
- data/test/deploy/scm/bzr_test.rb +0 -51
- data/test/deploy/scm/darcs_test.rb +0 -37
- data/test/deploy/scm/git_test.rb +0 -184
- data/test/deploy/scm/mercurial_test.rb +0 -134
- data/test/deploy/scm/none_test.rb +0 -35
- data/test/deploy/scm/subversion_test.rb +0 -32
- data/test/deploy/strategy/copy_test.rb +0 -321
- data/test/extensions_test.rb +0 -69
- data/test/fixtures/cli_integration.rb +0 -5
- data/test/fixtures/config.rb +0 -5
- data/test/fixtures/custom.rb +0 -3
- data/test/logger_test.rb +0 -123
- data/test/recipes_test.rb +0 -25
- data/test/role_test.rb +0 -11
- data/test/server_definition_test.rb +0 -121
- data/test/shell_test.rb +0 -90
- data/test/ssh_test.rb +0 -113
- data/test/task_definition_test.rb +0 -116
- data/test/transfer_test.rb +0 -160
- data/test/utils.rb +0 -37
data/test/cli/options_test.rb
DELETED
@@ -1,329 +0,0 @@
|
|
1
|
-
require "utils"
|
2
|
-
require 'capistrano/cli/options'
|
3
|
-
|
4
|
-
class CLIOptionsTest < Test::Unit::TestCase
|
5
|
-
class ExitException < Exception; end
|
6
|
-
|
7
|
-
class MockCLI
|
8
|
-
def initialize
|
9
|
-
@args = []
|
10
|
-
end
|
11
|
-
|
12
|
-
attr_reader :args
|
13
|
-
|
14
|
-
include Capistrano::CLI::Options
|
15
|
-
end
|
16
|
-
|
17
|
-
def setup
|
18
|
-
@cli = MockCLI.new
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_parse_options_should_require_non_empty_args_list
|
22
|
-
@cli.stubs(:warn)
|
23
|
-
@cli.expects(:exit).raises(ExitException)
|
24
|
-
assert_raises(ExitException) { @cli.parse_options! }
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_parse_options_with_d_should_set_debug_option
|
28
|
-
@cli.args << "-d"
|
29
|
-
@cli.parse_options!
|
30
|
-
assert @cli.options[:debug]
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_parse_options_with_n_should_set_dry_run_option
|
34
|
-
@cli.args << "-n"
|
35
|
-
@cli.parse_options!
|
36
|
-
assert @cli.options[:dry_run]
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_parse_options_with_dry_run_should_set_dry_run_option
|
40
|
-
@cli.args << "--dry-run"
|
41
|
-
@cli.parse_options!
|
42
|
-
assert @cli.options[:dry_run]
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_parse_options_with_e_should_set_explain_option
|
46
|
-
@cli.args << "-e" << "sample"
|
47
|
-
@cli.parse_options!
|
48
|
-
assert_equal "sample", @cli.options[:explain]
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_parse_options_with_f_should_add_recipe_file
|
52
|
-
@cli.args << "-f" << "deploy"
|
53
|
-
@cli.parse_options!
|
54
|
-
assert_equal %w(deploy), @cli.options[:recipes]
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_parse_options_with_multiple_f_should_add_each_as_recipe_file
|
58
|
-
@cli.args << "-f" << "deploy" << "-f" << "monitor"
|
59
|
-
@cli.parse_options!
|
60
|
-
assert_equal %w(deploy monitor), @cli.options[:recipes]
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_parse_options_with_H_should_show_verbose_help_and_exit
|
64
|
-
@cli.expects(:exit).raises(ExitException)
|
65
|
-
@cli.expects(:long_help)
|
66
|
-
@cli.args << "-H"
|
67
|
-
assert_raises(ExitException) { @cli.parse_options! }
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_parse_options_with_h_should_show_options_and_exit
|
71
|
-
@cli.expects(:puts).with(@cli.option_parser)
|
72
|
-
@cli.expects(:exit).raises(ExitException)
|
73
|
-
@cli.args << "-h"
|
74
|
-
assert_raises(ExitException) { @cli.parse_options! }
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_parse_options_with_p_should_prompt_for_password
|
78
|
-
MockCLI.expects(:password_prompt).returns(:the_password)
|
79
|
-
@cli.args << "-p"
|
80
|
-
@cli.parse_options!
|
81
|
-
assert_equal :the_password, @cli.options[:password]
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_parse_options_without_p_should_set_proc_for_password
|
85
|
-
@cli.args << "-e" << "sample"
|
86
|
-
@cli.parse_options!
|
87
|
-
assert_instance_of Proc, @cli.options[:password]
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_parse_options_with_q_should_set_verbose_to_0
|
91
|
-
@cli.args << "-q"
|
92
|
-
@cli.parse_options!
|
93
|
-
assert_equal 0, @cli.options[:verbose]
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_parse_options_with_r_should_set_preserve_roles_option
|
97
|
-
@cli.args << "-r"
|
98
|
-
@cli.parse_options!
|
99
|
-
assert @cli.options[:preserve_roles]
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_parse_options_with_preserve_roles_should_set_preserve_roles_option
|
103
|
-
@cli.args << "--preserve-roles"
|
104
|
-
@cli.parse_options!
|
105
|
-
assert @cli.options[:preserve_roles]
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_parse_options_with_S_should_set_pre_vars
|
109
|
-
@cli.args << "-S" << "foo=bar"
|
110
|
-
@cli.parse_options!
|
111
|
-
assert_equal "bar", @cli.options[:pre_vars][:foo]
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_S_should_coerce_digits_to_integers
|
115
|
-
@cli.args << "-S" << "foo=1234"
|
116
|
-
@cli.parse_options!
|
117
|
-
assert_equal 1234, @cli.options[:pre_vars][:foo]
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_S_should_treat_quoted_integers_as_string
|
121
|
-
@cli.args << "-S" << "foo=\"1234\""
|
122
|
-
@cli.parse_options!
|
123
|
-
assert_equal "1234", @cli.options[:pre_vars][:foo]
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_S_should_treat_digits_with_dot_as_floating_point
|
127
|
-
@cli.args << "-S" << "foo=3.1415"
|
128
|
-
@cli.parse_options!
|
129
|
-
assert_equal 3.1415, @cli.options[:pre_vars][:foo]
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_S_should_treat_true_as_boolean_true
|
133
|
-
@cli.args << "-S" << "foo=true"
|
134
|
-
@cli.parse_options!
|
135
|
-
assert_equal true, @cli.options[:pre_vars][:foo]
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_S_should_treat_false_as_boolean_false
|
139
|
-
@cli.args << "-S" << "foo=false"
|
140
|
-
@cli.parse_options!
|
141
|
-
assert_equal false, @cli.options[:pre_vars][:foo]
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_S_should_treat_nil_as_nil
|
145
|
-
@cli.args << "-S" << "foo=nil"
|
146
|
-
@cli.parse_options!
|
147
|
-
assert_equal nil, @cli.options[:pre_vars][:foo]
|
148
|
-
end
|
149
|
-
|
150
|
-
def test_parse_options_with_s_should_set_vars
|
151
|
-
@cli.args << "-s" << "foo=bar"
|
152
|
-
@cli.parse_options!
|
153
|
-
assert_equal "bar", @cli.options[:vars][:foo]
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_s_should_coerce_digits_to_integers
|
157
|
-
@cli.args << "-s" << "foo=1234"
|
158
|
-
@cli.parse_options!
|
159
|
-
assert_equal 1234, @cli.options[:vars][:foo]
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_s_should_treat_quoted_integers_as_string
|
163
|
-
@cli.args << "-s" << "foo=\"1234\""
|
164
|
-
@cli.parse_options!
|
165
|
-
assert_equal "1234", @cli.options[:vars][:foo]
|
166
|
-
end
|
167
|
-
|
168
|
-
def test_s_should_treat_digits_with_dot_as_floating_point
|
169
|
-
@cli.args << "-s" << "foo=3.1415"
|
170
|
-
@cli.parse_options!
|
171
|
-
assert_equal 3.1415, @cli.options[:vars][:foo]
|
172
|
-
end
|
173
|
-
|
174
|
-
def test_s_should_treat_true_as_boolean_true
|
175
|
-
@cli.args << "-s" << "foo=true"
|
176
|
-
@cli.parse_options!
|
177
|
-
assert_equal true, @cli.options[:vars][:foo]
|
178
|
-
end
|
179
|
-
|
180
|
-
def test_s_should_treat_false_as_boolean_false
|
181
|
-
@cli.args << "-s" << "foo=false"
|
182
|
-
@cli.parse_options!
|
183
|
-
assert_equal false, @cli.options[:vars][:foo]
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_s_should_treat_nil_as_nil
|
187
|
-
@cli.args << "-s" << "foo=nil"
|
188
|
-
@cli.parse_options!
|
189
|
-
assert_equal nil, @cli.options[:vars][:foo]
|
190
|
-
end
|
191
|
-
|
192
|
-
def test_parse_options_with_T_should_set_tasks_option_and_set_verbose_off
|
193
|
-
@cli.args << "-T"
|
194
|
-
@cli.parse_options!
|
195
|
-
assert @cli.options[:tasks]
|
196
|
-
assert_equal 0, @cli.options[:verbose]
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_parse_options_with_V_should_show_version_and_exit
|
200
|
-
@cli.args << "-V"
|
201
|
-
@cli.expects(:puts).with { |s| s.include?(Capistrano::Version.to_s) }
|
202
|
-
@cli.expects(:exit).raises(ExitException)
|
203
|
-
assert_raises(ExitException) { @cli.parse_options! }
|
204
|
-
end
|
205
|
-
|
206
|
-
def test_parse_options_with_v_should_set_verbose_to_1
|
207
|
-
@cli.args << "-v"
|
208
|
-
@cli.parse_options!
|
209
|
-
assert_equal 1, @cli.options[:verbose]
|
210
|
-
end
|
211
|
-
|
212
|
-
def test_parse_options_with_multiple_v_should_set_verbose_accordingly
|
213
|
-
@cli.args << "-vvvvvvv"
|
214
|
-
@cli.parse_options!
|
215
|
-
assert_equal 7, @cli.options[:verbose]
|
216
|
-
end
|
217
|
-
|
218
|
-
def test_parse_options_without_X_should_set_sysconf
|
219
|
-
@cli.args << "-v"
|
220
|
-
@cli.parse_options!
|
221
|
-
assert @cli.options.key?(:sysconf)
|
222
|
-
end
|
223
|
-
|
224
|
-
def test_parse_options_with_X_should_unset_sysconf
|
225
|
-
@cli.args << "-X"
|
226
|
-
@cli.parse_options!
|
227
|
-
assert !@cli.options.key?(:sysconf)
|
228
|
-
end
|
229
|
-
|
230
|
-
def test_parse_options_without_x_should_set_dotfile
|
231
|
-
@cli.args << "-v"
|
232
|
-
@cli.parse_options!
|
233
|
-
assert @cli.options.key?(:dotfile)
|
234
|
-
end
|
235
|
-
|
236
|
-
def test_parse_options_with_x_should_unset_dotfile
|
237
|
-
@cli.args << "-x"
|
238
|
-
@cli.parse_options!
|
239
|
-
assert !@cli.options.key?(:dotfile)
|
240
|
-
end
|
241
|
-
|
242
|
-
def test_parse_options_without_q_or_v_should_set_verbose_to_3
|
243
|
-
@cli.args << "-x"
|
244
|
-
@cli.parse_options!
|
245
|
-
assert_equal 3, @cli.options[:verbose]
|
246
|
-
end
|
247
|
-
|
248
|
-
def test_should_search_for_default_recipes_if_f_not_given
|
249
|
-
@cli.expects(:look_for_default_recipe_file!)
|
250
|
-
@cli.args << "-v"
|
251
|
-
@cli.parse_options!
|
252
|
-
end
|
253
|
-
|
254
|
-
def test_should_not_search_for_default_recipes_if_f_given
|
255
|
-
@cli.expects(:look_for_default_recipe_file!).never
|
256
|
-
@cli.args << "-f" << "hello"
|
257
|
-
@cli.parse_options!
|
258
|
-
end
|
259
|
-
|
260
|
-
def test_F_should_search_for_default_recipes_even_if_f_is_given
|
261
|
-
@cli.expects(:look_for_default_recipe_file!)
|
262
|
-
@cli.args << "-Ff" << "hello"
|
263
|
-
@cli.parse_options!
|
264
|
-
end
|
265
|
-
|
266
|
-
def test_should_extract_env_vars_from_command_line
|
267
|
-
assert_nil ENV["HELLO"]
|
268
|
-
assert_nil ENV["ANOTHER"]
|
269
|
-
|
270
|
-
@cli.args << "HELLO=world" << "hello" << "ANOTHER=value"
|
271
|
-
@cli.parse_options!
|
272
|
-
|
273
|
-
assert_equal "world", ENV["HELLO"]
|
274
|
-
assert_equal "value", ENV["ANOTHER"]
|
275
|
-
ensure
|
276
|
-
ENV.delete("HELLO")
|
277
|
-
ENV.delete("ANOTHER")
|
278
|
-
end
|
279
|
-
|
280
|
-
def test_remaining_args_should_be_added_to_actions_list
|
281
|
-
@cli.args << "-v" << "HELLO=world" << "-f" << "foo" << "something" << "else"
|
282
|
-
@cli.parse_options!
|
283
|
-
assert_equal %w(something else), @cli.args
|
284
|
-
ensure
|
285
|
-
ENV.delete("HELLO")
|
286
|
-
end
|
287
|
-
|
288
|
-
def test_search_for_default_recipe_file_should_look_for_Capfile
|
289
|
-
File.stubs(:file?).returns(false)
|
290
|
-
File.expects(:file?).with("Capfile").returns(true)
|
291
|
-
@cli.args << "-v"
|
292
|
-
@cli.parse_options!
|
293
|
-
assert_equal %w(Capfile), @cli.options[:recipes]
|
294
|
-
end
|
295
|
-
|
296
|
-
def test_search_for_default_recipe_file_should_look_for_capfile
|
297
|
-
File.stubs(:file?).returns(false)
|
298
|
-
File.expects(:file?).with("capfile").returns(true)
|
299
|
-
@cli.args << "-v"
|
300
|
-
@cli.parse_options!
|
301
|
-
assert_equal %w(capfile), @cli.options[:recipes]
|
302
|
-
end
|
303
|
-
|
304
|
-
def test_search_for_default_recipe_should_hike_up_the_directory_tree_until_it_finds_default_recipe
|
305
|
-
File.stubs(:file?).returns(false)
|
306
|
-
File.expects(:file?).with("capfile").times(2).returns(false,true)
|
307
|
-
Dir.expects(:pwd).times(3).returns(*%w(/bar/baz /bar/baz /bar))
|
308
|
-
Dir.expects(:chdir).with("..")
|
309
|
-
@cli.args << "-v"
|
310
|
-
@cli.parse_options!
|
311
|
-
assert_equal %w(capfile), @cli.options[:recipes]
|
312
|
-
end
|
313
|
-
|
314
|
-
def test_search_for_default_recipe_should_halt_at_root_directory
|
315
|
-
File.stubs(:file?).returns(false)
|
316
|
-
Dir.expects(:pwd).times(7).returns(*%w(/bar/baz /bar/baz /bar /bar / / /))
|
317
|
-
Dir.expects(:chdir).with("..").times(3)
|
318
|
-
Dir.expects(:chdir).with("/bar/baz")
|
319
|
-
@cli.args << "-v"
|
320
|
-
@cli.parse_options!
|
321
|
-
assert @cli.options[:recipes].empty?
|
322
|
-
end
|
323
|
-
|
324
|
-
def test_parse_should_instantiate_new_cli_and_call_parse_options
|
325
|
-
cli = mock("cli", :parse_options! => nil)
|
326
|
-
MockCLI.expects(:new).with(%w(a b c)).returns(cli)
|
327
|
-
assert_equal cli, MockCLI.parse(%w(a b c))
|
328
|
-
end
|
329
|
-
end
|
data/test/cli/ui_test.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require "utils"
|
2
|
-
require 'capistrano/cli/ui'
|
3
|
-
|
4
|
-
class CLIUITest < Test::Unit::TestCase
|
5
|
-
class MockCLI
|
6
|
-
include Capistrano::CLI::UI
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_ui_should_return_highline_instance
|
10
|
-
assert_instance_of HighLine, MockCLI.ui
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_password_prompt_should_have_default_prompt_and_set_echo_false
|
14
|
-
q = mock("question")
|
15
|
-
q.expects(:echo=).with(false)
|
16
|
-
ui = mock("ui")
|
17
|
-
ui.expects(:ask).with("Password: ").yields(q).returns("sayuncle")
|
18
|
-
MockCLI.expects(:ui).returns(ui)
|
19
|
-
assert_equal "sayuncle", MockCLI.password_prompt
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_password_prompt_with_custom_prompt_should_use_custom_prompt
|
23
|
-
ui = mock("ui")
|
24
|
-
ui.expects(:ask).with("Give the passphrase: ").returns("sayuncle")
|
25
|
-
MockCLI.expects(:ui).returns(ui)
|
26
|
-
assert_equal "sayuncle", MockCLI.password_prompt("Give the passphrase: ")
|
27
|
-
end
|
28
|
-
end
|
data/test/cli_test.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require "utils"
|
2
|
-
require 'capistrano/cli'
|
3
|
-
|
4
|
-
class CLI_Test < Test::Unit::TestCase
|
5
|
-
def test_options_ui_and_help_modules_should_integrate_successfully_with_configuration
|
6
|
-
cli = Capistrano::CLI.parse(%w(-T -x -X))
|
7
|
-
cli.expects(:puts).at_least_once
|
8
|
-
cli.execute!
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_options_and_execute_modules_should_integrate_successfully_with_configuration
|
12
|
-
path = "#{File.dirname(__FILE__)}/fixtures/cli_integration.rb"
|
13
|
-
cli = Capistrano::CLI.parse(%W(-x -X -q -f #{path} testing))
|
14
|
-
config = cli.execute!
|
15
|
-
assert config[:testing_occurred]
|
16
|
-
end
|
17
|
-
end
|
data/test/command_test.rb
DELETED
@@ -1,289 +0,0 @@
|
|
1
|
-
require "utils"
|
2
|
-
require 'capistrano/command'
|
3
|
-
require 'capistrano/configuration'
|
4
|
-
|
5
|
-
class CommandTest < Test::Unit::TestCase
|
6
|
-
def test_command_should_open_channels_on_all_sessions
|
7
|
-
s1, s2, s3 = mock_session, mock_session, mock_session
|
8
|
-
assert_equal "ls", Capistrano::Command.new("ls", [s1, s2, s3]).tree.fallback.command
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_command_with_newlines_should_be_properly_escaped
|
12
|
-
cmd = Capistrano::Command.new("ls\necho", [mock_session])
|
13
|
-
assert_equal "ls\\\necho", cmd.tree.fallback.command
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_command_with_windows_newlines_should_be_properly_escaped
|
17
|
-
cmd = Capistrano::Command.new("ls\r\necho", [mock_session])
|
18
|
-
assert_equal "ls\\\necho", cmd.tree.fallback.command
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_command_with_pty_should_request_pty_and_register_success_callback
|
22
|
-
session = setup_for_extracting_channel_action(:request_pty, true) do |ch|
|
23
|
-
ch.expects(:exec).with(%(sh -c 'ls'))
|
24
|
-
end
|
25
|
-
Capistrano::Command.new("ls", [session], :pty => true)
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_command_with_env_key_should_have_environment_constructed_and_prepended
|
29
|
-
session = setup_for_extracting_channel_action do |ch|
|
30
|
-
ch.expects(:request_pty).never
|
31
|
-
ch.expects(:exec).with(%(env FOO=bar sh -c 'ls'))
|
32
|
-
end
|
33
|
-
Capistrano::Command.new("ls", [session], :env => { "FOO" => "bar" })
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_env_with_symbolic_key_should_be_accepted_as_a_string
|
37
|
-
session = setup_for_extracting_channel_action do |ch|
|
38
|
-
ch.expects(:exec).with(%(env FOO=bar sh -c 'ls'))
|
39
|
-
end
|
40
|
-
Capistrano::Command.new("ls", [session], :env => { :FOO => "bar" })
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_env_as_string_should_be_substituted_in_directly
|
44
|
-
session = setup_for_extracting_channel_action do |ch|
|
45
|
-
ch.expects(:exec).with(%(env HOWDY=there sh -c 'ls'))
|
46
|
-
end
|
47
|
-
Capistrano::Command.new("ls", [session], :env => "HOWDY=there")
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_env_with_symbolic_value_should_be_accepted_as_string
|
51
|
-
session = setup_for_extracting_channel_action do |ch|
|
52
|
-
ch.expects(:exec).with(%(env FOO=bar sh -c 'ls'))
|
53
|
-
end
|
54
|
-
Capistrano::Command.new("ls", [session], :env => { "FOO" => :bar })
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_env_value_should_be_escaped
|
58
|
-
session = setup_for_extracting_channel_action do |ch|
|
59
|
-
ch.expects(:exec).with(%(env FOO=(\\ \\\"bar\\\"\\ ) sh -c 'ls'))
|
60
|
-
end
|
61
|
-
Capistrano::Command.new("ls", [session], :env => { "FOO" => '( "bar" )' })
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_env_with_multiple_keys_should_chain_the_entries_together
|
65
|
-
session = setup_for_extracting_channel_action do |ch|
|
66
|
-
ch.expects(:exec).with do |command|
|
67
|
-
command =~ /^env / &&
|
68
|
-
command =~ /\ba=b\b/ &&
|
69
|
-
command =~ /\bc=d\b/ &&
|
70
|
-
command =~ /\be=f\b/ &&
|
71
|
-
command =~ / sh -c 'ls'$/
|
72
|
-
end
|
73
|
-
end
|
74
|
-
Capistrano::Command.new("ls", [session], :env => { :a => :b, :c => :d, :e => :f })
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_open_channel_should_set_host_key_on_channel
|
78
|
-
channel = nil
|
79
|
-
session = setup_for_extracting_channel_action { |ch| channel = ch }
|
80
|
-
Capistrano::Command.new("ls", [session])
|
81
|
-
assert_equal "capistrano", channel[:host]
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_open_channel_should_set_options_key_on_channel
|
85
|
-
channel = nil
|
86
|
-
session = setup_for_extracting_channel_action { |ch| channel = ch }
|
87
|
-
Capistrano::Command.new("ls", [session], :data => "here we go")
|
88
|
-
assert_equal({ :data => 'here we go' }, channel[:options])
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_successful_channel_should_send_command
|
92
|
-
session = setup_for_extracting_channel_action do |ch|
|
93
|
-
ch.expects(:exec).with(%(sh -c 'ls'))
|
94
|
-
end
|
95
|
-
Capistrano::Command.new("ls", [session])
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_successful_channel_with_shell_option_should_send_command_via_specified_shell
|
99
|
-
session = setup_for_extracting_channel_action do |ch|
|
100
|
-
ch.expects(:exec).with(%(/bin/bash -c 'ls'))
|
101
|
-
end
|
102
|
-
Capistrano::Command.new("ls", [session], :shell => "/bin/bash")
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_successful_channel_with_shell_false_should_send_command_without_shell
|
106
|
-
session = setup_for_extracting_channel_action do |ch|
|
107
|
-
ch.expects(:exec).with(%(echo `hostname`))
|
108
|
-
end
|
109
|
-
Capistrano::Command.new("echo `hostname`", [session], :shell => false)
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_successful_channel_should_send_data_if_data_key_is_present
|
113
|
-
session = setup_for_extracting_channel_action do |ch|
|
114
|
-
ch.expects(:exec).with(%(sh -c 'ls'))
|
115
|
-
ch.expects(:send_data).with("here we go")
|
116
|
-
end
|
117
|
-
Capistrano::Command.new("ls", [session], :data => "here we go")
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_unsuccessful_pty_request_should_close_channel
|
121
|
-
session = setup_for_extracting_channel_action(:request_pty, false) do |ch|
|
122
|
-
ch.expects(:close)
|
123
|
-
end
|
124
|
-
Capistrano::Command.new("ls", [session], :pty => true)
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_on_data_should_invoke_callback_as_stdout
|
128
|
-
session = setup_for_extracting_channel_action(:on_data, "hello")
|
129
|
-
called = false
|
130
|
-
Capistrano::Command.new("ls", [session]) do |ch, stream, data|
|
131
|
-
called = true
|
132
|
-
assert_equal :out, stream
|
133
|
-
assert_equal "hello", data
|
134
|
-
end
|
135
|
-
assert called
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_on_extended_data_should_invoke_callback_as_stderr
|
139
|
-
session = setup_for_extracting_channel_action(:on_extended_data, 2, "hello")
|
140
|
-
called = false
|
141
|
-
Capistrano::Command.new("ls", [session]) do |ch, stream, data|
|
142
|
-
called = true
|
143
|
-
assert_equal :err, stream
|
144
|
-
assert_equal "hello", data
|
145
|
-
end
|
146
|
-
assert called
|
147
|
-
end
|
148
|
-
|
149
|
-
def test_on_request_should_record_exit_status
|
150
|
-
data = mock(:read_long => 5)
|
151
|
-
channel = nil
|
152
|
-
session = setup_for_extracting_channel_action([:on_request, "exit-status"], data) { |ch| channel = ch }
|
153
|
-
Capistrano::Command.new("ls", [session])
|
154
|
-
assert_equal 5, channel[:status]
|
155
|
-
end
|
156
|
-
|
157
|
-
def test_on_close_should_set_channel_closed
|
158
|
-
channel = nil
|
159
|
-
session = setup_for_extracting_channel_action(:on_close) { |ch| channel = ch }
|
160
|
-
Capistrano::Command.new("ls", [session])
|
161
|
-
assert channel[:closed]
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_stop_should_close_all_open_channels
|
165
|
-
sessions = [mock_session(new_channel(false)),
|
166
|
-
mock_session(new_channel(true)),
|
167
|
-
mock_session(new_channel(false))]
|
168
|
-
|
169
|
-
cmd = Capistrano::Command.new("ls", sessions)
|
170
|
-
cmd.stop!
|
171
|
-
end
|
172
|
-
|
173
|
-
def test_process_should_return_cleanly_if_all_channels_have_zero_exit_status
|
174
|
-
sessions = [mock_session(new_channel(true, 0)),
|
175
|
-
mock_session(new_channel(true, 0)),
|
176
|
-
mock_session(new_channel(true, 0))]
|
177
|
-
cmd = Capistrano::Command.new("ls", sessions)
|
178
|
-
assert_nothing_raised { cmd.process! }
|
179
|
-
end
|
180
|
-
|
181
|
-
def test_process_should_raise_error_if_any_channel_has_non_zero_exit_status
|
182
|
-
sessions = [mock_session(new_channel(true, 0)),
|
183
|
-
mock_session(new_channel(true, 0)),
|
184
|
-
mock_session(new_channel(true, 1))]
|
185
|
-
cmd = Capistrano::Command.new("ls", sessions)
|
186
|
-
assert_raises(Capistrano::CommandError) { cmd.process! }
|
187
|
-
end
|
188
|
-
|
189
|
-
def test_command_error_should_include_accessor_with_host_array
|
190
|
-
sessions = [mock_session(new_channel(true, 0)),
|
191
|
-
mock_session(new_channel(true, 0)),
|
192
|
-
mock_session(new_channel(true, 1))]
|
193
|
-
cmd = Capistrano::Command.new("ls", sessions)
|
194
|
-
|
195
|
-
begin
|
196
|
-
cmd.process!
|
197
|
-
flunk "expected an exception to be raised"
|
198
|
-
rescue Capistrano::CommandError => e
|
199
|
-
assert e.respond_to?(:hosts)
|
200
|
-
assert_equal %w(capistrano), e.hosts.map { |h| h.to_s }
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
def test_process_should_loop_until_all_channels_are_closed
|
205
|
-
new_channel = Proc.new do |times|
|
206
|
-
ch = mock("channel")
|
207
|
-
returns = [false] * (times-1)
|
208
|
-
ch.stubs(:[]).with(:closed).returns(*(returns + [true]))
|
209
|
-
ch.expects(:[]).with(:status).returns(0)
|
210
|
-
ch
|
211
|
-
end
|
212
|
-
|
213
|
-
sessions = [mock_session(new_channel[5]),
|
214
|
-
mock_session(new_channel[10]),
|
215
|
-
mock_session(new_channel[7])]
|
216
|
-
cmd = Capistrano::Command.new("ls", sessions)
|
217
|
-
assert_nothing_raised do
|
218
|
-
cmd.process!
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
def test_process_should_instantiate_command_and_process!
|
223
|
-
cmd = mock("command", :process! => nil)
|
224
|
-
Capistrano::Command.expects(:new).with("ls -l", %w(a b c), {:foo => "bar"}).returns(cmd)
|
225
|
-
Capistrano::Command.process("ls -l", %w(a b c), :foo => "bar")
|
226
|
-
end
|
227
|
-
|
228
|
-
def test_process_with_host_placeholder_should_substitute_placeholder_with_each_host
|
229
|
-
session = setup_for_extracting_channel_action do |ch|
|
230
|
-
ch.expects(:exec).with(%(sh -c 'echo capistrano'))
|
231
|
-
end
|
232
|
-
Capistrano::Command.new("echo $CAPISTRANO:HOST$", [session])
|
233
|
-
end
|
234
|
-
|
235
|
-
def test_process_with_unknown_placeholder_should_not_replace_placeholder
|
236
|
-
session = setup_for_extracting_channel_action do |ch|
|
237
|
-
ch.expects(:exec).with(%(sh -c 'echo $CAPISTRANO:OTHER$'))
|
238
|
-
end
|
239
|
-
Capistrano::Command.new("echo $CAPISTRANO:OTHER$", [session])
|
240
|
-
end
|
241
|
-
|
242
|
-
private
|
243
|
-
|
244
|
-
def mock_session(channel=nil)
|
245
|
-
stub('session',
|
246
|
-
:open_channel => channel,
|
247
|
-
:preprocess => true,
|
248
|
-
:postprocess => true,
|
249
|
-
:listeners => {},
|
250
|
-
:xserver => server("capistrano"))
|
251
|
-
end
|
252
|
-
|
253
|
-
class MockChannel < Hash
|
254
|
-
def close
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
def new_channel(closed, status=nil)
|
259
|
-
ch = MockChannel.new
|
260
|
-
ch.update({ :closed => closed, :host => "capistrano", :server => server("capistrano") })
|
261
|
-
ch[:status] = status if status
|
262
|
-
ch.expects(:close) unless closed
|
263
|
-
ch
|
264
|
-
end
|
265
|
-
|
266
|
-
def setup_for_extracting_channel_action(action=nil, *args)
|
267
|
-
s = server("capistrano")
|
268
|
-
session = mock("session", :xserver => s)
|
269
|
-
|
270
|
-
channel = {}
|
271
|
-
session.expects(:open_channel).yields(channel)
|
272
|
-
|
273
|
-
channel.stubs(:on_data)
|
274
|
-
channel.stubs(:on_extended_data)
|
275
|
-
channel.stubs(:on_request)
|
276
|
-
channel.stubs(:on_close)
|
277
|
-
channel.stubs(:exec)
|
278
|
-
channel.stubs(:send_data)
|
279
|
-
|
280
|
-
if action
|
281
|
-
action = Array(action)
|
282
|
-
channel.expects(action.first).with(*action[1..-1]).yields(channel, *args)
|
283
|
-
end
|
284
|
-
|
285
|
-
yield channel if block_given?
|
286
|
-
|
287
|
-
session
|
288
|
-
end
|
289
|
-
end
|