@@ -829,6 +829,72 @@ make_dev_mode_template_release(Config) ->
829829 % % ensure that the original vm.args didn't get overwritten
830830 ? assertMatch ({ok , <<" -sname {{nodename}}" >>}, file :read_file (VmArgs )).
831831
832+ make_multiple_overlay_vars_template_release (Config ) ->
833+ LibDir1 = ? config (lib_dir , Config ),
834+ OutputDir = ? config (out_dir , Config ),
835+
836+ SysConfig = filename :join ([LibDir1 , " config" , " sys.config" ]),
837+ SysConfigTerm = [{this_is_a_test , " yup it is" },
838+ {this_is_an_overlay_var , " {{var1}}" },
839+ {this_is_another_overlay_var , " {{var2}}" }],
840+ rlx_test_utils :write_config (SysConfig , SysConfigTerm ),
841+
842+ VarsFile1 = filename :join ([LibDir1 , " config" , " vars1.config" ]),
843+ rlx_test_utils :write_config (VarsFile1 , [{var1 , " indeed it is" },
844+ {var2 , " and so" },
845+ {nodename , " testnode" }]),
846+
847+ VarsFile2 = filename :join ([LibDir1 , " config" , " vars2.config" ]),
848+ rlx_test_utils :write_config (VarsFile2 , [{var1 , " indeed it is and more" }]),
849+
850+ VarsFile3 = filename :join ([LibDir1 , " config" , " vars3.config" ]),
851+ rlx_test_utils :write_config (VarsFile3 , [{var1 , " indeed it is and more" },
852+ {var2 , " and so on" }]),
853+
854+ RelxConfig = [{dev_mode , true },
855+ {mode , dev },
856+ {sys_config , SysConfig },
857+ {overlay_vars , [VarsFile1 ]},
858+ {overlay , [
859+ {template , " config/sys.config" ,
860+ " releases/{{release_version}}/sys.config" },
861+ {template , " config/sys.config" ,
862+ " releases/{{release_version}}/a/sys.config" , VarsFile2 },
863+ {template , " config/sys.config" ,
864+ " releases/{{release_version}}/b/sys.config" , VarsFile3 }]},
865+ {release , {foo , " 0.0.1" },
866+ [goal_app_1 ,
867+ goal_app_2 ]},
868+ {check_for_undefined_functions , false }],
869+
870+
871+ {ok , State } = relx :build_release (foo , [{root_dir , LibDir1 }, {lib_dirs , [LibDir1 ]},
872+ {output_dir , OutputDir } | RelxConfig ]),
873+
874+ [{{foo , " 0.0.1" }, _Release }] = maps :to_list (rlx_state :realized_releases (State )),
875+
876+ ? assert (rlx_file_utils :is_symlink (filename :join ([OutputDir , " foo" , " lib" , " non_goal_1-0.0.1" ]))),
877+ ? assert (rlx_file_utils :is_symlink (filename :join ([OutputDir , " foo" , " lib" , " non_goal_2-0.0.1" ]))),
878+ ? assert (rlx_file_utils :is_symlink (filename :join ([OutputDir , " foo" , " lib" , " goal_app_1-0.0.1" ]))),
879+ ? assert (rlx_file_utils :is_symlink (filename :join ([OutputDir , " foo" , " lib" , " goal_app_2-0.0.1" ]))),
880+ ? assert (rlx_file_utils :is_symlink (filename :join ([OutputDir , " foo" , " lib" , " lib_dep_1-0.0.1" ]))),
881+ ? assert (not rlx_file_utils :is_symlink (filename :join ([OutputDir , " foo" , " releases" , " 0.0.1" ,
882+ " sys.config" ]))),
883+ ? assert (not rlx_file_utils :is_symlink (filename :join ([OutputDir , " foo" , " releases" , " 0.0.1" ," a" ,
884+ " sys.config" ]))),
885+ ? assert (not rlx_file_utils :is_symlink (filename :join ([OutputDir , " foo" , " releases" , " 0.0.1" ," b" ,
886+ " sys.config" ]))),
887+ {ok , AConfig } = file :consult (filename :join ([OutputDir , " foo" , " releases" , " 0.0.1" ," a" ,
888+ " sys.config" ])),
889+ ? assertMatch (" indeed it is and more" , proplists :get_value (this_is_an_overlay_var , AConfig )),
890+ ? assertMatch (" and so" , proplists :get_value (this_is_another_overlay_var , AConfig )),
891+ {ok , BConfig } = file :consult (filename :join ([OutputDir , " foo" , " releases" , " 0.0.1" ," b" ,
892+ " sys.config" ])),
893+ ? assertMatch (" indeed it is and more" , proplists :get_value (this_is_an_overlay_var , BConfig )),
894+ ? assertMatch (" and so on" , proplists :get_value (this_is_another_overlay_var , BConfig )),
895+ % % ensure that the original sys.config didn't get overwritten
896+ ? assertMatch ({ok , SysConfigTerm }, file :consult (SysConfig )).
897+
832898% % verify that creating a new app with the same name after creating a release results in the
833899% % newest version being used in the new release
834900make_release_twice (Config ) ->
0 commit comments