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+
114Mix . start ( )
215Mix . shell ( Mix.Shell.Process )
316Application . put_env ( :mix , :colors , enabled: false )
417
518Logger . remove_backend ( :console )
619Application . put_env ( :logger , :backends , [ ] )
720
21+ ## Setup ExUnit
22+
823os_exclude = if match? ( { :win32 , _ } , :os . type ( ) ) , do: [ unix: true ] , else: [ windows: true ]
924epmd_exclude = if match? ( { :win32 , _ } , :os . type ( ) ) , do: [ epmd: true ] , else: [ ]
1025git_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
213228end
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
228232rebar3_source = System . get_env ( "REBAR3" ) || Path . expand ( "fixtures/rebar3" , __DIR__ )
229233[ major , minor | _ ] = String . split ( System . version ( ) , "." )
230234rebar3_target = Path . join ( [ mix , "elixir" , "#{ major } -#{ minor } " , "rebar3" ] )
231235File . mkdir_p! ( Path . dirname ( rebar3_target ) )
232236File . cp! ( rebar3_source , rebar3_target )
233237
234- ## Copy fixtures to tmp
235-
236238fixtures = ~w( rebar_dep rebar_override)
237239
238240Enum . each ( fixtures , fn fixture ->
@@ -242,12 +244,13 @@ Enum.each(fixtures, fn fixture ->
242244 File . cp_r! ( source , dest )
243245end )
244246
245- ## Generate Git repo fixtures
247+ ## Set up Git fixtures
248+
246249System . cmd ( "git" , ~w[ config --global user.email mix@example.com] )
247250System . cmd ( "git" , ~w[ config --global user.name mix-repo] )
248251System . cmd ( "git" , ~w[ config --global init.defaultBranch not-main] )
249252
250- # Git repo
253+ ### Git repo
251254target = Path . expand ( "fixtures/git_repo" , __DIR__ )
252255
253256unless File . dir? ( target ) do
@@ -329,7 +332,7 @@ unless File.dir?(target) do
329332 end )
330333end
331334
332- # Deps on Git repo
335+ ### Deps on Git repo
333336target = Path . expand ( "fixtures/deps_on_git_repo" , __DIR__ )
334337
335338unless 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__ ) )
424427end )
425428
426- # Archive ebin
429+ ### Archive ebin
427430target = Path . expand ( "fixtures/archive" , __DIR__ )
428431
429432unless File . dir? ( Path . join ( target , "ebin" ) ) do
0 commit comments