From bad251a20d00624cf6c15dfd6db74f06c7d59c19 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 30 Sep 2010 01:16:45 -0700 Subject: [PATCH] NFS no longer attempts to clean exports file if VM is not created, which caused a stack trace during recovery. --- CHANGELOG.md | 2 ++ lib/vagrant/action/vm/nfs.rb | 2 +- test/vagrant/action/vm/nfs_test.rb | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d74421af6..24864f14c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.6.4 (unreleased) + - NFS no longer attempts to clean exports file if VM is not created, + which was causing a stack trace during recovery. [related to GH-166] - Basic validation added for Chef configuration (both solo and server). - Top config class is now available in all `Vagrant::Config::Base` subclasses, which is useful for config validation. diff --git a/lib/vagrant/action/vm/nfs.rb b/lib/vagrant/action/vm/nfs.rb index 193b5b933..d44e3d7d2 100644 --- a/lib/vagrant/action/vm/nfs.rb +++ b/lib/vagrant/action/vm/nfs.rb @@ -42,7 +42,7 @@ module Vagrant end def recover(env) - clear_nfs_exports(env) + clear_nfs_exports(env) if env["vm"].created? end # Returns the folders which are to be synced via NFS. diff --git a/test/vagrant/action/vm/nfs_test.rb b/test/vagrant/action/vm/nfs_test.rb index 810bee84b..fb59d0dcd 100644 --- a/test/vagrant/action/vm/nfs_test.rb +++ b/test/vagrant/action/vm/nfs_test.rb @@ -68,10 +68,20 @@ class NFSVMActionTest < Test::Unit::TestCase end context "recovery" do + setup do + @vm.stubs(:created?).returns(true) + end + should "clear NFS exports" do @instance.expects(:clear_nfs_exports).with(@env).once @instance.recover(@env) end + + should "do nothing if VM is not created" do + @vm.stubs(:created?).returns(false) + @instance.expects(:clear_nfs_exports).never + @instance.recover(@env) + end end context "extracting folders" do