Skip to content

Commit decdc31

Browse files
committed
fix tests
1 parent 42a88db commit decdc31

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

apps/language_server/lib/language_server/providers/execute_command/get_ex_unit_tests_in_file.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.GetExUnitTestsInFile
1010
{:ok, tests} ->
1111
{:ok, tests}
1212

13-
{:error, reason} ->
13+
{:error, _reason} ->
14+
# TODO catch only Compile and Syntax errors?
1415
{:ok, []}
1516
end
1617
end

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.GetExUnitTestsInFileT
4747
end
4848

4949
@tag fixture: true
50-
test "return error when file fails to compile" do
50+
test "return empty when file fails to compile" do
5151
in_fixture(Path.join(__DIR__, "../../../test_fixtures"), "project_with_tests", fn ->
5252
uri = SourceFile.Path.to_uri(Path.join(File.cwd!(), "test/error_test.exs"))
5353

54-
assert {:error, :server_error, "Cannot get tests in file: %TokenMissingError" <> _, true} =
54+
assert {:ok, []} =
5555
GetExUnitTestsInFile.execute([uri], nil)
5656
end)
5757
end

apps/language_server/test/providers/formatting_test.exs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
115115
@tag :fixture
116116
test "Formats a file with LF line endings" do
117117
in_fixture(Path.join(__DIR__, ".."), "formatter", fn ->
118-
MixProject.store()
118+
store_mix_cache()
119119
path = "lib/file.ex"
120120
uri = SourceFile.Path.to_uri(path)
121121

@@ -166,7 +166,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
166166
@tag :fixture
167167
test "Formats a file with CRLF line endings" do
168168
in_fixture(Path.join(__DIR__, ".."), "formatter", fn ->
169-
MixProject.store()
169+
store_mix_cache()
170170
path = "lib/file.ex"
171171
uri = SourceFile.Path.to_uri(path)
172172

@@ -254,7 +254,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
254254
@tag :fixture
255255
test "elixir formatter does not support CR line endings" do
256256
in_fixture(Path.join(__DIR__, ".."), "formatter", fn ->
257-
MixProject.store()
257+
store_mix_cache()
258258
path = "lib/file.ex"
259259
uri = SourceFile.Path.to_uri(path)
260260

@@ -286,7 +286,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
286286
@tag :fixture
287287
test "formatting preserves line indings inside a string" do
288288
in_fixture(Path.join(__DIR__, ".."), "formatter", fn ->
289-
MixProject.store()
289+
store_mix_cache()
290290
path = "lib/file.ex"
291291
uri = SourceFile.Path.to_uri(path)
292292

@@ -342,7 +342,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
342342
@tag :fixture
343343
test "returns an error when formatting a file with a syntax error" do
344344
in_fixture(Path.join(__DIR__, ".."), "formatter", fn ->
345-
MixProject.store()
345+
store_mix_cache()
346346
path = "lib/file.ex"
347347
uri = SourceFile.Path.to_uri(path)
348348

@@ -372,7 +372,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
372372
@tag :fixture
373373
test "Proper utf-16 format: emoji 😀" do
374374
in_fixture(Path.join(__DIR__, ".."), "formatter", fn ->
375-
MixProject.store()
375+
store_mix_cache()
376376
path = "lib/file.ex"
377377
uri = SourceFile.Path.to_uri(path)
378378

@@ -412,7 +412,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
412412
@tag :fixture
413413
test "Proper utf-16 format: emoji 🏳️‍🌈" do
414414
in_fixture(Path.join(__DIR__, ".."), "formatter", fn ->
415-
MixProject.store()
415+
store_mix_cache()
416416
path = "lib/file.ex"
417417
uri = SourceFile.Path.to_uri(path)
418418

@@ -452,7 +452,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
452452
@tag :fixture
453453
test "Proper utf-16 format: zalgo" do
454454
in_fixture(Path.join(__DIR__, ".."), "formatter", fn ->
455-
MixProject.store()
455+
store_mix_cache()
456456
path = "lib/file.ex"
457457
uri = SourceFile.Path.to_uri(path)
458458

@@ -492,7 +492,7 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
492492
@tag :fixture
493493
test "honors :inputs when deciding to format" do
494494
in_fixture(Path.join(__DIR__, ".."), "formatter", fn ->
495-
MixProject.store()
495+
store_mix_cache()
496496
project_dir = Path.expand(".")
497497

498498
assert_formatted("file.ex", project_dir)
@@ -544,4 +544,23 @@ defmodule ElixirLS.LanguageServer.Providers.FormattingTest do
544544
File.write!(path, " asd = 1")
545545
Formatting.format(source_file, SourceFile.Path.to_uri(path), project_dir)
546546
end
547+
548+
defp store_mix_cache() do
549+
state = %{
550+
get: Mix.Project.get(),
551+
# project_file: Mix.Project.project_file(),
552+
config: Mix.Project.config(),
553+
# config_files: Mix.Project.config_files(),
554+
config_mtime: Mix.Project.config_mtime(),
555+
umbrella?: Mix.Project.umbrella?(),
556+
apps_paths: Mix.Project.apps_paths(),
557+
# deps_path: Mix.Project.deps_path(),
558+
# deps_apps: Mix.Project.deps_apps(),
559+
# deps_scms: Mix.Project.deps_scms(),
560+
deps_paths: Mix.Project.deps_paths(),
561+
# build_path: Mix.Project.build_path(),
562+
manifest_path: Mix.Project.manifest_path()
563+
}
564+
MixProject.store(state)
565+
end
547566
end

0 commit comments

Comments
 (0)