summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-05-04 01:34:35 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-05-04 18:05:24 +0900
commitcaa2180be0cf8499f83df6cce12511c1918abad2 (patch)
tree93b9ecfcc77c94389eda8a3d7a88966216002429 /test
parent2f9f44f077a53b14aa1fbd43111955251750d31f (diff)
downloadruby-caa2180be0cf8499f83df6cce12511c1918abad2.tar.gz
test_default_gems.rb: Stop using `git ls-files`
Just validate syntax and the result class instead. Not only `git ls-files` doesn't make sence under ruby's repository, some gemspec files hardcode `2>/dev/null`, which doesn't work of course on other than Unix-like platforms.
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_default_gems.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/test/ruby/test_default_gems.rb b/test/ruby/test_default_gems.rb
index c1c81bfec0..6bc0639f8a 100644
--- a/test/ruby/test_default_gems.rb
+++ b/test/ruby/test_default_gems.rb
@@ -2,22 +2,26 @@
require 'rubygems'
class TestDefaultGems < Test::Unit::TestCase
+ def self.load(file)
+ code = File.read(file, mode: "r:UTF-8:-", &:read)
+
+ # - `git ls-files` is useless under ruby's repository
+ # - `2>/dev/null` works only on Unix-like platforms
+ code.gsub!(/`git.*?`/, '""')
+
+ eval(code, binding, file)
+ end
def test_validate_gemspec
srcdir = File.expand_path('../../..', __FILE__)
specs = 0
Dir.chdir(srcdir) do
- 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
+ assert_kind_of(Gem::Specification, self.class.load(src), "invalid spec in #{src}")
end
end
- assert specs > 0, "gemspecs not found"
+ assert_operator specs, :>, 0, "gemspecs not found"
end
end