Package action cleans up in the event of some environmental error
This commit is contained in:
parent
f8909dcbfa
commit
8168ca3e86
1
Gemfile
1
Gemfile
|
@ -11,6 +11,7 @@ gem "mario", "~> 0.0.6"
|
|||
# Gems required for testing only. To install run
|
||||
# gem bundle test
|
||||
group :test do
|
||||
gem "rake"
|
||||
gem "contest", ">= 0.1.2"
|
||||
gem "mocha"
|
||||
gem "ruby-debug", ">= 0.10.3" if RUBY_VERSION < '1.9'
|
||||
|
|
|
@ -21,6 +21,13 @@ module Vagrant
|
|||
compress
|
||||
|
||||
@app.call(env)
|
||||
|
||||
cleanup if env.error?
|
||||
end
|
||||
|
||||
def cleanup
|
||||
# Cleanup any packaged files if the packaging failed at some point.
|
||||
File.delete(tar_path) if File.exist?(tar_path)
|
||||
end
|
||||
|
||||
def verify_included_files
|
||||
|
|
|
@ -1,10 +1,3 @@
|
|||
begin
|
||||
require File.expand_path('../.bundle/environment', __FILE__)
|
||||
rescue LoadError
|
||||
# Fallback on doing the resolve at runtime.
|
||||
require "rubygems"
|
||||
end
|
||||
|
||||
# ruby-debug, not necessary, but useful if we have it
|
||||
begin
|
||||
require 'ruby-debug'
|
||||
|
|
|
@ -68,6 +68,7 @@ class PackageVMActionTest < Test::Unit::TestCase
|
|||
@instance.expects(:verify_included_files).in_sequence(seq).returns(true)
|
||||
@instance.expects(:compress).in_sequence(seq)
|
||||
@app.expects(:call).with(@env).in_sequence(seq)
|
||||
@instance.expects(:cleanup).never
|
||||
|
||||
@instance.call(@env)
|
||||
end
|
||||
|
@ -88,6 +89,40 @@ class PackageVMActionTest < Test::Unit::TestCase
|
|||
assert @env.error?
|
||||
assert_equal :package_requires_export, @env.error.first
|
||||
end
|
||||
|
||||
should "run cleanup if environment errors" do
|
||||
seq = sequence("seq")
|
||||
@instance.expects(:verify_included_files).in_sequence(seq).returns(true)
|
||||
@instance.expects(:compress).in_sequence(seq)
|
||||
@app.expects(:call).with(@env).in_sequence(seq)
|
||||
@instance.expects(:cleanup).in_sequence(seq)
|
||||
|
||||
@env.error!(:foo)
|
||||
@instance.call(@env)
|
||||
end
|
||||
end
|
||||
|
||||
context "cleaning up" do
|
||||
setup do
|
||||
File.stubs(:exist?).returns(false)
|
||||
File.stubs(:delete)
|
||||
|
||||
@instance.stubs(:tar_path).returns("foo")
|
||||
end
|
||||
|
||||
should "do nothing if the file doesn't exist" do
|
||||
File.expects(:exist?).with(@instance.tar_path).returns(false)
|
||||
File.expects(:delete).never
|
||||
|
||||
@instance.cleanup
|
||||
end
|
||||
|
||||
should "delete the packaged box if it exists" do
|
||||
File.expects(:exist?).returns(true)
|
||||
File.expects(:delete).with(@instance.tar_path).once
|
||||
|
||||
@instance.cleanup
|
||||
end
|
||||
end
|
||||
|
||||
context "verifying included files" do
|
||||
|
|
120
vagrant.gemspec
120
vagrant.gemspec
|
@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|||
|
||||
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
||||
s.authors = ["Mitchell Hashimoto", "John Bender"]
|
||||
s.date = %q{2010-07-17}
|
||||
s.date = %q{2010-07-18}
|
||||
s.default_executable = %q{vagrant}
|
||||
s.description = %q{Vagrant is a tool for building and distributing virtualized development environments.}
|
||||
s.email = ["mitchell.hashimoto@gmail.com", "john.m.bender@gmail.com"]
|
||||
|
@ -208,94 +208,94 @@ Gem::Specification.new do |s|
|
|||
s.homepage = %q{http://github.com/mitchellh/vagrant}
|
||||
s.rdoc_options = ["--charset=UTF-8"]
|
||||
s.require_paths = ["lib"]
|
||||
s.rubygems_version = %q{1.3.6}
|
||||
s.rubygems_version = %q{1.3.7}
|
||||
s.summary = %q{Vagrant is a tool for building and distributing virtualized development environments.}
|
||||
s.test_files = [
|
||||
"test/test_helper.rb",
|
||||
"test/vagrant/vm_test.rb",
|
||||
"test/vagrant/command_test.rb",
|
||||
"test/vagrant/action/box/destroy_test.rb",
|
||||
"test/vagrant/action/box/download_test.rb",
|
||||
"test/vagrant/action/box/unpackage_test.rb",
|
||||
"test/vagrant/action/box/verify_test.rb",
|
||||
"test/vagrant/action/builder_test.rb",
|
||||
"test/vagrant/action/env/error_halt_test.rb",
|
||||
"test/vagrant/action/env/set_test.rb",
|
||||
"test/vagrant/action/environment_test.rb",
|
||||
"test/vagrant/action/exception_catcher_test.rb",
|
||||
"test/vagrant/action/box/verify_test.rb",
|
||||
"test/vagrant/action/box/destroy_test.rb",
|
||||
"test/vagrant/action/box/unpackage_test.rb",
|
||||
"test/vagrant/action/box/download_test.rb",
|
||||
"test/vagrant/action/vm/suspend_test.rb",
|
||||
"test/vagrant/action/vm/boot_test.rb",
|
||||
"test/vagrant/action/vm/package_test.rb",
|
||||
"test/vagrant/action/vm/share_folders_test.rb",
|
||||
"test/vagrant/action/vm/forward_ports_helpers_test.rb",
|
||||
"test/vagrant/action/vm/persist_test.rb",
|
||||
"test/vagrant/action/vm/nfs_test.rb",
|
||||
"test/vagrant/action/vm/clear_nfs_exports_test.rb",
|
||||
"test/vagrant/action/vm/destroy_test.rb",
|
||||
"test/vagrant/action/vm/halt_test.rb",
|
||||
"test/vagrant/action/vm/clear_forwarded_ports_test.rb",
|
||||
"test/vagrant/action/vm/check_guest_additions_test.rb",
|
||||
"test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb",
|
||||
"test/vagrant/action/vm/import_test.rb",
|
||||
"test/vagrant/action/vm/nfs_helpers_test.rb",
|
||||
"test/vagrant/action/vm/customize_test.rb",
|
||||
"test/vagrant/action/vm/network_test.rb",
|
||||
"test/vagrant/action/vm/export_test.rb",
|
||||
"test/vagrant/action/vm/provision_test.rb",
|
||||
"test/vagrant/action/vm/clear_shared_folders_test.rb",
|
||||
"test/vagrant/action/vm/clean_machine_folder_test.rb",
|
||||
"test/vagrant/action/vm/resume_test.rb",
|
||||
"test/vagrant/action/vm/match_mac_address_test.rb",
|
||||
"test/vagrant/action/vm/clear_forwarded_ports_test.rb",
|
||||
"test/vagrant/action/vm/clear_nfs_exports_test.rb",
|
||||
"test/vagrant/action/vm/clear_shared_folders_test.rb",
|
||||
"test/vagrant/action/vm/customize_test.rb",
|
||||
"test/vagrant/action/vm/destroy_test.rb",
|
||||
"test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb",
|
||||
"test/vagrant/action/vm/export_test.rb",
|
||||
"test/vagrant/action/vm/forward_ports_helpers_test.rb",
|
||||
"test/vagrant/action/vm/forward_ports_test.rb",
|
||||
"test/vagrant/action/builder_test.rb",
|
||||
"test/vagrant/action/env/set_test.rb",
|
||||
"test/vagrant/action/env/error_halt_test.rb",
|
||||
"test/vagrant/environment_test.rb",
|
||||
"test/vagrant/util_test.rb",
|
||||
"test/vagrant/action/vm/halt_test.rb",
|
||||
"test/vagrant/action/vm/import_test.rb",
|
||||
"test/vagrant/action/vm/match_mac_address_test.rb",
|
||||
"test/vagrant/action/vm/network_test.rb",
|
||||
"test/vagrant/action/vm/nfs_helpers_test.rb",
|
||||
"test/vagrant/action/vm/nfs_test.rb",
|
||||
"test/vagrant/action/vm/package_test.rb",
|
||||
"test/vagrant/action/vm/persist_test.rb",
|
||||
"test/vagrant/action/vm/provision_test.rb",
|
||||
"test/vagrant/action/vm/resume_test.rb",
|
||||
"test/vagrant/action/vm/share_folders_test.rb",
|
||||
"test/vagrant/action/vm/suspend_test.rb",
|
||||
"test/vagrant/action_test.rb",
|
||||
"test/vagrant/active_list_test.rb",
|
||||
"test/vagrant/box_test.rb",
|
||||
"test/vagrant/busy_test.rb",
|
||||
"test/vagrant/provisioners/base_test.rb",
|
||||
"test/vagrant/provisioners/chef_test.rb",
|
||||
"test/vagrant/provisioners/chef_server_test.rb",
|
||||
"test/vagrant/provisioners/chef_solo_test.rb",
|
||||
"test/vagrant/systems/linux_test.rb",
|
||||
"test/vagrant/config_test.rb",
|
||||
"test/vagrant/hosts/base_test.rb",
|
||||
"test/vagrant/hosts/linux_test.rb",
|
||||
"test/vagrant/hosts/bsd_test.rb",
|
||||
"test/vagrant/active_list_test.rb",
|
||||
"test/vagrant/command_test.rb",
|
||||
"test/vagrant/commands/base_test.rb",
|
||||
"test/vagrant/commands/reload_test.rb",
|
||||
"test/vagrant/commands/ssh_config_test.rb",
|
||||
"test/vagrant/commands/suspend_test.rb",
|
||||
"test/vagrant/commands/package_test.rb",
|
||||
"test/vagrant/commands/status_test.rb",
|
||||
"test/vagrant/commands/init_test.rb",
|
||||
"test/vagrant/commands/destroy_test.rb",
|
||||
"test/vagrant/commands/halt_test.rb",
|
||||
"test/vagrant/commands/box/remove_test.rb",
|
||||
"test/vagrant/commands/box/add_test.rb",
|
||||
"test/vagrant/commands/box/list_test.rb",
|
||||
"test/vagrant/commands/up_test.rb",
|
||||
"test/vagrant/commands/box/remove_test.rb",
|
||||
"test/vagrant/commands/destroy_test.rb",
|
||||
"test/vagrant/commands/halt_test.rb",
|
||||
"test/vagrant/commands/init_test.rb",
|
||||
"test/vagrant/commands/package_test.rb",
|
||||
"test/vagrant/commands/provision_test.rb",
|
||||
"test/vagrant/commands/reload_test.rb",
|
||||
"test/vagrant/commands/resume_test.rb",
|
||||
"test/vagrant/commands/ssh_config_test.rb",
|
||||
"test/vagrant/commands/ssh_test.rb",
|
||||
"test/vagrant/resource_logger_test.rb",
|
||||
"test/vagrant/commands/status_test.rb",
|
||||
"test/vagrant/commands/suspend_test.rb",
|
||||
"test/vagrant/commands/up_test.rb",
|
||||
"test/vagrant/config_test.rb",
|
||||
"test/vagrant/downloaders/base_test.rb",
|
||||
"test/vagrant/downloaders/file_test.rb",
|
||||
"test/vagrant/downloaders/http_test.rb",
|
||||
"test/vagrant/environment_test.rb",
|
||||
"test/vagrant/hosts/base_test.rb",
|
||||
"test/vagrant/hosts/bsd_test.rb",
|
||||
"test/vagrant/hosts/linux_test.rb",
|
||||
"test/vagrant/provisioners/base_test.rb",
|
||||
"test/vagrant/provisioners/chef_server_test.rb",
|
||||
"test/vagrant/provisioners/chef_solo_test.rb",
|
||||
"test/vagrant/provisioners/chef_test.rb",
|
||||
"test/vagrant/resource_logger_test.rb",
|
||||
"test/vagrant/ssh_session_test.rb",
|
||||
"test/vagrant/ssh_test.rb",
|
||||
"test/vagrant/systems/linux_test.rb",
|
||||
"test/vagrant/util/plain_logger_test.rb",
|
||||
"test/vagrant/util/platform_test.rb",
|
||||
"test/vagrant/util/stacked_proc_runner_test.rb",
|
||||
"test/vagrant/util/template_renderer_test.rb",
|
||||
"test/vagrant/util/translator_test.rb",
|
||||
"test/vagrant/util/platform_test.rb",
|
||||
"test/vagrant/util/plain_logger_test.rb",
|
||||
"test/vagrant/ssh_session_test.rb",
|
||||
"test/vagrant/action_test.rb",
|
||||
"test/vagrant/ssh_test.rb"
|
||||
"test/vagrant/util_test.rb",
|
||||
"test/vagrant/vm_test.rb"
|
||||
]
|
||||
|
||||
if s.respond_to? :specification_version then
|
||||
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
||||
s.specification_version = 3
|
||||
|
||||
if Gem::Version.new(Gem::RubyGemsVersion) >= 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<virtualbox>, ["~> 0.7.3"])
|
||||
s.add_runtime_dependency(%q<net-ssh>, [">= 2.0.19"])
|
||||
s.add_runtime_dependency(%q<net-scp>, [">= 1.0.2"])
|
||||
|
|
Loading…
Reference in New Issue