From 56a6c85e7df482c922910c941c2dda7bfd1250c8 Mon Sep 17 00:00:00 2001 From: Richard Guin Date: Wed, 28 Jan 2015 13:07:36 -0500 Subject: [PATCH] Windows rsync needs to create folders before syncing --- plugins/guests/windows/cap/rsync.rb | 13 ++++++++++ plugins/guests/windows/plugin.rb | 5 ++++ .../plugins/guests/windows/cap/rsync_test.rb | 26 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 plugins/guests/windows/cap/rsync.rb create mode 100644 test/unit/plugins/guests/windows/cap/rsync_test.rb diff --git a/plugins/guests/windows/cap/rsync.rb b/plugins/guests/windows/cap/rsync.rb new file mode 100644 index 000000000..e391b92db --- /dev/null +++ b/plugins/guests/windows/cap/rsync.rb @@ -0,0 +1,13 @@ +module VagrantPlugins + module GuestWindows + module Cap + class RSync + def self.rsync_pre(machine, opts) + machine.communicate.tap do |comm| + comm.execute("mkdir '#{opts[:guestpath]}'") + end + end + end + end + end +end diff --git a/plugins/guests/windows/plugin.rb b/plugins/guests/windows/plugin.rb index fd70ae4a6..47ca67e3f 100644 --- a/plugins/guests/windows/plugin.rb +++ b/plugins/guests/windows/plugin.rb @@ -64,6 +64,11 @@ module VagrantPlugins Cap::MountSharedFolder end + guest_capability(:windows, :rsync_pre) do + require_relative "cap/rsync" + Cap::RSync + end + protected def self.init! diff --git a/test/unit/plugins/guests/windows/cap/rsync_test.rb b/test/unit/plugins/guests/windows/cap/rsync_test.rb new file mode 100644 index 000000000..e28a5b3fb --- /dev/null +++ b/test/unit/plugins/guests/windows/cap/rsync_test.rb @@ -0,0 +1,26 @@ +require File.expand_path("../../../../../base", __FILE__) + +require Vagrant.source_root.join("plugins/guests/windows/cap/rsync") + +describe "VagrantPlugins::GuestWindows::Cap::RSync" do + let(:described_class) do + VagrantPlugins::GuestWindows::Plugin.components.guest_capabilities[:windows].get(:rsync_pre) + end + let(:machine) { double("machine") } + let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) } + + before do + allow(machine).to receive(:communicate).and_return(communicator) + end + + after do + communicator.verify_expectations! + end + + describe ".rsync_pre" do + it 'makes the guestpath directory with mkdir' do + communicator.expect_command("mkdir '/sync_dir'") + described_class.rsync_pre(machine, guestpath: '/sync_dir') + end + end +end