X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f69d2824c997c53caa11d30ba816768bad52e12b..6cae747c4bd57a2787e943cbc87b95e9cc1015a0:/services/api/test/helpers/git_test_helper.rb diff --git a/services/api/test/helpers/git_test_helper.rb b/services/api/test/helpers/git_test_helper.rb index 9abdc4f0d9..170b59ee1e 100644 --- a/services/api/test/helpers/git_test_helper.rb +++ b/services/api/test/helpers/git_test_helper.rb @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + require 'fileutils' require 'tmpdir' @@ -14,20 +18,21 @@ require 'tmpdir' module GitTestHelper def self.included base base.setup do - @tmpdir = Dir.mktmpdir() - system("tar", "-xC", @tmpdir, "-f", "test/test.git.tar") + # Extract the test repository data into the default test + # environment's Rails.configuration.git_repositories_dir. (We + # don't use that config setting here, though: it doesn't seem + # worth the risk of stepping on a real git repo root.) + @tmpdir = Rails.root.join 'tmp', 'git' + FileUtils.mkdir_p @tmpdir + system("tar", "-xC", @tmpdir.to_s, "-f", "test/test.git.tar") Rails.configuration.git_repositories_dir = "#{@tmpdir}/test" - intdir = Rails.configuration.git_internal_dir - if not File.exist? intdir - FileUtils.mkdir_p intdir - IO.read("|git --git-dir #{intdir.to_s.shellescape} init") - assert $?.success? - end + Rails.configuration.git_internal_dir = "#{@tmpdir}/internal.git" end base.teardown do - FileUtils.remove_entry @tmpdir, true FileUtils.remove_entry Commit.cache_dir_base, true + FileUtils.mkdir_p @tmpdir + system("tar", "-xC", @tmpdir.to_s, "-f", "test/test.git.tar") end end