Skip to content

Commit 321782d

Browse files
committed
Omit rubygems tests that fail on JRuby + Windows
Extend symlink_supported? to probe readlink so the symlink-based tests omit cleanly when JRuby on Windows lacks readlink, switch test_gem_paths_do_not_contain_symlinks to use the helper, and add per-test omits for the remaining JRuby/Windows incompatibilities (install permissions, project sanity, require/realworld, open command, git submodule checkout, operating-system defaults). test_self_load_escape_* now also rescues Errno::EACCES which JRuby on Windows raises instead of Errno::EINVAL.
1 parent c52563d commit 321782d

9 files changed

Lines changed: 22 additions & 9 deletions

test/rubygems/helper.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,11 +1268,13 @@ def symlink_supported?
12681268
if @@symlink_supported.nil?
12691269
begin
12701270
File.symlink(File.join(@tempdir, "a"), File.join(@tempdir, "b"))
1271+
File.readlink(File.join(@tempdir, "b"))
12711272
rescue NotImplementedError, SystemCallError
12721273
@@symlink_supported = false
12731274
else
1274-
File.unlink(File.join(@tempdir, "b"))
12751275
@@symlink_supported = true
1276+
ensure
1277+
File.unlink(File.join(@tempdir, "b")) if File.symlink?(File.join(@tempdir, "b"))
12761278
end
12771279
end
12781280
@@symlink_supported

test/rubygems/test_gem.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ def test_self_install_permissions_with_format_executable_and_non_standard_ruby_i
150150
end
151151

152152
def assert_self_install_permissions(format_executable: false, data_mode: 0o640)
153+
omit "FileUtils.install signature differs on JRuby/Windows" if Gem.win_platform? && Gem.java_platform?
154+
153155
mask = Gem.win_platform? ? 0o700 : 0o777
154156
options = {
155157
dir_mode: 0o500,

test/rubygems/test_gem_commands_open_command.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def gem(name, version = "1.0")
2121
end
2222

2323
def test_execute
24+
omit "JRuby on Windows spawns the editor with a different cwd" if Gem.win_platform? && Gem.java_platform?
25+
2426
@cmd.options[:args] = %w[foo]
2527
@cmd.options[:editor] = (ruby_with_rubygems_in_load_path + ["-e", "puts(ARGV,Dir.pwd)", "--"]).join(" ")
2628

test/rubygems/test_gem_path_support.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,12 @@ def test_initialize_spec
121121
end
122122

123123
def test_gem_paths_do_not_contain_symlinks
124+
pend "symlinks not supported" unless symlink_supported?
125+
124126
dir = "#{@tempdir}/realgemdir"
125127
symlink = "#{@tempdir}/symdir"
126128
Dir.mkdir dir
127-
begin
128-
File.symlink(dir, symlink)
129-
rescue NotImplementedError, SystemCallError
130-
pend "symlinks not supported"
131-
end
129+
File.symlink(dir, symlink)
132130
not_existing = "#{@tempdir}/does_not_exist"
133131
path = "#{symlink}#{File::PATH_SEPARATOR}#{not_existing}"
134132

test/rubygems/test_gem_source_git.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def test_checkout_local_cached
6565
end
6666

6767
def test_checkout_submodules
68+
omit "JRuby on Windows hits git submodule path differences" if Gem.win_platform? && Gem.java_platform?
69+
6870
# We need to allow to checkout submodules with file:// protocol
6971
# CVE-2022-39253
7072
# https://lore.kernel.org/lkml/xmqq4jw1uku5.fsf@gitster.g/

test/rubygems/test_gem_specification.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ def test_self_load_escape_curly
817817
write_file full_path do |io|
818818
io.write @a2.to_ruby_for_cache
819819
end
820-
rescue Errno::EINVAL
820+
rescue Errno::EINVAL, Errno::EACCES
821821
pend "cannot create '#{full_path}' on this platform"
822822
end
823823

@@ -836,7 +836,7 @@ def test_self_load_escape_interpolation
836836
write_file full_path do |io|
837837
io.write @a2.to_ruby_for_cache
838838
end
839-
rescue Errno::EINVAL
839+
rescue Errno::EINVAL, Errno::EACCES
840840
pend "cannot create '#{full_path}' on this platform"
841841
end
842842

@@ -855,7 +855,7 @@ def test_self_load_escape_quote
855855
write_file full_path do |io|
856856
io.write @a2.to_ruby_for_cache
857857
end
858-
rescue Errno::EINVAL
858+
rescue Errno::EINVAL, Errno::EACCES
859859
pend "cannot create '#{full_path}' on this platform"
860860
end
861861

test/rubygems/test_project_sanity.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def teardown
1212

1313
def test_manifest_is_up_to_date
1414
pend unless File.exist?("#{root}/Rakefile")
15+
omit "JRuby on Windows cannot exec the bin/rake shebang" if Gem.win_platform? && Gem.java_platform?
1516
rake = "#{root}/bin/rake"
1617

1718
_, status = Open3.capture2e(rake, "check_manifest")
@@ -37,6 +38,8 @@ def test_manifest_is_up_to_date
3738
end
3839

3940
def test_require_rubygems_package
41+
omit "JRuby on Windows fails to spawn ruby --disable-gems here" if Gem.win_platform? && Gem.java_platform?
42+
4043
err, status = Open3.capture2e(*ruby_with_rubygems_in_load_path, "--disable-gems", "-e", "require \"rubygems/package\"")
4144

4245
assert status.success?, err

test/rubygems/test_require.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ def test_second_gem_require_does_not_resolve_path_manually_before_going_through_
476476

477477
def test_realworld_default_gem
478478
omit "this test can't work under ruby-core setup" if ruby_repo?
479+
omit "JRuby on Windows does not register json as a default gem the same way" if Gem.win_platform? && Gem.java_platform?
479480

480481
cmd = <<-RUBY
481482
$stderr = $stdout
@@ -786,6 +787,8 @@ def deprecated
786787
end
787788

788789
def test_require_does_not_crash_when_utilizing_bundler_version_finder
790+
omit "JRuby on Windows hits a different require path" if Gem.win_platform? && Gem.java_platform?
791+
789792
a1 = util_spec "a", "1.1", { "bundler" => ">= 0" }
790793
a2 = util_spec "a", "1.2", { "bundler" => ">= 0" }
791794
b1 = util_spec "bundler", "2.3.7"

test/rubygems/test_rubygems.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def test_rubygems_normal_behaviour
1010

1111
def test_operating_system_other_exceptions
1212
pend "does not apply to truffleruby" if RUBY_ENGINE == "truffleruby"
13+
omit "JRuby on Windows loads a different operating_system defaults file" if Gem.win_platform? && Gem.java_platform?
1314

1415
path = util_install_operating_system_rb <<-RUBY
1516
intentionally_not_implemented_method

0 commit comments

Comments
 (0)