@@ -110,28 +110,24 @@ func PrintCurrentTest(t testing.TB, skip ...int) func() {
110110
111111 Printf ("=== %s (%s:%d)\n " , log .NewColoredValue (t .Name ()), strings .TrimPrefix (filename , prefix ), line )
112112
113+ getAllStack := func () string {
114+ stackBuf := make ([]byte , 1024 * 1024 )
115+ n := runtime .Stack (stackBuf , true )
116+ return string (stackBuf [:n ])
117+ }
113118 WriterCloser .pushT (t )
114119 timeoutChecker := time .AfterFunc (TestTimeout , func () {
115- l := 128 * 1024
116- var stack []byte
117- for {
118- stack = make ([]byte , l )
119- n := runtime .Stack (stack , true )
120- if n <= l {
121- stack = stack [:n ]
122- break
123- }
124- l = n
125- }
126- Printf ("!!! %s ... timeout: %v ... stacktrace:\n %s\n \n " , log .NewColoredValue (t .Name (), log .Bold , log .FgRed ), TestTimeout , string (stack ))
120+ Printf ("!!! %s ... timeout: %v ... full stack dump:\n %s\n \n " , log .NewColoredValue (t .Name (), log .Bold , log .FgRed ), TestTimeout , getAllStack ())
127121 })
128122 return func () {
129123 flushStart := time .Now ()
130124 slowFlushChecker := time .AfterFunc (TestSlowFlush , func () {
131125 Printf ("+++ %s ... still flushing after %v ...\n " , log .NewColoredValue (t .Name (), log .Bold , log .FgRed ), TestSlowFlush )
132126 })
133127 if err := queue .GetManager ().FlushAll (t .Context (), - 1 ); err != nil {
134- t .Errorf ("Flushing queues failed with error %v" , err )
128+ t .Errorf ("Flushing queues failed with error: %v" , err )
129+ // usually it is caused by something gets stuck, so dump stacktrace
130+ t .Errorf ("Full stack dump:\n %s" , getAllStack ())
135131 }
136132 slowFlushChecker .Stop ()
137133 timeoutChecker .Stop ()
0 commit comments