Commit 3c59d0ef authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/vmware/common: fix failing tests on Windows

parent 68524a38
...@@ -28,6 +28,9 @@ import ( ...@@ -28,6 +28,9 @@ import (
type StepShutdown struct { type StepShutdown struct {
Command string Command string
Timeout time.Duration Timeout time.Duration
// Set this to true if we're testing
Testing bool
} }
func (s *StepShutdown) Run(state multistep.StateBag) multistep.StepAction { func (s *StepShutdown) Run(state multistep.StateBag) multistep.StepAction {
...@@ -134,7 +137,7 @@ LockWaitLoop: ...@@ -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 // 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 // process is exiting. We just sleep here. In the future, it'd be
// nice to find a better solution to this. // nice to find a better solution to this.
......
...@@ -33,6 +33,7 @@ func TestStepShutdown_command(t *testing.T) { ...@@ -33,6 +33,7 @@ func TestStepShutdown_command(t *testing.T) {
step := new(StepShutdown) step := new(StepShutdown)
step.Command = "foo" step.Command = "foo"
step.Timeout = 10 * time.Second step.Timeout = 10 * time.Second
step.Testing = true
comm := state.Get("communicator").(*packer.MockCommunicator) comm := state.Get("communicator").(*packer.MockCommunicator)
driver := state.Get("driver").(*DriverMock) driver := state.Get("driver").(*DriverMock)
...@@ -116,6 +117,7 @@ func TestStepShutdown_noCommand(t *testing.T) { ...@@ -116,6 +117,7 @@ func TestStepShutdown_noCommand(t *testing.T) {
func TestStepShutdown_locks(t *testing.T) { func TestStepShutdown_locks(t *testing.T) {
state := testStepShutdownState(t) state := testStepShutdownState(t)
step := new(StepShutdown) step := new(StepShutdown)
step.Testing = true
dir := state.Get("dir").(*LocalOutputDir) dir := state.Get("dir").(*LocalOutputDir)
comm := state.Get("communicator").(*packer.MockCommunicator) comm := state.Get("communicator").(*packer.MockCommunicator)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment