mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
2e13a1319c
This removes the dependency on the `kuroko` gem and uses the Vagrant command line application to control the virtual environment. The `vagrant` command should be in your path, but if it isn't the path can be set with the `VAGRANT_BIN` environment variable. This may even work on older versions of Vagrant, but they are untested. The `VagrantHelpers` module was added to mimic some of the API that was provided by `kuroko`. The `RemoteCommandHelpers` module was modified to accommodate those changes. Any non-zero exit status on a remote command will raise a `VagrantHelpers::VagrantSSHCommandError` and should be expected by any tests using the command helpers. All existing tests work as expected. In addition, a couple of minor changes were made. The TestApp utilizes the Pathname library but does not require it. This was causing the suite to fail for me so I added an explicit require. Also, the test for the existence of a release directory would give a false positive on subsequent runs if the `KEEP_RUNNING` option was used. I added an `at_exit` that removes the test deployment directory to clean up the box for the next run. Documentation was also added to the README for how to run the test suites.
35 lines
769 B
Ruby
35 lines
769 B
Ruby
module VagrantHelpers
|
|
extend self
|
|
|
|
class VagrantSSHCommandError < RuntimeError; end
|
|
|
|
at_exit do
|
|
if ENV['KEEP_RUNNING']
|
|
puts "Vagrant vm will be left up because KEEP_RUNNING is set."
|
|
puts "Rerun without KEEP_RUNNING set to cleanup the vm."
|
|
else
|
|
vagrant_cli_command("destroy -f")
|
|
end
|
|
end
|
|
|
|
def vagrant_cli_command(command)
|
|
puts "[vagrant] #{command}"
|
|
Dir.chdir(VAGRANT_ROOT) do
|
|
`#{VAGRANT_BIN} #{command} 2>&1`.split("\n").each do |line|
|
|
puts "[vagrant] #{line}"
|
|
end
|
|
end
|
|
$?
|
|
end
|
|
|
|
def run_vagrant_command(command)
|
|
if (status = vagrant_cli_command("ssh -c #{command.inspect}")).success?
|
|
true
|
|
else
|
|
fail VagrantSSHCommandError, status
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
World(VagrantHelpers)
|