Skip to content

Commit

Permalink
DEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Oct 31, 2024
1 parent e369406 commit 1e03db2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ruby_lsp/ruby_lsp_rails/runner_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def read_response
break if content_length.nonzero?

failed_headers << headers
log_message(
$stderr.puts(
"Ruby LSP Rails expected message headers but got: #{headers}. Trying again...",
type: Constant::MessageType::WARNING,
)
Expand All @@ -305,7 +305,7 @@ def read_response
#{failed_headers.join("\n")}
MESSAGE

log_message(message, type: Constant::MessageType::WARNING)
$stderr.puts(message, type: Constant::MessageType::WARNING)
return
end

Expand Down
27 changes: 27 additions & 0 deletions test/ruby_lsp_rails/launch_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# typed: true
# frozen_string_literal: true

require "test_helper"

module RubyLsp
module Rails
class LaunchTest < ActiveSupport::TestCase
test "launching the client succeeds" do
outgoing_queue = Thread::Queue.new

client = RunnerClient.create_client(outgoing_queue)
refute_instance_of(NullClient, client)

first = pop_log_notification(outgoing_queue, Constant::MessageType::LOG)
assert_equal("Ruby LSP Rails booting server", first.params.message)

second = pop_log_notification(outgoing_queue, Constant::MessageType::LOG)
assert_match("Finished booting Ruby LSP Rails server", second.params.message)

client.shutdown
assert_predicate(client, :stopped?)
outgoing_queue.close
end
end
end
end
8 changes: 8 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,13 @@ def pop_result(server)
)
T.cast(result, RubyLsp::Result)
end

def pop_log_notification(message_queue, type)
log = message_queue.pop
return log if log.params.type == type

log = message_queue.pop until log.params.type == type
log
end
end
end

0 comments on commit 1e03db2

Please sign in to comment.