Skip to content

Commit f33c614

Browse files
authored
Make ExUnit tmp_dir absolute (#10826)
1 parent 5668ab2 commit f33c614

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

lib/ex_unit/lib/ex_unit/runner.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ defmodule ExUnit.Runner do
394394
defp create_tmp_dir!(test, extra_path, context) do
395395
module = escape_path(inspect(test.module))
396396
name = escape_path(to_string(test.name))
397-
path = Path.join(["tmp", module, name, extra_path])
397+
path = ["tmp", module, name, extra_path] |> Path.join() |> Path.expand()
398398
File.rm_rf!(path)
399399
File.mkdir_p!(path)
400400
Map.put(context, :tmp_dir, path)

lib/ex_unit/test/ex_unit/case_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,17 @@ defmodule ExUnit.CaseTest.TmpDir do
156156
@moduletag :tmp_dir
157157

158158
test "default path", context do
159-
assert context.tmp_dir == "tmp/ExUnit.CaseTest.TmpDir/test-default-path"
159+
assert context.tmp_dir == Path.expand("tmp/ExUnit.CaseTest.TmpDir/test-default-path")
160160
assert File.ls!(context.tmp_dir) == []
161161
end
162162

163163
test "escapes foo?/0", context do
164-
assert context.tmp_dir == "tmp/ExUnit.CaseTest.TmpDir/test-escapes-foo--0"
164+
assert context.tmp_dir == Path.expand("tmp/ExUnit.CaseTest.TmpDir/test-escapes-foo--0")
165165
end
166166

167167
@tag tmp_dir: "foo/bar"
168168
test "custom path", context do
169-
assert context.tmp_dir == "tmp/ExUnit.CaseTest.TmpDir/test-custom-path/foo/bar"
169+
assert context.tmp_dir == Path.expand("tmp/ExUnit.CaseTest.TmpDir/test-custom-path/foo/bar")
170170
end
171171

172172
@tag tmp_dir: false

lib/mix/test/mix_test.exs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ defmodule MixTest do
7575

7676
Mix.State.put(:install_called?, false)
7777

78-
tmp_dir = Path.expand(tmp_dir)
7978
File.mkdir_p!("#{tmp_dir}/install_test/lib")
8079

8180
File.write!("#{tmp_dir}/install_test/mix.exs", """

0 commit comments

Comments
 (0)