Skip to content

Commit

Permalink
making sure to lock when touching the promise.cmd property
Browse files Browse the repository at this point in the history
  • Loading branch information
zabawaba99 committed Jan 29, 2016
1 parent 309c670 commit 845f674
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions vow/promise.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ func (p *promise) Run(w io.Writer, verbose bool) (err error) {
}

func (p *promise) wait(w io.Writer, verbose bool, buf *syncBuffer) error {
p.cmdMtx.Lock()
err := p.cmd.Wait()
p.cmdMtx.Unlock()

status := statusPassed
if err != nil {
Expand Down
8 changes: 5 additions & 3 deletions vow/to_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ func TestStopAsync(t *testing.T) {
<-time.After(10 * time.Millisecond)

vow.Stop()
for _, cmd := range vow.cmds {
cmd.cmd.Wait()
assert.True(t, cmd.cmd.ProcessState.Exited())
for _, p := range vow.cmds {
p.cmdMtx.Lock()
p.cmd.Wait()
assert.True(t, p.cmd.ProcessState.Exited())
p.cmdMtx.Unlock()
}
}

Expand Down

0 comments on commit 845f674

Please sign in to comment.