Skip to content

Commit bccfca4

Browse files
committed
Purge Hex before running Mix tests
1 parent 417255f commit bccfca4

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

lib/mix/test/test_helper.exs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
home = Path.expand("../tmp/.home", __DIR__)
2+
File.mkdir_p!(home)
3+
System.put_env("HOME", home)
4+
5+
mix = Path.expand("../tmp/.mix", __DIR__)
6+
File.mkdir_p!(mix)
7+
System.put_env("MIX_HOME", mix)
8+
9+
System.delete_env("XDG_DATA_HOME")
10+
System.delete_env("XDG_CONFIG_HOME")
11+
12+
## Setup Mix
13+
114
Mix.start()
215
Mix.shell(Mix.Shell.Process)
316
Application.put_env(:mix, :colors, enabled: false)
417

518
Logger.remove_backend(:console)
619
Application.put_env(:logger, :backends, [])
720

21+
## Setup ExUnit
22+
823
os_exclude = if match?({:win32, _}, :os.type()), do: [unix: true], else: [windows: true]
924
epmd_exclude = if match?({:win32, _}, :os.type()), do: [epmd: true], else: []
1025
git_exclude = if Mix.SCM.Git.git_version() <= {1, 7, 4}, do: [git_sparse: true], else: []
@@ -212,27 +227,14 @@ defmodule MixTest.Case do
212227
end
213228
end
214229

215-
## Set up globals
216-
217-
home = MixTest.Case.tmp_path(".home")
218-
File.mkdir_p!(home)
219-
System.put_env("HOME", home)
220-
221-
mix = MixTest.Case.tmp_path(".mix")
222-
File.mkdir_p!(mix)
223-
System.put_env("MIX_HOME", mix)
224-
225-
System.delete_env("XDG_DATA_HOME")
226-
System.delete_env("XDG_CONFIG_HOME")
230+
## Set up Rebar fixtures
227231

228232
rebar3_source = System.get_env("REBAR3") || Path.expand("fixtures/rebar3", __DIR__)
229233
[major, minor | _] = String.split(System.version(), ".")
230234
rebar3_target = Path.join([mix, "elixir", "#{major}-#{minor}", "rebar3"])
231235
File.mkdir_p!(Path.dirname(rebar3_target))
232236
File.cp!(rebar3_source, rebar3_target)
233237

234-
## Copy fixtures to tmp
235-
236238
fixtures = ~w(rebar_dep rebar_override)
237239

238240
Enum.each(fixtures, fn fixture ->
@@ -242,12 +244,13 @@ Enum.each(fixtures, fn fixture ->
242244
File.cp_r!(source, dest)
243245
end)
244246

245-
## Generate Git repo fixtures
247+
## Set up Git fixtures
248+
246249
System.cmd("git", ~w[config --global user.email [email protected]])
247250
System.cmd("git", ~w[config --global user.name mix-repo])
248251
System.cmd("git", ~w[config --global init.defaultBranch not-main])
249252

250-
# Git repo
253+
### Git repo
251254
target = Path.expand("fixtures/git_repo", __DIR__)
252255

253256
unless File.dir?(target) do
@@ -329,7 +332,7 @@ unless File.dir?(target) do
329332
end)
330333
end
331334

332-
# Deps on Git repo
335+
### Deps on Git repo
333336
target = Path.expand("fixtures/deps_on_git_repo", __DIR__)
334337

335338
unless File.dir?(target) do
@@ -423,7 +426,7 @@ Enum.each([:invalidapp, :invalidvsn, :noappfile, :nosemver, :ok], fn dep ->
423426
File.mkdir_p!(Path.expand("fixtures/deps_status/deps/#{dep}/.git", __DIR__))
424427
end)
425428

426-
# Archive ebin
429+
### Archive ebin
427430
target = Path.expand("fixtures/archive", __DIR__)
428431

429432
unless File.dir?(Path.join(target, "ebin")) do

0 commit comments

Comments
 (0)