Skip to content

Commit 922b6b1

Browse files
committed
Remove warnings on latest Elixir versions
1 parent f9f2cde commit 922b6b1

File tree

2 files changed

+51
-46
lines changed

2 files changed

+51
-46
lines changed

test/support/file_helpers.exs

Lines changed: 0 additions & 45 deletions
This file was deleted.

test/test_helper.exs

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,53 @@
1-
Code.require_file("support/file_helpers.exs", __DIR__)
1+
# Copied from https://github.com/elixir-ecto/ecto/blob/v2.2/integration_test/support/file_helpers.exs
2+
defmodule Support.FileHelpers do
3+
import ExUnit.Assertions
4+
5+
@doc """
6+
Returns the `tmp_path` for tests.
7+
"""
8+
def tmp_path do
9+
Path.expand("../../tmp", __DIR__)
10+
end
11+
12+
@doc """
13+
Executes the given function in a temp directory
14+
tailored for this test case and test.
15+
"""
16+
defmacro in_tmp(fun) do
17+
path =
18+
Path.join([
19+
tmp_path(),
20+
"#{__CALLER__.module}",
21+
"#{elem(__CALLER__.function || raise("no function"), 0)}"
22+
])
23+
24+
quote do
25+
path = unquote(path)
26+
File.rm_rf!(path)
27+
File.mkdir_p!(path)
28+
File.cd!(path, fn -> unquote(fun).(path) end)
29+
end
30+
end
31+
32+
@doc """
33+
Asserts a file was generated.
34+
"""
35+
def assert_file(file) do
36+
assert File.regular?(file), "Expected #{file} to exist, but does not"
37+
end
38+
39+
@doc """
40+
Asserts a file was generated and that it matches a given pattern.
41+
"""
42+
def assert_file(file, callback) when is_function(callback, 1) do
43+
assert_file(file)
44+
callback.(File.read!(file))
45+
end
46+
47+
def assert_file(file, match) do
48+
assert_file(file, &assert(&1 =~ match))
49+
end
50+
end
51+
252
Mix.shell(Mix.Shell.Process)
353
ExUnit.start()

0 commit comments

Comments
 (0)