Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/typeprof/core/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ def batch(files, output)
output.puts "# failed to analyze: #{ file }"
false
end
rescue => e
output.puts "# error: #{ file }"
raise e
end
if @options[:display_indicator]
$stderr << "\r\e[K"
Expand Down
25 changes: 25 additions & 0 deletions test/core/service_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require_relative "../helper"
require "stringio"
require "tempfile"

module TypeProf::Core
class ServiceTest < Test::Unit::TestCase
def test_runtime_error
options = {}
service = TypeProf::Core::Service.new(options)

# Mocking an error while analyzing a file
service.extend(Module.new do
def update_rb_file(*)
raise
end
end)

Tempfile.create(["", ".rb"]) do |f|
output = StringIO.new(+"")
assert_raises(RuntimeError) { service.batch([f.path], output) }
assert_equal("# error: #{f.path}\n", output.string)
end
end
end
end