Make sure TestDefaultGems#test_validate_gemspec runs even when Dir.pwd != srcdir

For instance, when running tests in build directory like:

$ make test-all TESTOPTS="../ruby/test"
This commit is contained in:
lukeg 2023-03-08 12:29:39 -05:00 committed by Hiroshi SHIBATA
parent 1658e7d966
commit 2ecdefab7d
Notes: git 2023-03-09 04:18:32 +00:00

View File

@ -4,13 +4,20 @@ require 'rubygems'
class TestDefaultGems < Test::Unit::TestCase class TestDefaultGems < Test::Unit::TestCase
def test_validate_gemspec def test_validate_gemspec
omit "git not found" unless system("git", "rev-parse", %i[out err]=>IO::NULL)
srcdir = File.expand_path('../../..', __FILE__) srcdir = File.expand_path('../../..', __FILE__)
Dir.glob("#{srcdir}/{lib,ext}/**/*.gemspec").map do |src| specs = 0
assert_nothing_raised do Dir.chdir(srcdir) do
raise("invalid spec in #{src}") unless Gem::Specification.load(src) unless system("git", "rev-parse", %i[out err]=>IO::NULL)
omit "git not found"
end
Dir.glob("#{srcdir}/{lib,ext}/**/*.gemspec").map do |src|
specs += 1
assert_nothing_raised do
raise("invalid spec in #{src}") unless Gem::Specification.load(src)
end
end end
end end
assert specs > 0, "gemspecs not found"
end end
end end