Skip to content

Commit 58b471d

Browse files
committed
Fixed flaky test
Changed inline calls of start_link to instead use a setup block using `start_supervised`
1 parent f1b44f9 commit 58b471d

File tree

1 file changed

+12
-42
lines changed

1 file changed

+12
-42
lines changed

apps/language_server/test/providers/execute_command/manipulate_pipes_test.exs

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,20 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ManipulatePipesTest d
2929
end
3030
end
3131

32+
setup do
33+
{:ok, _} =
34+
start_supervised(%{
35+
id: JsonRpcMock,
36+
start:
37+
{JsonRpcMock, :start_link,
38+
[[success_reply: {:ok, %{"applied" => true}}, test_pid: self()]]}
39+
})
40+
41+
:ok
42+
end
43+
3244
describe "execute/2 toPipe" do
3345
test "can pipe remote calls in single lines" do
34-
{:ok, _} =
35-
JsonRpcMock.start_link(success_reply: {:ok, %{"applied" => true}}, test_pid: self())
36-
3746
uri = "file:///some_file.ex"
3847

3948
text = """
@@ -105,9 +114,6 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ManipulatePipesTest d
105114
end
106115

107116
test "can pipe remote calls with multi-line args" do
108-
{:ok, _} =
109-
JsonRpcMock.start_link(success_reply: {:ok, %{"applied" => true}}, test_pid: self())
110-
111117
uri = "file:/some_file.ex"
112118

113119
text = """
@@ -182,9 +188,6 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ManipulatePipesTest d
182188
end
183189

184190
test "can pipe remote calls when there are multi-line args" do
185-
{:ok, _} =
186-
JsonRpcMock.start_link(success_reply: {:ok, %{"applied" => true}}, test_pid: self())
187-
188191
uri = "file:/some_file.ex"
189192

190193
text = """
@@ -486,9 +489,6 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ManipulatePipesTest d
486489
end
487490

488491
test "can pipe local calls in single line" do
489-
{:ok, _} =
490-
JsonRpcMock.start_link(success_reply: {:ok, %{"applied" => true}}, test_pid: self())
491-
492492
uri = "file:/some_file.ex"
493493

494494
text = """
@@ -562,9 +562,6 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ManipulatePipesTest d
562562
end
563563

564564
test "converts function_call_not_found to 3-tuple" do
565-
{:ok, _} =
566-
JsonRpcMock.start_link(success_reply: {:ok, %{"applied" => true}}, test_pid: self())
567-
568565
uri = "file:/some_file.ex"
569566

570567
text = """
@@ -595,9 +592,6 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ManipulatePipesTest d
595592

596593
for {line_sep, test_name_suffix} <- [{"\r\n", "\\r\\n"}, {"\n", "\\n"}] do
597594
test "can pipe correctly when the line separator is #{test_name_suffix}" do
598-
{:ok, _} =
599-
JsonRpcMock.start_link(success_reply: {:ok, %{"applied" => true}}, test_pid: self())
600-
601595
uri = "file:/some_file.ex"
602596

603597
base_code = [
@@ -672,9 +666,6 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ManipulatePipesTest d
672666
end
673667

674668
test "can handle utf 16 characters" do
675-
{:ok, _} =
676-
JsonRpcMock.start_link(success_reply: {:ok, %{"applied" => true}}, test_pid: self())
677-
678669
uri = "file:/some_file.ex"
679670

680671
text = """
@@ -773,9 +764,6 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ManipulatePipesTest d
773764
end
774765

775766
test "can handle multiple calls" do
776-
{:ok, _} =
777-
JsonRpcMock.start_link(success_reply: {:ok, %{"applied" => true}}, test_pid: self())
778-
779767
uri = "file:/some_file.ex"
780768

781769
text = """
@@ -849,9 +837,6 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ManipulatePipesTest d
849837

850838
describe "execute/2 fromPipe" do
851839
test "can unpipe remote calls in single lines" do
852-
{:ok, _} =
853-
JsonRpcMock.start_link(success_reply: {:ok, %{"applied" => true}}, test_pid: self())
854-
855840
uri = "file:/some_file.ex"
856841

857842
text = """
@@ -923,9 +908,6 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ManipulatePipesTest d
923908
end
924909

925910
test "can unpipe remote calls when there are multi-line args" do
926-
{:ok, _} =
927-
JsonRpcMock.start_link(success_reply: {:ok, %{"applied" => true}}, test_pid: self())
928-
929911
uri = "file:/some_file.ex"
930912

931913
text = """
@@ -1000,9 +982,6 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ManipulatePipesTest d
1000982
end
1001983

1002984
test "can unpipe local calls in single line" do
1003-
{:ok, _} =
1004-
JsonRpcMock.start_link(success_reply: {:ok, %{"applied" => true}}, test_pid: self())
1005-
1006985
uri = "file:/some_file.ex"
1007986

1008987
text = """
@@ -1077,9 +1056,6 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ManipulatePipesTest d
10771056

10781057
for {line_sep, test_name_suffix} <- [{"\r\n", "\\r\\n"}, {"\n", "\\n"}] do
10791058
test "can unpipe correctly when the line separator is #{test_name_suffix}" do
1080-
{:ok, _} =
1081-
JsonRpcMock.start_link(success_reply: {:ok, %{"applied" => true}}, test_pid: self())
1082-
10831059
uri = "file:/some_file.ex"
10841060

10851061
base_code = [
@@ -1152,9 +1128,6 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ManipulatePipesTest d
11521128
end
11531129

11541130
test "can handle multiple calls in no-op execution" do
1155-
{:ok, _} =
1156-
JsonRpcMock.start_link(success_reply: {:ok, %{"applied" => true}}, test_pid: self())
1157-
11581131
uri = "file:/some_file.ex"
11591132

11601133
text = """
@@ -1187,9 +1160,6 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.ManipulatePipesTest d
11871160
end
11881161

11891162
test "can handle utf 16 characters" do
1190-
{:ok, _} =
1191-
JsonRpcMock.start_link(success_reply: {:ok, %{"applied" => true}}, test_pid: self())
1192-
11931163
uri = "file:/some_file.ex"
11941164

11951165
text = """

0 commit comments

Comments
 (0)