mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-12 11:15:00 +02:00
33 lines
486 B
Go
33 lines
486 B
Go
package lo
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// https://github.com/stretchr/testify/issues/1101
|
|
func testWithTimeout(t *testing.T, timeout time.Duration) {
|
|
t.Helper()
|
|
|
|
testFinished := make(chan struct{})
|
|
t.Cleanup(func() { close(testFinished) })
|
|
|
|
go func() {
|
|
select {
|
|
case <-testFinished:
|
|
case <-time.After(timeout):
|
|
t.Errorf("test timed out after %s", timeout)
|
|
os.Exit(1)
|
|
}
|
|
}()
|
|
}
|
|
|
|
type foo struct {
|
|
bar string
|
|
}
|
|
|
|
func (f foo) Clone() foo {
|
|
return foo{f.bar}
|
|
}
|