diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2021-02-21 20:26:08 +0300 |
---|---|---|
committer | Pavlo Strokov <pstrokov@gitlab.com> | 2021-02-21 20:26:08 +0300 |
commit | d3ab3e3647a10e246defaa010efd89d563afedf2 (patch) | |
tree | 58c5f2997a893658cf6aebaab00f769bd2a30a1e | |
parent | 3f29772a7241e66cc89608778b2411f2a3733a17 (diff) |
Removal of config.Config from the buildCommand
Removal of the buildCommand function dependency on the
global config.Config variable.
Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/2699
18 files changed, 37 insertions, 36 deletions
diff --git a/cmd/gitaly-git2go/conflicts/conflicts_test.go b/cmd/gitaly-git2go/conflicts/conflicts_test.go index 31db7c6c2..ca4f474a4 100644 --- a/cmd/gitaly-git2go/conflicts/conflicts_test.go +++ b/cmd/gitaly-git2go/conflicts/conflicts_test.go @@ -22,7 +22,7 @@ func testMain(m *testing.M) int { defer testhelper.MustHaveNoChildProcess() cleanup := testhelper.Configure() defer cleanup() - testhelper.ConfigureGitalyGit2Go() + testhelper.ConfigureGitalyGit2Go(config.Config.BinDir) return m.Run() } diff --git a/cmd/gitaly-git2go/main_test.go b/cmd/gitaly-git2go/main_test.go index 1c863380a..1202aedf9 100644 --- a/cmd/gitaly-git2go/main_test.go +++ b/cmd/gitaly-git2go/main_test.go @@ -6,6 +6,7 @@ import ( "os" "testing" + "gitlab.com/gitlab-org/gitaly/internal/gitaly/config" "gitlab.com/gitlab-org/gitaly/internal/testhelper" ) @@ -17,6 +18,6 @@ func testMain(m *testing.M) int { defer testhelper.MustHaveNoChildProcess() cleanup := testhelper.Configure() defer cleanup() - testhelper.ConfigureGitalyGit2Go() + testhelper.ConfigureGitalyGit2Go(config.Config.BinDir) return m.Run() } diff --git a/cmd/gitaly-hooks/hooks_test.go b/cmd/gitaly-hooks/hooks_test.go index b64e23cf0..d64035fbc 100644 --- a/cmd/gitaly-hooks/hooks_test.go +++ b/cmd/gitaly-hooks/hooks_test.go @@ -98,8 +98,8 @@ func testMain(m *testing.M) int { config.Config.Ruby.Dir = rubyDir - testhelper.ConfigureGitalyHooksBinary() - testhelper.ConfigureGitalySSH() + testhelper.ConfigureGitalyHooksBinary(config.Config.BinDir) + testhelper.ConfigureGitalySSH(config.Config.BinDir) return m.Run() } diff --git a/cmd/gitaly-ssh/testhelper_test.go b/cmd/gitaly-ssh/testhelper_test.go index d8c3a6a0c..b565bcbcf 100644 --- a/cmd/gitaly-ssh/testhelper_test.go +++ b/cmd/gitaly-ssh/testhelper_test.go @@ -21,8 +21,8 @@ func testMain(m *testing.M) int { cleanup := testhelper.Configure() defer cleanup() - testhelper.ConfigureGitalySSH() - testhelper.ConfigureGitalyHooksBinary() + testhelper.ConfigureGitalySSH(config.Config.BinDir) + testhelper.ConfigureGitalyHooksBinary(config.Config.BinDir) gitalySSHPath = filepath.Join(config.Config.BinDir, "gitaly-ssh") diff --git a/internal/git2go/commit_test.go b/internal/git2go/commit_test.go index b9c687496..528b29063 100644 --- a/internal/git2go/commit_test.go +++ b/internal/git2go/commit_test.go @@ -27,7 +27,7 @@ func testMain(m *testing.M) int { defer testhelper.MustHaveNoChildProcess() cleanup := testhelper.Configure() defer cleanup() - testhelper.ConfigureGitalyGit2Go() + testhelper.ConfigureGitalyGit2Go(config.Config.BinDir) return m.Run() } diff --git a/internal/gitaly/service/cleanup/testhelper_test.go b/internal/gitaly/service/cleanup/testhelper_test.go index 1eb9db491..c6a44b44b 100644 --- a/internal/gitaly/service/cleanup/testhelper_test.go +++ b/internal/gitaly/service/cleanup/testhelper_test.go @@ -23,7 +23,7 @@ func testMain(m *testing.M) int { defer testhelper.MustHaveNoChildProcess() cleanup := testhelper.Configure() defer cleanup() - testhelper.ConfigureGitalyHooksBinary() + testhelper.ConfigureGitalyHooksBinary(config.Config.BinDir) return m.Run() } diff --git a/internal/gitaly/service/conflicts/testhelper_test.go b/internal/gitaly/service/conflicts/testhelper_test.go index c56889f70..6e92d94d2 100644 --- a/internal/gitaly/service/conflicts/testhelper_test.go +++ b/internal/gitaly/service/conflicts/testhelper_test.go @@ -28,7 +28,7 @@ func testMain(m *testing.M) int { cleanup := testhelper.Configure() defer cleanup() - testhelper.ConfigureGitalyGit2Go() + testhelper.ConfigureGitalyGit2Go(config.Config.BinDir) tempDir, err := ioutil.TempDir("", "gitaly") if err != nil { diff --git a/internal/gitaly/service/objectpool/testhelper_test.go b/internal/gitaly/service/objectpool/testhelper_test.go index 57bb7f560..72db332f7 100644 --- a/internal/gitaly/service/objectpool/testhelper_test.go +++ b/internal/gitaly/service/objectpool/testhelper_test.go @@ -26,7 +26,7 @@ func testMain(m *testing.M) int { defer testhelper.MustHaveNoChildProcess() cleanup := testhelper.Configure() defer cleanup() - testhelper.ConfigureGitalyHooksBinary() + testhelper.ConfigureGitalyHooksBinary(config.Config.BinDir) return m.Run() } diff --git a/internal/gitaly/service/operations/testhelper_test.go b/internal/gitaly/service/operations/testhelper_test.go index 467c1538d..f0d48f4a2 100644 --- a/internal/gitaly/service/operations/testhelper_test.go +++ b/internal/gitaly/service/operations/testhelper_test.go @@ -55,9 +55,9 @@ func testMain(m *testing.M) int { config.Config.GitlabShell.Dir = gitlabShellDir - testhelper.ConfigureGitalySSH() - testhelper.ConfigureGitalyGit2Go() - testhelper.ConfigureGitalyHooksBinary() + testhelper.ConfigureGitalySSH(config.Config.BinDir) + testhelper.ConfigureGitalyGit2Go(config.Config.BinDir) + testhelper.ConfigureGitalyHooksBinary(config.Config.BinDir) defer func(token string) { config.Config.Auth.Token = token diff --git a/internal/gitaly/service/ref/testhelper_test.go b/internal/gitaly/service/ref/testhelper_test.go index 68f2a0e70..c40da49d1 100644 --- a/internal/gitaly/service/ref/testhelper_test.go +++ b/internal/gitaly/service/ref/testhelper_test.go @@ -34,7 +34,7 @@ func testMain(m *testing.M) int { cleanup := testhelper.Configure() defer cleanup() - testhelper.ConfigureGitalyHooksBinary() + testhelper.ConfigureGitalyHooksBinary(config.Config.BinDir) // Force small messages to test that fragmenting the // ref list works correctly diff --git a/internal/gitaly/service/remote/fetch_internal_remote_test.go b/internal/gitaly/service/remote/fetch_internal_remote_test.go index d52f67d0b..8812e22ec 100644 --- a/internal/gitaly/service/remote/fetch_internal_remote_test.go +++ b/internal/gitaly/service/remote/fetch_internal_remote_test.go @@ -48,7 +48,7 @@ func TestSuccessfulFetchInternalRemote(t *testing.T) { }, }...) - testhelper.ConfigureGitalyHooksBinary() + testhelper.ConfigureGitalyHooksBinary(config.Config.BinDir) locator := config.NewLocator(config.Config) gitCmdFactory := git.NewExecCommandFactory(config.Config) diff --git a/internal/gitaly/service/remote/testhelper_test.go b/internal/gitaly/service/remote/testhelper_test.go index 7e343677a..0b05b0a2b 100644 --- a/internal/gitaly/service/remote/testhelper_test.go +++ b/internal/gitaly/service/remote/testhelper_test.go @@ -25,7 +25,7 @@ func testMain(m *testing.M) int { cleanup := testhelper.Configure() defer cleanup() - testhelper.ConfigureGitalySSH() + testhelper.ConfigureGitalySSH(config.Config.BinDir) RubyServer = rubyserver.New(config.Config) if err := RubyServer.Start(); err != nil { diff --git a/internal/gitaly/service/repository/archive_test.go b/internal/gitaly/service/repository/archive_test.go index cb7cf62b2..00d130b3d 100644 --- a/internal/gitaly/service/repository/archive_test.go +++ b/internal/gitaly/service/repository/archive_test.go @@ -173,7 +173,7 @@ func TestGetArchiveSuccess(t *testing.T) { } func TestGetArchiveWithLfsSuccess(t *testing.T) { - testhelper.ConfigureGitalyLfsSmudge() + testhelper.ConfigureGitalyLfsSmudge(config.Config.BinDir) defaultOptions := testhelper.GitlabTestServerOptions{ SecretToken: secretToken, diff --git a/internal/gitaly/service/repository/testhelper_test.go b/internal/gitaly/service/repository/testhelper_test.go index 3bcd4f2c5..9334b1945 100644 --- a/internal/gitaly/service/repository/testhelper_test.go +++ b/internal/gitaly/service/repository/testhelper_test.go @@ -56,8 +56,8 @@ func testMain(m *testing.M) int { return 1 } - testhelper.ConfigureGitalyHooksBinary() - testhelper.ConfigureGitalySSH() + testhelper.ConfigureGitalyHooksBinary(config.Config.BinDir) + testhelper.ConfigureGitalySSH(config.Config.BinDir) RubyServer = rubyserver.New(config.Config) if err := RubyServer.Start(); err != nil { diff --git a/internal/gitaly/service/smarthttp/testhelper_test.go b/internal/gitaly/service/smarthttp/testhelper_test.go index 1a59c9a6e..3b69fc0c0 100644 --- a/internal/gitaly/service/smarthttp/testhelper_test.go +++ b/internal/gitaly/service/smarthttp/testhelper_test.go @@ -43,7 +43,7 @@ func testMain(m *testing.M) int { config.Config.Ruby.Dir = filepath.Join(cwd, "../../../../ruby") - testhelper.ConfigureGitalyHooksBinary() + testhelper.ConfigureGitalyHooksBinary(config.Config.BinDir) return m.Run() } diff --git a/internal/gitaly/service/ssh/testhelper_test.go b/internal/gitaly/service/ssh/testhelper_test.go index 6dcac7f81..5bf277a7b 100644 --- a/internal/gitaly/service/ssh/testhelper_test.go +++ b/internal/gitaly/service/ssh/testhelper_test.go @@ -33,8 +33,8 @@ func testMain(m *testing.M) int { cleanup := testhelper.Configure() defer cleanup() - testhelper.ConfigureGitalyHooksBinary() - testhelper.ConfigureGitalySSH() + testhelper.ConfigureGitalyHooksBinary(config.Config.BinDir) + testhelper.ConfigureGitalySSH(config.Config.BinDir) gitalySSHPath = filepath.Join(config.Config.BinDir, "gitaly-ssh") return m.Run() diff --git a/internal/praefect/replicator_test.go b/internal/praefect/replicator_test.go index 9894ece76..3d631f2f8 100644 --- a/internal/praefect/replicator_test.go +++ b/internal/praefect/replicator_test.go @@ -71,8 +71,8 @@ func testMain(m *testing.M) int { return 1 } - testhelper.ConfigureGitalySSH() - testhelper.ConfigureGitalyHooksBinary() + testhelper.ConfigureGitalySSH(gitaly_config.Config.BinDir) + testhelper.ConfigureGitalyHooksBinary(gitaly_config.Config.BinDir) RubyServer = rubyserver.New(gitaly_config.Config) if err := RubyServer.Start(); err != nil { diff --git a/internal/testhelper/configure.go b/internal/testhelper/configure.go index 137852433..1d9eed9e6 100644 --- a/internal/testhelper/configure.go +++ b/internal/testhelper/configure.go @@ -129,34 +129,34 @@ func ConfigureRuby(cfg *config.Cfg) error { } // ConfigureGitalyGit2Go configures the gitaly-git2go command for tests -func ConfigureGitalyGit2Go() { - buildCommand("gitaly-git2go") +func ConfigureGitalyGit2Go(outputDir string) { + buildCommand(outputDir, "gitaly-git2go") } // ConfigureGitalyLfsSmudge configures the gitaly-lfs-smudge command for tests -func ConfigureGitalyLfsSmudge() { - buildCommand("gitaly-lfs-smudge") +func ConfigureGitalyLfsSmudge(outputDir string) { + buildCommand(outputDir, "gitaly-lfs-smudge") } // ConfigureGitalySSH configures the gitaly-ssh command for tests -func ConfigureGitalySSH() { - buildCommand("gitaly-ssh") +func ConfigureGitalySSH(outputDir string) { + buildCommand(outputDir, "gitaly-ssh") } // ConfigureGitalyHooksBinary builds gitaly-hooks command for tests -func ConfigureGitalyHooksBinary() { - buildCommand("gitaly-hooks") +func ConfigureGitalyHooksBinary(outputDir string) { + buildCommand(outputDir, "gitaly-hooks") } -func buildCommand(cmd string) { - if config.Config.BinDir == "" { - log.Fatal("config.Config.BinDir must be set") +func buildCommand(outputDir, cmd string) { + if outputDir == "" { + log.Fatal("BinDir must be set") } goBuildArgs := []string{ "build", "-tags", "static,system_libgit2", - "-o", filepath.Join(config.Config.BinDir, cmd), + "-o", filepath.Join(outputDir, cmd), fmt.Sprintf("gitlab.com/gitlab-org/gitaly/cmd/%s", cmd), } MustRunCommand(nil, nil, "go", goBuildArgs...) |