Merge pull request #16636 from Microsoft/setrunninglocking

Move setRunningLocking to test code
This commit is contained in:
David Calavera 2015-09-28 14:25:32 -07:00
commit 79dd76b602
2 changed files with 7 additions and 9 deletions

View File

@ -121,7 +121,7 @@ func wait(waitChan <-chan struct{}, timeout time.Duration) error {
// waitRunning waits until state is running. If state is already
// running it returns immediately. If you want wait forever you must
// supply negative timeout. Returns pid, that was passed to
// setRunningLocking.
// setRunning.
func (s *State) waitRunning(timeout time.Duration) (int, error) {
s.Lock()
if s.Running {
@ -178,12 +178,6 @@ func (s *State) getExitCode() int {
return res
}
func (s *State) setRunningLocking(pid int) {
s.Lock()
s.setRunning(pid)
s.Unlock()
}
func (s *State) setRunning(pid int) {
s.Error = ""
s.Running = true

View File

@ -18,7 +18,9 @@ func TestStateRunStop(t *testing.T) {
atomic.StoreInt64(&pid, int64(runPid))
close(started)
}()
s.setRunningLocking(i + 100)
s.Lock()
s.setRunning(i + 100)
s.Unlock()
if !s.IsRunning() {
t.Fatal("State not running")
@ -90,7 +92,9 @@ func TestStateTimeoutWait(t *testing.T) {
t.Log("Start callback fired")
}
s.setRunningLocking(42)
s.Lock()
s.setRunning(49)
s.Unlock()
stopped := make(chan struct{})
go func() {