packer/rpc: get rid of data races in tests

This commit is contained in:
Mitchell Hashimoto 2013-08-21 10:21:32 -07:00
parent 6f742cb332
commit a66085444c
1 changed files with 4 additions and 1 deletions

View File

@ -99,7 +99,10 @@ func TestCommunicatorRPC(t *testing.T) {
c.startCmd.SetExited(42)
for i := 0; i < 5; i++ {
if cmd.Exited {
cmd.Lock()
exited := cmd.Exited
cmd.Unlock()
if exited {
assert.Equal(cmd.ExitStatus, 42, "should have proper exit status")
break
}