[ruby/rubygems] Skip the newgem linter specs only when ast.rb is on RUBYLIB

An in-tree build of ruby core puts the source root on RUBYLIB, and its ast.rb shadows the ast gem that rubocop-ast requires. Out-of-source builds, as on CI, can run them.

https://github.com/ruby/rubygems/commit/9b08921212

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hiroshi SHIBATAandClaude Opus 5.5 authored and git committed 2026-10-05 06:23:48 +00:00
1 parent 412fc158b2
commit 347a80c8c9
1 file changed
+14 -10
+14 -10
View File
@@ -38,6 +38,10 @@ RSpec.describe "bundle gem" do
false
end
def ast_rb_on_rubylib?
rubylib.any? {|dir| File.exist?(File.join(dir, "ast.rb")) }
end
let(:generated_gemspec) { Bundler.load_gemspec_uncached(bundled_app(gem_name).join("#{gem_name}.gemspec")) }
let(:gem_name) { "mygem" }
@@ -95,49 +99,49 @@ RSpec.describe "bundle gem" do
end
it "has no rubocop offenses when using --linter=rubocop flag" do
skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
skip "an in-tree ruby/ruby build puts its ast.rb on RUBYLIB, shadowing the ast gem" if ast_rb_on_rubylib?
bundle "gem #{gem_name} --linter=rubocop"
bundle_exec_rubocop
expect(last_command).to be_success
end
it "has no rubocop offenses when using --ext=c and --linter=rubocop flag" do
skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
skip "an in-tree ruby/ruby build puts its ast.rb on RUBYLIB, shadowing the ast gem" if ast_rb_on_rubylib?
bundle "gem #{gem_name} --ext=c --linter=rubocop"
bundle_exec_rubocop
expect(last_command).to be_success
end
it "has no rubocop offenses when using --ext=c, --test=minitest, and --linter=rubocop flag" do
skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
skip "an in-tree ruby/ruby build puts its ast.rb on RUBYLIB, shadowing the ast gem" if ast_rb_on_rubylib?
bundle "gem #{gem_name} --ext=c --test=minitest --linter=rubocop"
bundle_exec_rubocop
expect(last_command).to be_success
end
it "has no rubocop offenses when using --ext=c, --test=rspec, and --linter=rubocop flag" do
skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
skip "an in-tree ruby/ruby build puts its ast.rb on RUBYLIB, shadowing the ast gem" if ast_rb_on_rubylib?
bundle "gem #{gem_name} --ext=c --test=rspec --linter=rubocop"
bundle_exec_rubocop
expect(last_command).to be_success
end
it "has no rubocop offenses when using --ext=c, --test=test-unit, and --linter=rubocop flag" do
skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
skip "an in-tree ruby/ruby build puts its ast.rb on RUBYLIB, shadowing the ast gem" if ast_rb_on_rubylib?
bundle "gem #{gem_name} --ext=c --test=test-unit --linter=rubocop"
bundle_exec_rubocop
expect(last_command).to be_success
end
it "has no standard offenses when using --linter=standard flag" do
skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
skip "an in-tree ruby/ruby build puts its ast.rb on RUBYLIB, shadowing the ast gem" if ast_rb_on_rubylib?
bundle "gem #{gem_name} --linter=standard"
bundle_exec_standardrb
expect(last_command).to be_success
end
it "has no rubocop offenses when using --ext=rust and --linter=rubocop flag" do
skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
skip "an in-tree ruby/ruby build puts its ast.rb on RUBYLIB, shadowing the ast gem" if ast_rb_on_rubylib?
bundle "gem #{gem_name} --ext=rust --linter=rubocop"
bundle_exec_rubocop
@@ -145,7 +149,7 @@ RSpec.describe "bundle gem" do
end
it "has no rubocop offenses when using --ext=rust, --test=minitest, and --linter=rubocop flag" do
skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
skip "an in-tree ruby/ruby build puts its ast.rb on RUBYLIB, shadowing the ast gem" if ast_rb_on_rubylib?
bundle "gem #{gem_name} --ext=rust --test=minitest --linter=rubocop"
bundle_exec_rubocop
@@ -153,7 +157,7 @@ RSpec.describe "bundle gem" do
end
it "has no rubocop offenses when using --ext=rust, --test=rspec, and --linter=rubocop flag" do
skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
skip "an in-tree ruby/ruby build puts its ast.rb on RUBYLIB, shadowing the ast gem" if ast_rb_on_rubylib?
bundle "gem #{gem_name} --ext=rust --test=rspec --linter=rubocop"
bundle_exec_rubocop
@@ -161,7 +165,7 @@ RSpec.describe "bundle gem" do
end
it "has no rubocop offenses when using --ext=rust, --test=test-unit, and --linter=rubocop flag" do
skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
skip "an in-tree ruby/ruby build puts its ast.rb on RUBYLIB, shadowing the ast gem" if ast_rb_on_rubylib?
bundle "gem #{gem_name} --ext=rust --test=test-unit --linter=rubocop"
bundle_exec_rubocop