diff --git a/builder/vmware/common/step_shutdown.go b/builder/vmware/common/step_shutdown.go index 92516730e..378d699b1 100644 --- a/builder/vmware/common/step_shutdown.go +++ b/builder/vmware/common/step_shutdown.go @@ -28,6 +28,9 @@ import ( type StepShutdown struct { Command string Timeout time.Duration + + // Set this to true if we're testing + Testing bool } func (s *StepShutdown) Run(state multistep.StateBag) multistep.StepAction { @@ -134,7 +137,7 @@ LockWaitLoop: } } - if runtime.GOOS == "windows" { + if runtime.GOOS == "windows" && !s.Testing { // Windows takes a while to yield control of the files when the // process is exiting. We just sleep here. In the future, it'd be // nice to find a better solution to this. diff --git a/builder/vmware/common/step_shutdown_test.go b/builder/vmware/common/step_shutdown_test.go index 531bfc34b..b3c13a9f6 100644 --- a/builder/vmware/common/step_shutdown_test.go +++ b/builder/vmware/common/step_shutdown_test.go @@ -33,6 +33,7 @@ func TestStepShutdown_command(t *testing.T) { step := new(StepShutdown) step.Command = "foo" step.Timeout = 10 * time.Second + step.Testing = true comm := state.Get("communicator").(*packer.MockCommunicator) driver := state.Get("driver").(*DriverMock) @@ -116,6 +117,7 @@ func TestStepShutdown_noCommand(t *testing.T) { func TestStepShutdown_locks(t *testing.T) { state := testStepShutdownState(t) step := new(StepShutdown) + step.Testing = true dir := state.Get("dir").(*LocalOutputDir) comm := state.Get("communicator").(*packer.MockCommunicator)