Skip to content

Commit 3611e5a

Browse files
committed
another attempt at fixing tests
1 parent 1ff0c46 commit 3611e5a

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

apps/language_server/lib/language_server/json_rpc_logger_backend.ex

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ defmodule Logger.Backends.JsonRpc do
107107
format = Logger.Formatter.compile(Keyword.get(config, :format))
108108
metadata = Keyword.get(config, :metadata, []) |> configure_metadata()
109109

110-
Code.ensure_loaded!(ElixirLS.Utils.WireProtocol)
111-
112110
%{
113111
state
114112
| format: format,
@@ -127,8 +125,11 @@ defmodule Logger.Backends.JsonRpc do
127125
end
128126

129127
defp log_event(level, msg, ts, md, state) do
130-
output = format_event(level, msg, ts, md, state) |> IO.chardata_to_string()
131-
ElixirLS.LanguageServer.JsonRpc.log_message(elixir_log_level_to_lsp(level), output)
128+
if function_exported?(ElixirLS.Utils.WireProtocol, :send, 1) do
129+
output = format_event(level, msg, ts, md, state) |> IO.chardata_to_string()
130+
ElixirLS.LanguageServer.JsonRpc.log_message(elixir_log_level_to_lsp(level), output)
131+
end
132+
132133
state
133134
end
134135

apps/language_server/test/source_file/path_test.exs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,20 @@ defmodule ElixirLS.LanguageServer.SourceFile.PathTest do
145145
test "windows path" do
146146
if is_windows() do
147147
drive_letter = Path.expand("/") |> String.split(":") |> hd()
148-
assert "file:///#{drive_letter}%3A/win/path" == to_uri("c:/win/path")
149-
assert "file:///#{drive_letter}%3A/win/path" == to_uri("C:/win/path")
150-
assert "file:///#{drive_letter}%3A/win/path" == to_uri("c:/win/path/")
148+
assert "file:///c%3A/win/path" == to_uri("c:/win/path")
149+
assert "file:///c%3A/win/path" == to_uri("C:/win/path")
150+
assert "file:///c%3A/win/path" == to_uri("c:/win/path/")
151+
152+
# this path may actually expand to other drive letter than C: (on GHA runner it expands to D:)
151153
assert "file:///#{drive_letter}%3A/win/path" == to_uri("/c:/win/path")
152154

153-
assert "file:///#{drive_letter}%3A/win/path" == to_uri("c:\\win\\path")
154-
assert "file:///#{drive_letter}%3A/win/path" == to_uri("c:\\win/path")
155+
assert "file:///c%3A/win/path" == to_uri("c:\\win\\path")
156+
assert "file:///c%3A/win/path" == to_uri("c:\\win/path")
155157

156-
assert "file:///#{drive_letter}%3A/test%20with%20%25/path" ==
158+
assert "file:///c%3A/test%20with%20%25/path" ==
157159
to_uri("c:\\test with %\\path")
158160

159-
assert "file:///#{drive_letter}%3A/test%20with%20%2525/c%23code" ==
161+
assert "file:///c%3A/test%20with%20%2525/c%23code" ==
160162
to_uri("c:\\test with %25\\c#code")
161163
end
162164
end

0 commit comments

Comments
 (0)