-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rename compile * add clean * add mix clean as a custom command * add test * fix tests * fix tests
- Loading branch information
1 parent
6c1833c
commit c3b73d8
Showing
8 changed files
with
120 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
apps/language_server/lib/language_server/providers/execute_command/mix_clean.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.MixClean do | ||
@behaviour ElixirLS.LanguageServer.Providers.ExecuteCommand | ||
|
||
@impl ElixirLS.LanguageServer.Providers.ExecuteCommand | ||
def execute([clean_deps?], _state) do | ||
case ElixirLS.LanguageServer.Build.clean(clean_deps?) do | ||
:ok -> {:ok, %{}} | ||
{:error, reason} -> {:error, :server_error, inspect(reason)} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
defmodule A do | ||
def fun do | ||
:ok = B.fun() | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
defmodule B do | ||
def fun do | ||
:error | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
defmodule C do | ||
def myfun do | ||
1 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
defmodule ElixirLS.LanguageServer.Fixtures.Clean.Mixfile do | ||
use Mix.Project | ||
|
||
def project do | ||
[app: :els_clean_test, version: "0.1.0"] | ||
end | ||
|
||
# Configuration for the OTP application | ||
# | ||
# Type "mix help compile.app" for more information | ||
def application do | ||
# Specify extra applications you'll use from Erlang/Elixir | ||
[] | ||
end | ||
end |
47 changes: 47 additions & 0 deletions
47
apps/language_server/test/providers/execute_command/mix_clean_test.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
defmodule ElixirLS.LanguageServer.Providers.ExecuteCommand.MixCleanTest do | ||
alias ElixirLS.LanguageServer.{Server, Protocol, SourceFile} | ||
use ElixirLS.Utils.MixTest.Case, async: false | ||
use Protocol | ||
|
||
setup do | ||
server = ElixirLS.LanguageServer.Test.ServerTestHelpers.start_server() | ||
|
||
{:ok, %{server: server}} | ||
end | ||
|
||
@tag fixture: true | ||
test "mix clean", %{server: server} do | ||
in_fixture(Path.join(__DIR__, "../.."), "clean", fn -> | ||
root_uri = SourceFile.path_to_uri(File.cwd!()) | ||
Server.receive_packet(server, initialize_req(1, root_uri, %{})) | ||
|
||
Server.receive_packet( | ||
server, | ||
did_change_configuration(%{ | ||
"elixirLS" => %{"dialyzerEnabled" => false} | ||
}) | ||
) | ||
|
||
assert_receive %{ | ||
"method" => "window/logMessage", | ||
"params" => %{"message" => "Compile took" <> _} | ||
}, | ||
20000 | ||
|
||
path = ".elixir_ls/build/test/lib/els_clean_test/ebin/Elixir.A.beam" | ||
assert File.exists?(path) | ||
|
||
server_instance_id = :sys.get_state(server).server_instance_id | ||
|
||
Server.receive_packet( | ||
server, | ||
execute_command_req(4, "mixClean:#{server_instance_id}", [false]) | ||
) | ||
|
||
res = assert_receive(%{"id" => 4}, 5000) | ||
assert res["result"] == %{} | ||
|
||
refute File.exists?(path) | ||
end) | ||
end | ||
end |