Export action now cleans up and rescues. Package no longer cleans up temporary directory.
This commit is contained in:
parent
e50e264747
commit
5dd3e51788
|
@ -9,6 +9,17 @@ module Vagrant
|
|||
export
|
||||
end
|
||||
|
||||
def cleanup
|
||||
if temp_dir
|
||||
logger.info "Removing temporary export directory..."
|
||||
FileUtils.rm_r(temp_dir)
|
||||
end
|
||||
end
|
||||
|
||||
def rescue(exception)
|
||||
cleanup
|
||||
end
|
||||
|
||||
def setup_temp_dir
|
||||
@temp_dir = File.join(Env.tmp_path, Time.now.to_i.to_s)
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ module Vagrant
|
|||
@temp_path = nil
|
||||
end
|
||||
|
||||
def prepare
|
||||
def prepare
|
||||
@include_files.each do |file|
|
||||
raise ActionException.new("#{file} does not exist") unless File.exists?(file)
|
||||
end
|
||||
|
@ -21,12 +21,6 @@ module Vagrant
|
|||
|
||||
def execute!
|
||||
compress
|
||||
clean
|
||||
end
|
||||
|
||||
def clean
|
||||
logger.info "Removing temporary directory ..."
|
||||
FileUtils.rm_r(temp_path)
|
||||
end
|
||||
|
||||
def tar_path
|
||||
|
|
|
@ -65,4 +65,29 @@ class ExportActionTest < Test::Unit::TestCase
|
|||
@action.export
|
||||
end
|
||||
end
|
||||
|
||||
context "cleanup" do
|
||||
setup do
|
||||
@temp_dir = "foo"
|
||||
@action.stubs(:temp_dir).returns(@temp_dir)
|
||||
end
|
||||
|
||||
should "remove the temporary directory" do
|
||||
FileUtils.expects(:rm_r).with(@temp_dir).once
|
||||
@action.cleanup
|
||||
end
|
||||
|
||||
should "not remove a directory if temp_dir is nil" do
|
||||
FileUtils.expects(:rm_r).never
|
||||
@action.stubs(:temp_dir).returns(nil)
|
||||
@action.cleanup
|
||||
end
|
||||
end
|
||||
|
||||
context "rescue" do
|
||||
should "call cleanup method" do
|
||||
@action.expects(:cleanup).once
|
||||
@action.rescue(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,29 +29,15 @@ class PackageActionTest < Test::Unit::TestCase
|
|||
context "executing" do
|
||||
setup do
|
||||
@action.stubs(:compress)
|
||||
@action.stubs(:clean)
|
||||
end
|
||||
|
||||
should "compress and remove the working directory" do
|
||||
should "compress" do
|
||||
package_seq = sequence("package_seq")
|
||||
@action.expects(:compress).in_sequence(package_seq)
|
||||
@action.expects(:clean).in_sequence(package_seq)
|
||||
@action.execute!
|
||||
end
|
||||
end
|
||||
|
||||
context "cleaning up" do
|
||||
setup do
|
||||
@working_dir = "foo"
|
||||
@action.stubs(:working_dir).returns(@working_dir)
|
||||
end
|
||||
|
||||
should "remove the working directory" do
|
||||
FileUtils.expects(:rm_r).with(@temp_path).once
|
||||
@action.clean
|
||||
end
|
||||
end
|
||||
|
||||
context "tar path" do
|
||||
should "be the temporary directory with the name and extension attached" do
|
||||
pwd = "foo"
|
||||
|
|
Loading…
Reference in New Issue