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-17 10:06:13 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-11-17 10:07:45 +0300
commitabed52c0d62beb789f9224251f0e2b09822ad0e8 (patch)
tree0fa3ac7c7d98708c0d90e58225f5474c9396c59a
parentd250926f3cadd7ee281819f6f3333c6e9a08c18c (diff)
testhelper: Remove global test directory if setup fails
If configuring tests via `testhelper.Configure()` fails, then we call `log.Fatal()` to immediately exit the test suite. This'll leave behind the global test directory though. Let's clean it up.
-rw-r--r--internal/testhelper/testhelper.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go
index df0143757..96cda6359 100644
--- a/internal/testhelper/testhelper.go
+++ b/internal/testhelper/testhelper.go
@@ -84,6 +84,7 @@ func Configure() func() {
config.Config.Logging.Dir = filepath.Join(testDirectory, "log")
if err := os.Mkdir(config.Config.Logging.Dir, 0755); err != nil {
+ os.RemoveAll(testDirectory)
log.Fatal(err)
}
@@ -96,11 +97,13 @@ func Configure() func() {
config.Config.InternalSocketDir = filepath.Join(testDirectory, "internal-socket")
if err := os.Mkdir(config.Config.InternalSocketDir, 0755); err != nil {
+ os.RemoveAll(testDirectory)
log.Fatal(err)
}
config.Config.BinDir = filepath.Join(testDirectory, "bin")
if err := os.Mkdir(config.Config.BinDir, 0755); err != nil {
+ os.RemoveAll(testDirectory)
log.Fatal(err)
}
@@ -110,6 +113,7 @@ func Configure() func() {
config.Validate,
} {
if err := f(); err != nil {
+ os.RemoveAll(testDirectory)
log.Fatalf("error configuring tests: %v", err)
}
}