Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2020-11-12 15:09:36 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-11-17 10:07:45 +0300
commit169ca21e6d52d6e6548a6d8e51d11021fff6a246 (patch)
treec330082a3f0374b9294a958c58daa115e375da70
parent3d2d90b0b58d9fea04f26eee3ca402e5fdb919f7 (diff)
testhelper: Have Configure() return cleanup function
During tests we're accumulating quite some global data, some of which is hard to clean up separately. As we don't have any shared global test directory in which we can put all generated test data, they're thus all over `/tmp` and never get cleaned up. As a result, after a few runs the temporary directory will be cluttered by thousands of files and directories generated by our test suite. This commit is a preparation for such a global unified test directory, which is going to be set up by `testhelper.Configure()`. In order to assure it'll get cleaned up, we add a (still empty) cleanup function and adjust all callers to invoke it. This function will at a later point be used to delete the temporary test directory.
-rw-r--r--cmd/gitaly-git2go/conflicts/conflicts_test.go3
-rw-r--r--cmd/gitaly-git2go/main_test.go3
-rw-r--r--cmd/gitaly-hooks/hooks_test.go3
-rw-r--r--cmd/gitaly-ssh/testhelper_test.go3
-rw-r--r--internal/cache/cachedb_test.go3
-rw-r--r--internal/git/catfile/testhelper_test.go3
-rw-r--r--internal/git/helper_test.go3
-rw-r--r--internal/git/log/commit_test.go3
-rw-r--r--internal/git/objectpool/testhelper_test.go3
-rw-r--r--internal/git/packfile/packfile_test.go3
-rw-r--r--internal/git/remote/remote_test.go3
-rw-r--r--internal/git/stats/testhelper_test.go3
-rw-r--r--internal/git/updateref/updateref_test.go3
-rw-r--r--internal/git2go/commit_test.go3
-rw-r--r--internal/gitaly/hook/testhelper_test.go3
-rw-r--r--internal/gitaly/linguist/linguist_test.go3
-rw-r--r--internal/gitaly/rubyserver/testhelper_test.go3
-rw-r--r--internal/gitaly/server/auth_test.go3
-rw-r--r--internal/gitaly/service/blob/testhelper_test.go3
-rw-r--r--internal/gitaly/service/cleanup/testhelper_test.go3
-rw-r--r--internal/gitaly/service/commit/testhelper_test.go3
-rw-r--r--internal/gitaly/service/conflicts/testhelper_test.go3
-rw-r--r--internal/gitaly/service/diff/testhelper_test.go3
-rw-r--r--internal/gitaly/service/hook/testhelper_test.go3
-rw-r--r--internal/gitaly/service/namespace/namespace_test.go3
-rw-r--r--internal/gitaly/service/objectpool/testhelper_test.go3
-rw-r--r--internal/gitaly/service/operations/testhelper_test.go3
-rw-r--r--internal/gitaly/service/ref/testhelper_test.go3
-rw-r--r--internal/gitaly/service/remote/testhelper_test.go3
-rw-r--r--internal/gitaly/service/repository/testhelper_test.go3
-rw-r--r--internal/gitaly/service/smarthttp/testhelper_test.go3
-rw-r--r--internal/gitaly/service/ssh/testhelper_test.go3
-rw-r--r--internal/gitaly/service/wiki/testhelper_test.go3
-rw-r--r--internal/gitalyssh/testhelper_test.go3
-rw-r--r--internal/helper/repo_test.go3
-rw-r--r--internal/middleware/commandstatshandler/commandstatshandler_test.go3
-rw-r--r--internal/praefect/replicator_test.go3
-rw-r--r--internal/tempdir/testhelper_test.go3
-rw-r--r--internal/testhelper/testhelper.go4
39 files changed, 79 insertions, 39 deletions
diff --git a/cmd/gitaly-git2go/conflicts/conflicts_test.go b/cmd/gitaly-git2go/conflicts/conflicts_test.go
index 0dabd0d84..a91a73027 100644
--- a/cmd/gitaly-git2go/conflicts/conflicts_test.go
+++ b/cmd/gitaly-git2go/conflicts/conflicts_test.go
@@ -19,7 +19,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
testhelper.ConfigureGitalyGit2Go()
return m.Run()
}
diff --git a/cmd/gitaly-git2go/main_test.go b/cmd/gitaly-git2go/main_test.go
index fc4909771..1c863380a 100644
--- a/cmd/gitaly-git2go/main_test.go
+++ b/cmd/gitaly-git2go/main_test.go
@@ -15,7 +15,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
testhelper.ConfigureGitalyGit2Go()
return m.Run()
}
diff --git a/cmd/gitaly-hooks/hooks_test.go b/cmd/gitaly-hooks/hooks_test.go
index fe76b37be..98c04a36c 100644
--- a/cmd/gitaly-hooks/hooks_test.go
+++ b/cmd/gitaly-hooks/hooks_test.go
@@ -32,7 +32,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
defer func(rubyDir string) {
config.Config.Ruby.Dir = rubyDir
diff --git a/cmd/gitaly-ssh/testhelper_test.go b/cmd/gitaly-ssh/testhelper_test.go
index edccb8570..a90909e26 100644
--- a/cmd/gitaly-ssh/testhelper_test.go
+++ b/cmd/gitaly-ssh/testhelper_test.go
@@ -18,7 +18,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
testhelper.ConfigureGitalySSH()
gitalySSHPath = filepath.Join(config.Config.BinDir, "gitaly-ssh")
diff --git a/internal/cache/cachedb_test.go b/internal/cache/cachedb_test.go
index 76708b00e..d18e0355f 100644
--- a/internal/cache/cachedb_test.go
+++ b/internal/cache/cachedb_test.go
@@ -25,7 +25,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/git/catfile/testhelper_test.go b/internal/git/catfile/testhelper_test.go
index a1332dc1d..d5b306d6d 100644
--- a/internal/git/catfile/testhelper_test.go
+++ b/internal/git/catfile/testhelper_test.go
@@ -13,6 +13,7 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/git/helper_test.go b/internal/git/helper_test.go
index 70033750b..3a4bbc715 100644
--- a/internal/git/helper_test.go
+++ b/internal/git/helper_test.go
@@ -14,7 +14,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/git/log/commit_test.go b/internal/git/log/commit_test.go
index 4d2d4fcae..0cfcde58c 100644
--- a/internal/git/log/commit_test.go
+++ b/internal/git/log/commit_test.go
@@ -19,7 +19,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/git/objectpool/testhelper_test.go b/internal/git/objectpool/testhelper_test.go
index dab21cd9f..71dee15c6 100644
--- a/internal/git/objectpool/testhelper_test.go
+++ b/internal/git/objectpool/testhelper_test.go
@@ -16,7 +16,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/git/packfile/packfile_test.go b/internal/git/packfile/packfile_test.go
index 4180f7024..7f5767b4c 100644
--- a/internal/git/packfile/packfile_test.go
+++ b/internal/git/packfile/packfile_test.go
@@ -15,7 +15,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/git/remote/remote_test.go b/internal/git/remote/remote_test.go
index a0259163a..53449a00a 100644
--- a/internal/git/remote/remote_test.go
+++ b/internal/git/remote/remote_test.go
@@ -16,7 +16,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
testhelper.ConfigureGitalySSH()
return m.Run()
}
diff --git a/internal/git/stats/testhelper_test.go b/internal/git/stats/testhelper_test.go
index 1247f2c8c..4f106e465 100644
--- a/internal/git/stats/testhelper_test.go
+++ b/internal/git/stats/testhelper_test.go
@@ -13,6 +13,7 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/git/updateref/updateref_test.go b/internal/git/updateref/updateref_test.go
index 796192bc3..de4209321 100644
--- a/internal/git/updateref/updateref_test.go
+++ b/internal/git/updateref/updateref_test.go
@@ -19,7 +19,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/git2go/commit_test.go b/internal/git2go/commit_test.go
index 7bba3aa31..1d00c526d 100644
--- a/internal/git2go/commit_test.go
+++ b/internal/git2go/commit_test.go
@@ -24,7 +24,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
testhelper.ConfigureGitalyGit2Go()
return m.Run()
}
diff --git a/internal/gitaly/hook/testhelper_test.go b/internal/gitaly/hook/testhelper_test.go
index 58fef1ed9..f6879db21 100644
--- a/internal/gitaly/hook/testhelper_test.go
+++ b/internal/gitaly/hook/testhelper_test.go
@@ -13,6 +13,7 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/gitaly/linguist/linguist_test.go b/internal/gitaly/linguist/linguist_test.go
index 55f62c9c0..284b25b17 100644
--- a/internal/gitaly/linguist/linguist_test.go
+++ b/internal/gitaly/linguist/linguist_test.go
@@ -17,7 +17,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/gitaly/rubyserver/testhelper_test.go b/internal/gitaly/rubyserver/testhelper_test.go
index dfe218701..bdd36f0eb 100644
--- a/internal/gitaly/rubyserver/testhelper_test.go
+++ b/internal/gitaly/rubyserver/testhelper_test.go
@@ -19,7 +19,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
testRepo = testhelper.TestRepository()
return m.Run()
diff --git a/internal/gitaly/server/auth_test.go b/internal/gitaly/server/auth_test.go
index e72034376..8a4a9046b 100644
--- a/internal/gitaly/server/auth_test.go
+++ b/internal/gitaly/server/auth_test.go
@@ -33,7 +33,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
testhelper.ConfigureGitalyHooksBinary()
return m.Run()
}
diff --git a/internal/gitaly/service/blob/testhelper_test.go b/internal/gitaly/service/blob/testhelper_test.go
index 7b3554d71..7c23ed835 100644
--- a/internal/gitaly/service/blob/testhelper_test.go
+++ b/internal/gitaly/service/blob/testhelper_test.go
@@ -23,7 +23,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
testhelper.ConfigureRuby()
if err := rubyServer.Start(); err != nil {
diff --git a/internal/gitaly/service/cleanup/testhelper_test.go b/internal/gitaly/service/cleanup/testhelper_test.go
index 5b1fb336a..56020c06c 100644
--- a/internal/gitaly/service/cleanup/testhelper_test.go
+++ b/internal/gitaly/service/cleanup/testhelper_test.go
@@ -17,7 +17,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/gitaly/service/commit/testhelper_test.go b/internal/gitaly/service/commit/testhelper_test.go
index 4b2792a05..37120b132 100644
--- a/internal/gitaly/service/commit/testhelper_test.go
+++ b/internal/gitaly/service/commit/testhelper_test.go
@@ -19,7 +19,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/gitaly/service/conflicts/testhelper_test.go b/internal/gitaly/service/conflicts/testhelper_test.go
index 86bbec0af..21ff9dee6 100644
--- a/internal/gitaly/service/conflicts/testhelper_test.go
+++ b/internal/gitaly/service/conflicts/testhelper_test.go
@@ -25,7 +25,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
testhelper.ConfigureGitalyGit2Go()
tempDir, err := ioutil.TempDir("", "gitaly")
diff --git a/internal/gitaly/service/diff/testhelper_test.go b/internal/gitaly/service/diff/testhelper_test.go
index 7a7a83aa0..6ed2f4a79 100644
--- a/internal/gitaly/service/diff/testhelper_test.go
+++ b/internal/gitaly/service/diff/testhelper_test.go
@@ -18,7 +18,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/gitaly/service/hook/testhelper_test.go b/internal/gitaly/service/hook/testhelper_test.go
index 319ba9beb..9881278e7 100644
--- a/internal/gitaly/service/hook/testhelper_test.go
+++ b/internal/gitaly/service/hook/testhelper_test.go
@@ -20,7 +20,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/gitaly/service/namespace/namespace_test.go b/internal/gitaly/service/namespace/namespace_test.go
index 20bfa7d37..c9aeb1396 100644
--- a/internal/gitaly/service/namespace/namespace_test.go
+++ b/internal/gitaly/service/namespace/namespace_test.go
@@ -22,7 +22,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
config.Config.Storages = nil
diff --git a/internal/gitaly/service/objectpool/testhelper_test.go b/internal/gitaly/service/objectpool/testhelper_test.go
index 212e710bd..0fe1334ed 100644
--- a/internal/gitaly/service/objectpool/testhelper_test.go
+++ b/internal/gitaly/service/objectpool/testhelper_test.go
@@ -19,7 +19,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/gitaly/service/operations/testhelper_test.go b/internal/gitaly/service/operations/testhelper_test.go
index 71fb3caab..b75fd346f 100644
--- a/internal/gitaly/service/operations/testhelper_test.go
+++ b/internal/gitaly/service/operations/testhelper_test.go
@@ -44,7 +44,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
cwd, err := os.Getwd()
if err != nil {
diff --git a/internal/gitaly/service/ref/testhelper_test.go b/internal/gitaly/service/ref/testhelper_test.go
index 7fb871e7b..710e6cafc 100644
--- a/internal/gitaly/service/ref/testhelper_test.go
+++ b/internal/gitaly/service/ref/testhelper_test.go
@@ -29,7 +29,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
// Force small messages to test that fragmenting the
// ref list works correctly
diff --git a/internal/gitaly/service/remote/testhelper_test.go b/internal/gitaly/service/remote/testhelper_test.go
index c861b44f2..9a0769661 100644
--- a/internal/gitaly/service/remote/testhelper_test.go
+++ b/internal/gitaly/service/remote/testhelper_test.go
@@ -23,7 +23,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
testhelper.ConfigureGitalySSH()
if err := RubyServer.Start(); err != nil {
diff --git a/internal/gitaly/service/repository/testhelper_test.go b/internal/gitaly/service/repository/testhelper_test.go
index fb74f0e10..3c2777c12 100644
--- a/internal/gitaly/service/repository/testhelper_test.go
+++ b/internal/gitaly/service/repository/testhelper_test.go
@@ -41,7 +41,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
config.Config.Auth.Token = testhelper.RepositoryAuthToken
diff --git a/internal/gitaly/service/smarthttp/testhelper_test.go b/internal/gitaly/service/smarthttp/testhelper_test.go
index eeff13553..d432e7297 100644
--- a/internal/gitaly/service/smarthttp/testhelper_test.go
+++ b/internal/gitaly/service/smarthttp/testhelper_test.go
@@ -30,7 +30,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
hooks.Override = "/"
diff --git a/internal/gitaly/service/ssh/testhelper_test.go b/internal/gitaly/service/ssh/testhelper_test.go
index 22415c71e..b3c0ded90 100644
--- a/internal/gitaly/service/ssh/testhelper_test.go
+++ b/internal/gitaly/service/ssh/testhelper_test.go
@@ -35,7 +35,8 @@ func testMain(m *testing.M) int {
config.Config.Ruby.Dir = rubyDir
}(config.Config.Ruby.Dir)
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
config.Config.Ruby.Dir = filepath.Join("../../../ruby", "git-hooks")
diff --git a/internal/gitaly/service/wiki/testhelper_test.go b/internal/gitaly/service/wiki/testhelper_test.go
index 8ec53efe6..31946d0e7 100644
--- a/internal/gitaly/service/wiki/testhelper_test.go
+++ b/internal/gitaly/service/wiki/testhelper_test.go
@@ -40,7 +40,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
tempDir, err := ioutil.TempDir("", "gitaly")
if err != nil {
diff --git a/internal/gitalyssh/testhelper_test.go b/internal/gitalyssh/testhelper_test.go
index aff4bae94..7f5545162 100644
--- a/internal/gitalyssh/testhelper_test.go
+++ b/internal/gitalyssh/testhelper_test.go
@@ -13,6 +13,7 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/helper/repo_test.go b/internal/helper/repo_test.go
index 17e2496bf..9cd28c874 100644
--- a/internal/helper/repo_test.go
+++ b/internal/helper/repo_test.go
@@ -18,7 +18,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/middleware/commandstatshandler/commandstatshandler_test.go b/internal/middleware/commandstatshandler/commandstatshandler_test.go
index c02103323..0fbf34954 100644
--- a/internal/middleware/commandstatshandler/commandstatshandler_test.go
+++ b/internal/middleware/commandstatshandler/commandstatshandler_test.go
@@ -49,7 +49,8 @@ func getBufDialer(listener *bufconn.Listener) func(context.Context, string) (net
}
func TestInterceptor(t *testing.T) {
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
logBuffer := &bytes.Buffer{}
testhelper.NewTestLogger = func(tb testing.TB) *logrus.Logger {
diff --git a/internal/praefect/replicator_test.go b/internal/praefect/replicator_test.go
index ac26045c2..63529911e 100644
--- a/internal/praefect/replicator_test.go
+++ b/internal/praefect/replicator_test.go
@@ -57,7 +57,8 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
gitaly_config.Config.Auth.Token = testhelper.RepositoryAuthToken
diff --git a/internal/tempdir/testhelper_test.go b/internal/tempdir/testhelper_test.go
index bf2008aa2..42986ae4a 100644
--- a/internal/tempdir/testhelper_test.go
+++ b/internal/tempdir/testhelper_test.go
@@ -13,6 +13,7 @@ func TestMain(m *testing.M) {
func testMain(m *testing.M) int {
defer testhelper.MustHaveNoChildProcess()
- testhelper.Configure()
+ cleanup := testhelper.Configure()
+ defer cleanup()
return m.Run()
}
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go
index 41b034aeb..57a605b18 100644
--- a/internal/testhelper/testhelper.go
+++ b/internal/testhelper/testhelper.go
@@ -71,7 +71,7 @@ var (
// Configure sets up the global test configuration. On failure,
// terminates the program.
-func Configure() {
+func Configure() func() {
configureOnce.Do(func() {
gitalylog.Configure("json", "info")
@@ -119,6 +119,8 @@ func Configure() {
}
}
})
+
+ return func() {}
}
// MustReadFile returns the content of a file or fails at once.