From cf1cc1fb72b11343915d7a900fd0b43ea5b3a1e8 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 7 Apr 2023 19:51:31 +0200 Subject: [PATCH] lock: Print stacktrace if TestLockSuccessfulRefresh fails --- cmd/restic/lock_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/restic/lock_test.go b/cmd/restic/lock_test.go index 242252f42..fd3af0724 100644 --- a/cmd/restic/lock_test.go +++ b/cmd/restic/lock_test.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + "runtime" "testing" "time" @@ -165,6 +166,13 @@ func TestLockSuccessfulRefresh(t *testing.T) { case <-wrappedCtx.Done(): // don't call t.Fatal to allow the lock to be properly cleaned up t.Error("lock refresh failed", time.Now()) + + // Dump full stacktrace + buf := make([]byte, 1024*1024) + n := runtime.Stack(buf, true) + buf = buf[:n] + t.Log(string(buf)) + case <-time.After(2 * refreshabilityTimeout): // expected lock refresh to work }