Skip to content

Commit e2934c0

Browse files
authored
Merge pull request ruby#250 from dylanahsmith/re-raise-load-error-without-path
Re-raise a LoadError that didn't come from require in the test loader
2 parents e5c5ac5 + da34100 commit e2934c0

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/rake/rake_test_loader.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
false
2020
end
2121
rescue LoadError => e
22+
raise unless e.path
2223
abort "\nFile does not exist: #{e.path}\n\n"
2324
end
2425
end

test/test_rake_rake_test_loader.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_pattern
2424
$:.replace orig_loaded_features
2525
end
2626

27-
def test_load_error
27+
def test_load_error_from_require
2828
out, err = capture_io do
2929
ARGV.replace %w[no_such_test_file.rb]
3030

@@ -44,4 +44,18 @@ def test_load_error
4444

4545
assert_match expected, err
4646
end
47+
48+
def test_load_error_raised_explicitly
49+
File.write("error_test.rb", "raise LoadError, 'explicitly raised'")
50+
out, err = capture_io do
51+
ARGV.replace %w[error_test.rb]
52+
53+
exc = assert_raises(LoadError) do
54+
load @loader
55+
end
56+
assert_equal "explicitly raised", exc.message
57+
end
58+
assert_empty out
59+
assert_empty err
60+
end
4761
end

0 commit comments

Comments
 (0)