Skip to content

Commit 3e3f299

Browse files
committed
EnginesRunner only calls formatter#close if the method exists.
1 parent 50f39e1 commit 3e3f299

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/cc/analyzer/engines_runner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def run(container_listener = ContainerListener.new)
2424

2525
@formatter.finished
2626
ensure
27-
@formatter.close
27+
@formatter.close if @formatter.respond_to?(:close)
2828
end
2929

3030
private

spec/cc/analyzer/engines_runner_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,22 @@ module CC::Analyzer
107107
end
108108
end
109109

110+
describe "when the formatter does not respond to #close" do
111+
let(:config) { config_with_engine("an_engine") }
112+
let(:formatter) do
113+
formatter = stub(started: nil, write: nil, run: nil, finished: nil)
114+
formatter.stubs(:engine_running).yields
115+
formatter
116+
end
117+
let(:registry) { registry_with_engine("an_engine") }
118+
119+
it "does not call #close" do
120+
expect_engine_run("an_engine", "/code", formatter)
121+
FileUtils.stubs(:readable_by_all?).at_least_once.returns(true)
122+
EnginesRunner.new(registry, formatter, "/code", config).run
123+
end
124+
end
125+
110126
def registry_with_engine(name)
111127
{ name => { "image" => "codeclimate/codeclimate-#{name}" } }
112128
end

0 commit comments

Comments
 (0)