@@ -337,17 +337,14 @@ defmodule Mix.ReleaseTest do
337
337
338
338
test "configures other applications in cascade" , context do
339
339
in_tmp ( context . test , fn ->
340
- app =
340
+ write_app! (
341
+ "my_sample_mode/ebin/my_sample_mode.app" ,
341
342
{ :application , :my_sample_mode ,
342
343
applications: [ :kernel , :stdlib , :elixir , :runtime_tools , :compiler ] ,
343
344
description: ~c" my_sample_mode" ,
344
345
modules: [ ] ,
345
346
vsn: ~c" 1.0.0" }
346
-
347
- File . mkdir_p! ( "my_sample_mode/ebin" )
348
- Code . prepend_path ( "my_sample_mode/ebin" )
349
- format = :io_lib . format ( "%% coding: utf-8~n~p.~n" , [ app ] )
350
- File . write! ( "my_sample_mode/ebin/my_sample_mode.app" , format )
347
+ )
351
348
352
349
apps = [ my_sample_mode: :temporary ]
353
350
release = release ( applications: apps )
@@ -802,18 +799,15 @@ defmodule Mix.ReleaseTest do
802
799
describe "included applications" do
803
800
test "are included in the release" , context do
804
801
in_tmp ( context . test , fn ->
805
- app =
802
+ write_app! (
803
+ "my_sample1/ebin/my_sample1.app" ,
806
804
{ :application , :my_sample1 ,
807
805
applications: [ :kernel , :stdlib , :elixir ] ,
808
806
description: ~c" my_sample1" ,
809
807
modules: [ ] ,
810
808
vsn: ~c" 1.0.0" ,
811
809
included_applications: [ :runtime_tools ] }
812
-
813
- File . mkdir_p! ( "my_sample1/ebin" )
814
- Code . prepend_path ( "my_sample1/ebin" )
815
- format = :io_lib . format ( "%% coding: utf-8~n~p.~n" , [ app ] )
816
- File . write! ( "my_sample1/ebin/my_sample1.app" , format )
810
+ )
817
811
818
812
release = release ( applications: [ my_sample1: :permanent ] )
819
813
assert release . boot_scripts . start [ :runtime_tools ] == :load
@@ -825,18 +819,15 @@ defmodule Mix.ReleaseTest do
825
819
826
820
test "raise on conflict" , context do
827
821
in_tmp ( context . test , fn ->
828
- app =
822
+ write_app! (
823
+ "my_sample2/ebin/my_sample2.app" ,
829
824
{ :application , :my_sample2 ,
830
825
applications: [ :kernel , :stdlib , :elixir , :runtime_tools ] ,
831
826
description: ~c" my_sample" ,
832
827
modules: [ ] ,
833
828
vsn: ~c" 1.0.0" ,
834
829
included_applications: [ :runtime_tools ] }
835
-
836
- File . mkdir_p! ( "my_sample2/ebin" )
837
- Code . prepend_path ( "my_sample2/ebin" )
838
- format = :io_lib . format ( "%% coding: utf-8~n~p.~n" , [ app ] )
839
- File . write! ( "my_sample2/ebin/my_sample2.app" , format )
830
+ )
840
831
841
832
assert_raise Mix.Error ,
842
833
":runtime_tools is listed both as a regular application and as an included application" ,
@@ -848,25 +839,30 @@ defmodule Mix.ReleaseTest do
848
839
describe "optional applications" do
849
840
test "are ignored if not available" , context do
850
841
in_tmp ( context . test , fn ->
851
- app =
852
- { :application , :my_sample1 ,
842
+ write_app! (
843
+ "my_sample3/ebin/my_sample3.app" ,
844
+ { :application , :my_sample3 ,
853
845
applications: [ :kernel , :stdlib , :elixir , :unknown ] ,
854
846
optional_applications: [ :unknown ] ,
855
- description: ~c" my_sample1 " ,
847
+ description: ~c" my_sample3 " ,
856
848
modules: [ ] ,
857
849
vsn: ~c" 1.0.0" }
850
+ )
858
851
859
- File . mkdir_p! ( "my_sample1/ebin" )
860
- Code . prepend_path ( "my_sample1/ebin" )
861
- format = :io_lib . format ( "%% coding: utf-8~n~p.~n" , [ app ] )
862
- File . write! ( "my_sample1/ebin/my_sample1.app" , format )
863
-
864
- release = release ( applications: [ my_sample1: :permanent ] )
852
+ release = release ( applications: [ my_sample3: :permanent ] )
865
853
assert release . boot_scripts . start [ :unknown ] == nil
866
854
end )
867
855
end
868
856
end
869
857
858
+ defp write_app! ( path , app ) do
859
+ dir = Path . dirname ( path )
860
+ File . mkdir_p! ( dir )
861
+ Code . prepend_path ( dir )
862
+ format = :io_lib . format ( "%% coding: utf-8~n~p.~n" , [ app ] )
863
+ File . write! ( path , format )
864
+ end
865
+
870
866
defp size! ( path ) do
871
867
File . stat! ( path ) . size
872
868
end
0 commit comments