diff --git a/plugins/guests/windows/cap/reboot.rb b/plugins/guests/windows/cap/reboot.rb index 070f4ea80..452042f82 100644 --- a/plugins/guests/windows/cap/reboot.rb +++ b/plugins/guests/windows/cap/reboot.rb @@ -21,6 +21,8 @@ module VagrantPlugins @logger.debug("A reboot is already in progress") end + machine.ui.info(I18n.t("vagrant.guests.capabilities.rebooting")) + @logger.debug("Waiting for machine to finish rebooting") wait_remaining = MAX_REBOOT_RETRY_DURATION diff --git a/templates/locales/en.yml b/templates/locales/en.yml index fe2a80115..04345c7ea 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1922,6 +1922,14 @@ en: path of the shared folder must be located on a file system with DrvFs type. Host path: %{path} +#------------------------------------------------------------------------------- +# Translations for guests +#------------------------------------------------------------------------------- + guests: + capabilities: + rebooting: |- + Waiting for machine to reboot... + #------------------------------------------------------------------------------- # Translations for commands. e.g. `vagrant x` #------------------------------------------------------------------------------- diff --git a/test/unit/plugins/guests/windows/cap/reboot_test.rb b/test/unit/plugins/guests/windows/cap/reboot_test.rb index ab7549445..6b6efc88d 100644 --- a/test/unit/plugins/guests/windows/cap/reboot_test.rb +++ b/test/unit/plugins/guests/windows/cap/reboot_test.rb @@ -8,9 +8,10 @@ describe "VagrantPlugins::GuestWindows::Cap::Reboot" do end let(:vm) { double("vm") } let(:config) { double("config") } - let(:machine) { double("machine") } + let(:machine) { double("machine", ui: ui) } let(:guest) { double("guest") } let(:communicator) { double("communicator") } + let(:ui) { double("ui") } before do allow(machine).to receive(:communicate).and_return(communicator) @@ -18,6 +19,7 @@ describe "VagrantPlugins::GuestWindows::Cap::Reboot" do allow(machine.guest).to receive(:ready?).and_return(true) allow(machine).to receive(:config).and_return(config) allow(config).to receive(:vm).and_return(vm) + allow(ui).to receive(:info) end describe ".reboot" do @@ -26,13 +28,27 @@ describe "VagrantPlugins::GuestWindows::Cap::Reboot" do end it "reboots the vm" do + allow(communicator).to receive(:execute) + + expect(communicator).to receive(:test).with(/# Function/, { error_check: false, shell: :powershell }).and_return(0) + expect(communicator).to receive(:execute).with(/shutdown/, { shell: :powershell }).and_return(0) + expect(described_class).to receive(:wait_for_reboot) + + described_class.reboot(machine) + end + + context "user output" do + before do allow(communicator).to receive(:execute) + allow(described_class).to receive(:wait_for_reboot) + end - expect(communicator).to receive(:test).with(/# Function/, { error_check: false, shell: :powershell }).and_return(0) - expect(communicator).to receive(:execute).with(/shutdown/, { shell: :powershell }).and_return(0) - expect(described_class).to receive(:wait_for_reboot) + after { described_class.reboot(machine) } - described_class.reboot(machine) + it "sends message to user that guest is rebooting" do + expect(communicator).to receive(:test).and_return(true) + expect(ui).to receive(:info) + end end end