-
-
Notifications
You must be signed in to change notification settings - Fork 187
/
release_test.exs
97 lines (77 loc) · 3.07 KB
/
release_test.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
defmodule Nerves.ReleaseTest do
use NervesTest.Case, async: true
@tag :tmp_dir
@tag :release
test "rootfs priorities from valid bootfile", %{tmp_dir: tmp} do
{path, env} = compile_fixture!("release_app", tmp, [], [])
opts = [cd: path, env: [{"MIX_ENV", "prod"} | env], stderr_to_stdout: true]
{_, 0} = System.cmd("mix", ["release"], opts)
expected = """
srv/erlang/releases/0.1.0/consolidated/Elixir.String.Chars.beam 32000
srv/erlang/releases/0.1.0/consolidated/Elixir.List.Chars.beam 31999
srv/erlang/releases/0.1.0/consolidated/Elixir.Inspect.beam 31998
srv/erlang/releases/0.1.0/consolidated/Elixir.Enumerable.beam 31997
srv/erlang/releases/0.1.0/consolidated/Elixir.Collectable.beam 31996
"""
# TODO: Adjust this test to better check ordering
# Asserting a specific generated priorities is brittle as it drastically
# changes with each Elixir version. The ordering is also currently suboptimal.
# For now, just check the file begins with the consolidated protocols
# until the ordering is optimized and a better test can be constructed
assert Path.join(path, "_build/prod/nerves/rootfs.priorities")
|> File.read!()
|> String.starts_with?(expected)
end
@tag :tmp_dir
@tag :release
test "requires vm.args.eex", %{tmp_dir: tmp} do
{path, env} = compile_fixture!("release_app", tmp, [], [])
opts = [
cd: path,
env: [{"MIX_ENV", "prod"}, {"REL_TEMPLATES_PATH", Path.join(tmp, "no-rel")} | env],
stderr_to_stdout: true
]
assert {output, 1} = System.cmd("mix", ["release"], opts)
assert output =~ ~r/Missing required .*vm\.args\.eex/
end
@tag :tmp_dir
@tag :release
test "fails if vm.args has incompatible shell setting", %{tmp_dir: tmp} do
{path, env} = compile_fixture!("release_app", tmp, [], [])
rel_templates_path = Path.join(tmp, "bad_rel")
assert :ok = File.mkdir_p(rel_templates_path)
bad_vm_args = Path.join(rel_templates_path, "vm.args.eex")
expected =
if Version.match?(System.version(), ">= 1.15.0") do
assert :ok = File.write(bad_vm_args, "# test.vm.args\n-user Elixir.IEx.CLI")
~r"""
Please remove the following lines:
\* #{bad_vm_args}:2:
-user Elixir.IEx.CLI
Please ensure the following lines are in #{bad_vm_args}:
-user elixir
-run elixir start_iex
"""
else
assert :ok =
File.write(bad_vm_args, "# test.vm.args\n-user elixir\n-run elixir start_iex")
~r"""
Please remove the following lines:
\* #{bad_vm_args}:2:
-user elixir
\* #{bad_vm_args}:3:
-run elixir start_iex
Please ensure the following lines are in #{bad_vm_args}:
-user Elixir.IEx.CLI
"""
end
opts = [
cd: path,
env: [{"MIX_ENV", "prod"}, {"REL_TEMPLATES_PATH", rel_templates_path} | env],
stderr_to_stdout: true
]
{output, 1} = System.cmd("mix", ["release"], opts)
assert output =~ "Incompatible vm.args"
assert output =~ expected
end
end