File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,8 @@ retry:
104104 }
105105 select {
106106 case <- ctx .Done ():
107- return nil , ctx .Err ()
107+ log .Warnf ("did not acquire lock: %s" , ctx .Err ())
108+ return nil , err
108109 case <- ticker .C :
109110 goto retry
110111 }
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package fslock_test
33import (
44 "bufio"
55 "context"
6- "errors"
76 "os"
87 "os/exec"
98 "path/filepath"
@@ -158,6 +157,7 @@ func TestWaitLock(t *testing.T) {
158157 someFile = "somefile"
159158 permErr = "permission denied"
160159 heldErr = "lock is already held by us"
160+ wantErr = "someone else has the lock"
161161 )
162162
163163 confdir := t .TempDir ()
@@ -259,7 +259,11 @@ func TestWaitLock(t *testing.T) {
259259 if err == nil {
260260 t .Fatalf ("parent successfully acquired the lock" )
261261 }
262- if ! errors .Is (err , context .DeadlineExceeded ) {
263- t .Fatalf ("did not get expected error: %s" , context .DeadlineExceeded )
262+ pe , ok = err .(* os.PathError )
263+ if ! ok {
264+ t .Fatalf ("wrong error type %T" , err )
265+ }
266+ if got := pe .Error (); ! strings .Contains (got , wantErr ) {
267+ t .Fatalf ("error %q does not contain %q" , got , wantErr )
264268 }
265269}
You can’t perform that action at this time.
0 commit comments