Skip to content

Commit 7400668

Browse files
committed
chore: write fixtures at runtime
1 parent f469a6d commit 7400668

File tree

14 files changed

+85
-108
lines changed

14 files changed

+85
-108
lines changed

Diff for: .github/workflows/ci.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ jobs:
3838
- name: Start EPMD
3939
run: epmd -daemon
4040

41-
- name: Compile test project
42-
run: (cd test/support/project && mix deps.get && mix compile)
43-
4441
- name: Compile
4542
env:
4643
MIX_ENV: test

Diff for: mix.exs

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ defmodule NextLS.MixProject do
77
description: "The language server for Elixir that just works",
88
version: "0.4.0",
99
elixir: "~> 1.13",
10+
elixirc_paths: elixirc_paths(Mix.env()),
1011
start_permanent: Mix.env() == :prod,
1112
package: package(),
1213
deps: deps(),
@@ -27,6 +28,9 @@ defmodule NextLS.MixProject do
2728
]
2829
end
2930

31+
defp elixirc_paths(:test), do: ["lib", "test/support"]
32+
defp elixirc_paths(_), do: ["lib"]
33+
3034
# Run "mix help deps" to learn about dependencies.
3135
defp deps do
3236
[

Diff for: test/next_ls/runtime_test.exs

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
defmodule NextLs.RuntimeTest do
22
use ExUnit.Case, async: true
3+
import NextLS.Support.Utils
34

45
@moduletag :tmp_dir
56

@@ -9,7 +10,17 @@ defmodule NextLs.RuntimeTest do
910
alias NextLS.Runtime
1011

1112
setup %{tmp_dir: tmp_dir} do
12-
File.cp_r!("test/support/project", tmp_dir)
13+
File.write!(Path.join(tmp_dir, "mix.exs"), mix_exs())
14+
File.mkdir_p!(Path.join(tmp_dir, "lib"))
15+
16+
File.write!(Path.join(tmp_dir, "lib/bar.ex"), """
17+
defmodule Bar do
18+
defstruct [:foo]
19+
20+
def foo(arg1) do
21+
end
22+
end
23+
""")
1324

1425
{:ok, logger} =
1526
Task.start_link(fn ->

Diff for: test/next_ls_test.exs

+38-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,48 @@
11
defmodule NextLSTest do
22
use ExUnit.Case, async: true
3+
import NextLS.Support.Utils
34

45
@moduletag :tmp_dir
56

67
import GenLSP.Test
78

89
setup %{tmp_dir: tmp_dir} do
9-
File.cp_r!("test/support/project", tmp_dir)
10+
File.write!(Path.join(tmp_dir, "mix.exs"), mix_exs())
11+
File.mkdir_p!(Path.join(tmp_dir, "lib"))
12+
13+
File.write!(Path.join(tmp_dir, "lib/bar.ex"), """
14+
defmodule Bar do
15+
defstruct [:foo]
16+
17+
def foo(arg1) do
18+
end
19+
end
20+
""")
21+
22+
File.write!(Path.join(tmp_dir, "lib/code_action.ex"), """
23+
defmodule Foo.CodeAction do
24+
# some comment
25+
26+
defmodule NestedMod do
27+
def foo do
28+
:ok
29+
end
30+
end
31+
end
32+
""")
33+
34+
File.write!(Path.join(tmp_dir, "lib/foo.ex"), """
35+
defmodule Foo do
36+
end
37+
""")
38+
39+
File.write!(Path.join(tmp_dir, "lib/project.ex"), """
40+
defmodule Project do
41+
def hello do
42+
:world
43+
end
44+
end
45+
""")
1046

1147
File.rm_rf!(Path.join(tmp_dir, ".elixir-tools"))
1248

@@ -69,9 +105,7 @@ defmodule NextLSTest do
69105
assert_result 2, nil
70106
end
71107

72-
test "returns method not found for unimplemented requests", %{
73-
client: client
74-
} do
108+
test "returns method not found for unimplemented requests", %{client: client} do
75109
id = System.unique_integer([:positive])
76110

77111
assert :ok ==

Diff for: test/support/project/.formatter.exs

-4
This file was deleted.

Diff for: test/support/project/.gitignore

-26
This file was deleted.

Diff for: test/support/project/README.md

-21
This file was deleted.

Diff for: test/support/project/lib/bar.ex

-6
This file was deleted.

Diff for: test/support/project/lib/code_action.ex

-9
This file was deleted.

Diff for: test/support/project/lib/foo.ex

-2
This file was deleted.

Diff for: test/support/project/lib/project.ex

-5
This file was deleted.

Diff for: test/support/project/mix.exs

-25
This file was deleted.

Diff for: test/support/project/mix.lock

-2
This file was deleted.

Diff for: test/support/utils.ex

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
defmodule NextLS.Support.Utils do
2+
def mix_exs do
3+
"""
4+
defmodule Project.MixProject do
5+
use Mix.Project
6+
7+
def project do
8+
[
9+
app: :project,
10+
version: "0.1.0",
11+
elixir: "~> 1.10",
12+
start_permanent: Mix.env() == :prod,
13+
deps: deps()
14+
]
15+
end
16+
17+
# Run "mix help compile.app" to learn about applications.
18+
def application do
19+
[
20+
extra_applications: [:logger]
21+
]
22+
end
23+
24+
# Run "mix help deps" to learn about dependencies.
25+
defp deps do
26+
[]
27+
end
28+
end
29+
"""
30+
end
31+
end

0 commit comments

Comments
 (0)