Commit 1e9b0186 authored by Toon Claes's avatar Toon Claes

test: Add helper method to expand path

In several places we need to expand the path from the root of the
project. To simplify this, a helper method is added that expands the
given path to an absolute path.
parent 4e33b6b2
......@@ -18,8 +18,12 @@ module GitalySetup
Logger.new($stdout, level: level, formatter: ->(_, _, _, msg) { msg })
end
def expand_path(path)
File.expand_path(path, File.join(__dir__, '../../..'))
end
def tmp_tests_gitaly_dir
File.expand_path('../../../tmp/tests/gitaly', __dir__)
expand_path('tmp/tests/gitaly')
end
def tmp_tests_gitaly_bin_dir
......@@ -27,11 +31,11 @@ module GitalySetup
end
def tmp_tests_gitlab_shell_dir
File.expand_path('../../../tmp/tests/gitlab-shell', __dir__)
expand_path('tmp/tests/gitlab-shell')
end
def rails_gitlab_shell_secret
File.expand_path('../../../.gitlab_shell_secret', __dir__)
expand_path('.gitlab_shell_secret')
end
def gemfile
......@@ -48,7 +52,7 @@ module GitalySetup
def env
{
'HOME' => File.expand_path('tmp/tests'),
'HOME' => expand_path('tmp/tests'),
'GEM_PATH' => Gem.path.join(':'),
'BUNDLE_APP_CONFIG' => File.join(gemfile_dir, '.bundle'),
'BUNDLE_INSTALL_FLAGS' => nil,
......@@ -67,7 +71,7 @@ module GitalySetup
system('bundle config set --local retry 3', chdir: gemfile_dir)
if ENV['CI']
bundle_path = File.expand_path('../../../vendor/gitaly-ruby', __dir__)
bundle_path = expand_path('vendor/gitaly-ruby')
system('bundle', 'config', 'set', '--local', 'path', bundle_path, chdir: gemfile_dir)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment