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-08-19 16:19:43 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-08-20 14:20:19 +0300
commit7471d0b42e4c5250ed37e08c5de224eb87a900be (patch)
treef33b0360da4a073c6f4ad5bf194ba6caa1758b26
parent8941c9126692fef30fd136a21e5a7158634edbcc (diff)
rspec: Fix tests using system-provided Git
Two of our helpers in the rspec tests use the system Git instead of the configured one. While this isn't much of a problem by itself as it's only tests, we're going to change test execution so that we can verify only the configured Git executable is ever executed. Executing Git via the PATH variable is always going to fail with this setup. Prepare for this by honoring the GITALY_TESTING_GIT_BINARY environment variable like our Go tests do. Convert callers to use the configured value. As there's now a dependency cycle between the spec helper and the test repo helper because the test repo helper depends on the overrides defined in the spec helper, this commit also moves those overrides into the test repo helper.
-rw-r--r--ruby/spec/spec_helper.rb4
-rw-r--r--ruby/spec/test_repo_helper.rb8
2 files changed, 6 insertions, 6 deletions
diff --git a/ruby/spec/spec_helper.rb b/ruby/spec/spec_helper.rb
index 49e956f92..93a600b7f 100644
--- a/ruby/spec/spec_helper.rb
+++ b/ruby/spec/spec_helper.rb
@@ -12,10 +12,6 @@ require File.join(__dir__, 'support/helpers/gitlab_shell_helper.rb')
Dir[File.join(__dir__, 'support/helpers/*.rb')].each { |f| require f }
-Gitlab.config.git.test_global_ivar_override(:bin_path, 'git')
-Gitlab.config.git.test_global_ivar_override(:hooks_directory, File.join(Gitlab.config.gitlab_shell.path.to_s, "hooks"))
-Gitlab.config.gitaly.test_global_ivar_override(:bin_dir, __dir__)
-
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
diff --git a/ruby/spec/test_repo_helper.rb b/ruby/spec/test_repo_helper.rb
index 5250bfaa7..4ae4c6fe9 100644
--- a/ruby/spec/test_repo_helper.rb
+++ b/ruby/spec/test_repo_helper.rb
@@ -5,6 +5,10 @@ require 'rugged'
$:.unshift(File.expand_path('../proto', __dir__))
require 'gitaly'
+Gitlab.config.git.test_global_ivar_override(:bin_path, ENV.fetch('GITALY_TESTING_GIT_BINARY', 'git'))
+Gitlab.config.git.test_global_ivar_override(:hooks_directory, File.join(Gitlab.config.gitlab_shell.path.to_s, "hooks"))
+Gitlab.config.gitaly.test_global_ivar_override(:bin_dir, __dir__)
+
DEFAULT_STORAGE_DIR = File.expand_path('../tmp/repositories', __dir__)
DEFAULT_STORAGE_NAME = 'default'.freeze
TEST_REPO_PATH = File.join(DEFAULT_STORAGE_DIR, 'gitlab-test.git')
@@ -104,13 +108,13 @@ module TestRepo
end
def self.clone_new_repo!(origin, destination)
- return if system("git", "clone", "--quiet", "--bare", origin.to_s, destination.to_s)
+ return if system(Gitlab.config.git.bin_path, "clone", "--quiet", "--bare", origin.to_s, destination.to_s)
abort "Failed to clone test repo. Try running 'make prepare-tests' and try again."
end
def self.init_new_repo!(destination)
- return if system("git", "init", "--quiet", "--bare", destination.to_s)
+ return if system(Gitlab.config.git.bin_path, "init", "--quiet", "--bare", destination.to_s)
abort "Failed to init test repo."
end