File tree Expand file tree Collapse file tree
lib/ruby_lsp/test_reporters Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ module RubyLsp
99 class LspReporter
1010 include Singleton
1111
12+ #: bool
13+ attr_reader :invoked_shutdown
14+
1215 #: -> void
1316 def initialize
1417 port = ENV [ "RUBY_LSP_REPORTER_PORT" ]
@@ -19,6 +22,8 @@ def initialize
1922 require "stringio"
2023 StringIO . new
2124 end #: IO | StringIO
25+
26+ @invoked_shutdown = false #: bool
2227 end
2328
2429 #: -> void
@@ -34,6 +39,8 @@ def shutdown
3439 # reporter, use `shutdown` instead
3540 #: -> void
3641 def internal_shutdown
42+ @invoked_shutdown = true
43+
3744 send_message ( "finish" )
3845 @io . close
3946 end
@@ -161,4 +168,10 @@ def send_message(method_name, **params)
161168 File . write ( File . join ( ".ruby-lsp" , "coverage_result.json" ) , coverage_results . to_json )
162169 RubyLsp ::LspReporter . instance . internal_shutdown
163170 end
171+ elsif ENV [ "RUBY_LSP_TEST_RUNNER" ] && !ENV [ "RUBY_LSP_ENV" ] == "test"
172+ at_exit do
173+ # If the test process crashed immediately without finishing the tests, we still need to tell the extension that the
174+ # execution ended so that it can clean up
175+ RubyLsp ::LspReporter . instance . internal_shutdown unless RubyLsp ::LspReporter . instance . invoked_shutdown
176+ end
164177end
You can’t perform that action at this time.
0 commit comments