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:
104
104
}
105
105
select {
106
106
case <- ctx .Done ():
107
- return nil , ctx .Err ()
107
+ log .Warnf ("did not acquire lock: %s" , ctx .Err ())
108
+ return nil , err
108
109
case <- ticker .C :
109
110
goto retry
110
111
}
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package fslock_test
3
3
import (
4
4
"bufio"
5
5
"context"
6
- "errors"
7
6
"os"
8
7
"os/exec"
9
8
"path/filepath"
@@ -158,6 +157,7 @@ func TestWaitLock(t *testing.T) {
158
157
someFile = "somefile"
159
158
permErr = "permission denied"
160
159
heldErr = "lock is already held by us"
160
+ wantErr = "someone else has the lock"
161
161
)
162
162
163
163
confdir := t .TempDir ()
@@ -259,7 +259,11 @@ func TestWaitLock(t *testing.T) {
259
259
if err == nil {
260
260
t .Fatalf ("parent successfully acquired the lock" )
261
261
}
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 )
264
268
}
265
269
}
You can’t perform that action at this time.
0 commit comments