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>2023-08-16 13:06:16 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-08-16 13:19:31 +0300
commite649e027b724c6d685770735ae6083932943c656 (patch)
tree1f82ddd7d39cca7fa363f930afffa1ee488dfb40
parente58e61e98a530e1ccdffbe7e48a8c701a43db3e9 (diff)
tests: Stop using global logrus logger
Stop using the global logrus logger. In one case we can simply use the logger provided by `log.Configure()`, while in the other case we can instead use the logging facilities provided by `testing.TB`.
-rw-r--r--internal/git/gittest/repo.go3
-rw-r--r--internal/testhelper/configure.go12
2 files changed, 7 insertions, 8 deletions
diff --git a/internal/git/gittest/repo.go b/internal/git/gittest/repo.go
index baa30c0ea..8ee2dfb20 100644
--- a/internal/git/gittest/repo.go
+++ b/internal/git/gittest/repo.go
@@ -9,7 +9,6 @@ import (
"runtime"
"testing"
- log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
gitalyauth "gitlab.com/gitlab-org/gitaly/v16/auth"
"gitlab.com/gitlab-org/gitaly/v16/client"
@@ -315,7 +314,7 @@ func testRepositoryPath(tb testing.TB, repo string) string {
if !isValidRepoPath(path) {
makePath := filepath.Join(filepath.Dir(currentFile), "..", "..", "..")
makeTarget := "prepare-test-repos"
- log.Printf("local clone of test repository %q not found in %q, running `make %v`", repo, path, makeTarget)
+ tb.Logf("local clone of test repository %q not found in %q, running `make %v`", repo, path, makeTarget)
testhelper.MustRunCommand(tb, nil, "make", "-C", makePath, makeTarget)
}
diff --git a/internal/testhelper/configure.go b/internal/testhelper/configure.go
index 7f165ca05..399e20bfc 100644
--- a/internal/testhelper/configure.go
+++ b/internal/testhelper/configure.go
@@ -8,9 +8,9 @@ import (
"runtime"
"testing"
- log "github.com/sirupsen/logrus"
+ "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm"
- gitalylog "gitlab.com/gitlab-org/gitaly/v16/internal/log"
+ "gitlab.com/gitlab-org/gitaly/v16/internal/log"
)
var testDirectory string
@@ -81,7 +81,7 @@ func Run(m *testing.M, opts ...RunOption) {
// configure sets up the global test configuration. On failure,
// terminates the program.
func configure() (_ func(), returnedErr error) {
- gitalylog.Configure(os.Stdout, "json", "panic")
+ logger := log.Configure(os.Stdout, "json", "panic")
for key, value := range map[string]string{
// We inject the following two variables, which instruct Git to search its
@@ -129,7 +129,7 @@ func configure() (_ func(), returnedErr error) {
}
}
- cleanup, err := configureTestDirectory()
+ cleanup, err := configureTestDirectory(logger)
if err != nil {
return nil, fmt.Errorf("configuring test directory: %w", err)
}
@@ -142,7 +142,7 @@ func configure() (_ func(), returnedErr error) {
return cleanup, nil
}
-func configureTestDirectory() (_ func(), returnedErr error) {
+func configureTestDirectory(logger logrus.FieldLogger) (_ func(), returnedErr error) {
if testDirectory != "" {
return nil, errors.New("test directory has already been configured")
}
@@ -165,7 +165,7 @@ func configureTestDirectory() (_ func(), returnedErr error) {
cleanup := func() {
if err := os.RemoveAll(testDirectory); err != nil {
- log.Errorf("cleaning up test directory: %v", err)
+ logger.Errorf("cleaning up test directory: %v", err)
}
}
defer func() {