Skip to content

Commit 927a992

Browse files
committed
[GR-40333] Ruby 3.1 $LOAD_PATH.path_resolve_features_path does not raise
PullRequest: truffleruby/3685
2 parents 70e0939 + 6101dfb commit 927a992

File tree

5 files changed

+23
-27
lines changed

5 files changed

+23
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Compatibility:
8787
* Add `Integer.try_convert` (#2733, @moste00, @eregon).
8888
* Support optional `:in` keyword argument for `Time.now` and `Time.new` (#2733, @andrykonchin).
8989
* Add optional `Hash` argument to `Enumerable#tally` (#2733, @andrykonchin).
90+
* Update `$LOAD_PATH.resolve_feature_path` to return `nil` instead of raising `LoadError` when feature isn't found (#2733, @andrykonchin).
9091

9192
Performance:
9293

spec/tags/language/predefined_tags.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ slow:The predefined global constant ARGV contains Strings encoded in locale Enco
66
slow:Global variable $0 is the path given as the main script and the same as __FILE__
77
slow:Global variable $? is thread-local
88
slow:Global variable $0 actually sets the program name
9-
fails:$LOAD_PATH.resolve_feature_path return nil if feature cannot be found

src/main/ruby/truffleruby/core/truffle/kernel_operations.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,10 @@ def self.define_read_only_global(name, getter)
5555

5656
def $LOAD_PATH.resolve_feature_path(file_name)
5757
path = Truffle::Type.coerce_to_path(file_name)
58-
_status, path, ext = Truffle::FeatureLoader.find_feature_or_file(path, false)
59-
if Primitive.nil?(ext)
60-
raise Truffle::KernelOperations.load_error(file_name)
61-
else
62-
[ext, path]
63-
end
58+
status, path, ext = Truffle::FeatureLoader.find_feature_or_file(path, false)
59+
60+
return nil if status == :not_found
61+
[ext, path]
6462
end
6563

6664
# The runtime needs to access these values, so we want them to be set in the variable storage.

test/mri/excludes/TestRequire.rb

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
exclude :test_load, "needs investigation"
2-
exclude :test_race_exception, "needs investigation"
3-
exclude :test_require_changed_home, "needs investigation"
4-
exclude :test_require_invalid_shared_object, "needs investigation"
5-
exclude :test_require_path_home_1, "needs investigation"
6-
exclude :test_require_path_home_2, "needs investigation"
7-
exclude :test_require_path_home_3, "needs investigation"
8-
exclude :test_require_to_path_redefined_in_load_path, "needs investigation"
9-
exclude :test_require_to_str_redefined_in_load_path, "needs investigation"
10-
exclude :test_require_too_long_filename, "needs investigation"
11-
exclude :test_throw_while_loading, "needs investigation"
12-
exclude :test_load_ospath, "needs investigation"
13-
exclude :test_loading_fifo_fd_leak, "needs investigation"
14-
exclude :test_loading_fifo_threading_raise, "needs investigation"
15-
exclude :test_loading_fifo_threading_success, "needs investigation"
16-
exclude :test_require_nonascii_path, "needs investigation"
17-
exclude :test_require_nonascii_path_shift_jis, "needs investigation"
1+
exclude :test_require_path_home_2, "pid 90932 exit 1"
2+
exclude :test_race_exception, "Expected /circular require/ to match \"\"."
3+
exclude :test_require_invalid_shared_object, "[LoadError] exception expected, not #<NameError: undefined local variable or method `dummy' for main:Object>."
4+
exclude :test_require_to_path_redefined_in_load_path, "[ruby-core:47970]"
5+
exclude :test_require_changed_home, "[ruby-core:47970]"
6+
exclude :test_require_path_home_1, "pid 90994 exit 1"
187
exclude :test_relative_symlink_realpath, "bug17885 [ruby-core:104010]."
19-
exclude :test_load_into_module, "<[:b]> expected but was"
20-
exclude :test_resolve_feature_path_with_missing_feature, "LoadError: cannot load such file -- superkalifragilisticoespialidoso"
8+
exclude :test_require_path_home_3, "pid 90997 exit 1"
9+
exclude :test_require_too_long_filename, "Expected 2 to be <= 1."
10+
exclude :test_require_to_str_redefined_in_load_path, "[ruby-core:47970]"
11+
exclude :test_require_nonascii_path_shift_jis, "LoadError: cannot load such file -- enc/trans/single_byte"
12+
exclude :test_load_ospath, "Encoding::CompatibilityError: incompatible encoding regexp match (Windows-31J regexp with UTF-8 string)"
13+
exclude :test_loading_fifo_threading_raise, "Timeout::Error: execution of assert_separately expired (took longer than 9 seconds)"
14+
exclude :test_loading_fifo_threading_success, "Timeout::Error: execution of assert_separately expired (took longer than 9 seconds)"
15+
exclude :test_loading_fifo_fd_leak, "Timeout::Error: execution of assert_separately expired (took longer than 9 seconds)"
16+
exclude :test_require_nonascii_path, "LoadError: cannot load such file -- enc/trans/single_byte"

tool/parse_mri_errors.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@
5555

5656
FileUtils.mkdir_p(File.dirname(file))
5757
lines = File.exist?(file) ? File.readlines(file) : []
58-
if i = lines.index { |line| line.start_with?(prefix) }
58+
59+
# we need the ',' to handle a case when one test name is a substring of another test name
60+
if i = lines.index { |line| line.start_with?(prefix + ",") }
5961
puts "already excluded: #{class_name}##{test_method}"
6062
lines[i] = new_line
6163
else

0 commit comments

Comments
 (0)