From e8fd57fbbb74d5033393aa43f0372403dca3cdda Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 20 Jun 2010 14:14:11 -0700 Subject: [PATCH] Fixes to unison. Now tested and working. --- lib/vagrant/actions/vm/shared_folders.rb | 3 +++ templates/unison/script.erb | 2 +- test/vagrant/actions/vm/shared_folders_test.rb | 14 +++++++++++++- vagrant.gemspec | 6 +++--- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/vagrant/actions/vm/shared_folders.rb b/lib/vagrant/actions/vm/shared_folders.rb index ec8486ca7..f18ca639c 100644 --- a/lib/vagrant/actions/vm/shared_folders.rb +++ b/lib/vagrant/actions/vm/shared_folders.rb @@ -8,6 +8,9 @@ module Vagrant runner.env.config.vm.shared_folders.inject({}) do |acc, data| key, value = data + # This to prevent overwriting the actual shared folders data + value = value.dup + if value[:sync] # Syncing this folder. Change the guestpath to reflect # what we're actually mounting. diff --git a/templates/unison/script.erb b/templates/unison/script.erb index 645b68e9a..4e70ac5c6 100644 --- a/templates/unison/script.erb +++ b/templates/unison/script.erb @@ -45,7 +45,7 @@ echo $$ > "${LOCK_FILE}" while [ 1 ]; do echo 'Syncing...' # TODO check result and output log data... somewhere! - unison $1 $2 $3 + sudo unison $1 $2 $3 > unison.log 2>&1 sleep 1 done diff --git a/test/vagrant/actions/vm/shared_folders_test.rb b/test/vagrant/actions/vm/shared_folders_test.rb index a1fc50da6..bc86a98bc 100644 --- a/test/vagrant/actions/vm/shared_folders_test.rb +++ b/test/vagrant/actions/vm/shared_folders_test.rb @@ -81,6 +81,17 @@ class SharedFoldersActionTest < Test::Unit::TestCase assert_equal "#{guest}#{@runner.env.config.unison.folder_suffix}", result[name][:guestpath] assert_equal guest, result[name][:original][:guestpath] end + + should "not destroy original hash" do + @folders = stub_shared_folders do |config| + config.vm.share_folder("foo", "bar", "baz", :sync => true) + end + + folder = @folders["foo"].dup + + @action.shared_folders + assert_equal folder, @runner.env.config.vm.shared_folders["foo"] + end end context "unison shared folders" do @@ -183,11 +194,12 @@ class SharedFoldersActionTest < Test::Unit::TestCase should "prepare unison then create for each folder" do seq = sequence("unison seq") @runner.system.expects(:prepare_unison).with(@ssh).once.in_sequence(seq) - @folders.each do |name, data| + @action.unison_folders.each do |name, data| if data[:sync] @runner.system.expects(:create_unison).with do |ssh, opts| assert_equal @ssh, ssh assert_equal data, opts + true end end diff --git a/vagrant.gemspec b/vagrant.gemspec index 95ab3f7a5..577d9a330 100644 --- a/vagrant.gemspec +++ b/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-06-17} + s.date = %q{2010-06-20} 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"] @@ -106,12 +106,12 @@ Gem::Specification.new do |s| "templates/Vagrantfile.erb", "templates/chef_server_client.erb", "templates/chef_solo_solo.erb", - "templates/crontab_entry.erb", "templates/network_entry.erb", "templates/package_Vagrantfile.erb", "templates/ssh_config.erb", "templates/strings.yml", - "templates/sync.erb", + "templates/unison/crontab_entry.erb", + "templates/unison/script.erb", "test/test_helper.rb", "test/vagrant/actions/base_test.rb", "test/vagrant/actions/box/add_test.rb",