Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

Commit 7b4fa54

Browse files
committed
Support Elixir 1.10
This works around the use of the new temporary directory feature in Elixir 1.11's ex_unit and the Elixir 1.11 Task.await_all/2 call. These changes only affected the unit tests.
1 parent d9859c6 commit 7b4fa54

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

test/bakeware_test.exs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,25 @@ defmodule BakewareTest do
3131
:ok
3232
end
3333

34+
defp fix_tmp_dir(tmp_dir) when is_binary(tmp_dir) do
35+
tmp_dir
36+
end
37+
38+
defp fix_tmp_dir(_tmp_dir) do
39+
# Elixir 1.10 and earlier
40+
path = Path.join(["tmp", "BakewareTest", Integer.to_string(:rand.uniform(10000))])
41+
File.mkdir_p!(path)
42+
path
43+
end
44+
3445
test "creates executable" do
3546
assert File.exists?(@rel_test_binary)
3647
end
3748

3849
@tag :tmp_dir
3950
test "install creates expected directories", %{tmp_dir: tmp_dir} do
51+
tmp_dir = fix_tmp_dir(tmp_dir)
52+
4053
{_, 0} =
4154
System.cmd(@rel_test_binary, ["--bw-install"],
4255
env: [{"BAKEWARE_CACHE", Path.absname(tmp_dir)}]
@@ -73,6 +86,8 @@ defmodule BakewareTest do
7386

7487
@tag :tmp_dir
7588
test "run bakeware executable", %{tmp_dir: tmp_dir} do
89+
tmp_dir = fix_tmp_dir(tmp_dir)
90+
7691
{result, 0} =
7792
System.cmd(@rel_test_binary, [], env: [{"BAKEWARE_CACHE", Path.absname(tmp_dir)}])
7893

@@ -87,18 +102,22 @@ defmodule BakewareTest do
87102

88103
@tag :tmp_dir
89104
test "run bakeware executable simultaneously", %{tmp_dir: tmp_dir} do
105+
tmp_dir = fix_tmp_dir(tmp_dir)
106+
90107
# Test out launching the executable multiple times simultaneously.
91108
# Everything should run ok, but internally, the extractors will
92109
# step on each other and resolve the situation.
93-
94110
tasks =
95-
for _ <- 0..3 do
111+
for _ <- 1..4 do
96112
Task.async(fn ->
97113
System.cmd(@rel_test_binary, [], env: [{"BAKEWARE_CACHE", Path.absname(tmp_dir)}])
98114
end)
99115
end
100116

101-
results = Task.await_many(tasks, 30000)
117+
results =
118+
for task <- tasks do
119+
Task.await(task, 30000)
120+
end
102121

103122
for result <- results do
104123
assert result == {"Hello, OTP Application!\n", 0}

0 commit comments

Comments
 (0)