Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-raise a LoadError that didn't come from require in the test loader #250

Merged
merged 1 commit into from Jan 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/rake/rake_test_loader.rb
Expand Up @@ -19,6 +19,7 @@
false
end
rescue LoadError => e
raise unless e.path
abort "\nFile does not exist: #{e.path}\n\n"
end
end
Expand Down
16 changes: 15 additions & 1 deletion test/test_rake_rake_test_loader.rb
Expand Up @@ -24,7 +24,7 @@ def test_pattern
$:.replace orig_loaded_features
end

def test_load_error
def test_load_error_from_require
out, err = capture_io do
ARGV.replace %w[no_such_test_file.rb]

Expand All @@ -44,4 +44,18 @@ def test_load_error

assert_match expected, err
end

def test_load_error_raised_explicitly
File.write("error_test.rb", "raise LoadError, 'explicitly raised'")
out, err = capture_io do
ARGV.replace %w[error_test.rb]

exc = assert_raises(LoadError) do
load @loader
end
assert_equal "explicitly raised", exc.message
end
assert_empty out
assert_empty err
end
end