diff options
| author | lhchavez <[email protected]> | 2020-12-10 05:35:40 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-12-10 05:35:40 -0800 |
| commit | e28cce87c7551bffa1f4602ff492348f9a8cba60 (patch) | |
| tree | 17cda66f878bd6285f24d0867c444e9ca2e191e6 /git_test.go | |
| parent | abf02bc7d79dfb7b0bbcd404ebecb202cff2a18e (diff) | |
Ensure that no pointer handles leak during the test (#712)
This change makes sure that pointer handles are correctly cleaned up
during tests.
Diffstat (limited to 'git_test.go')
| -rw-r--r-- | git_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/git_test.go b/git_test.go index 1bd311a..1c57f79 100644 --- a/git_test.go +++ b/git_test.go @@ -1,13 +1,33 @@ package git import ( + "fmt" "io/ioutil" "os" "path" + "reflect" "testing" "time" ) +func TestMain(m *testing.M) { + ret := m.Run() + + // Ensure that we are not leaking any pointer handles. + pointerHandles.Lock() + if len(pointerHandles.handles) > 0 { + for h, ptr := range pointerHandles.handles { + fmt.Printf("%016p: %v %+v\n", h, reflect.TypeOf(ptr), ptr) + } + panic("pointer handle list not empty") + } + pointerHandles.Unlock() + + Shutdown() + + os.Exit(ret) +} + func cleanupTestRepo(t *testing.T, r *Repository) { var err error if r.IsBare() { |
