You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.0 KiB

  1. -module(tdeps2_rt).
  2. -compile(export_all).
  3. %% Exercise transitive dependencies where there are multiple files
  4. %% depending on the same set of deps
  5. %% [A1, A2] -> B -> C ; A1 and A2 includes B.hrl which includes C.hrl
  6. files() ->
  7. [
  8. %% A1 application
  9. {create, "apps/a1/ebin/a1.app", app(a1, [a1])},
  10. {copy, "a.rebar.config", "apps/a1/rebar.config"},
  11. {template, "a.erl", "apps/a1/src/a1.erl", dict:from_list([{module, a1}])},
  12. %% A2 application
  13. {create, "apps/a2/ebin/a2.app", app(a2, [a2])},
  14. {copy, "a.rebar.config", "apps/a2/rebar.config"},
  15. {template, "a.erl", "apps/a2/src/a2.erl", dict:from_list([{module, a2}])},
  16. {copy, "root.rebar.config", "rebar.config"},
  17. {copy, "../../rebar", "rebar"},
  18. %% B application
  19. {create, "repo/b/ebin/b.app", app(b, [])},
  20. {copy, "b.rebar.config", "repo/b/rebar.config"},
  21. {copy, "b.hrl", "repo/b/include/b.hrl"},
  22. %% C application
  23. {create, "repo/c/ebin/c.app", app(c, [])},
  24. {copy, "c.hrl", "repo/c/include/c.hrl"}
  25. ].
  26. apply_cmds([], _Params) ->
  27. ok;
  28. apply_cmds([Cmd | Rest], Params) ->
  29. io:format("Running: ~s (~p)\n", [Cmd, Params]),
  30. {ok, _} = retest_sh:run(Cmd, Params),
  31. apply_cmds(Rest, Params).
  32. run(_Dir) ->
  33. %% Initialize the b/c apps as git repos so that dependencies pull
  34. %% properly
  35. GitCmds = ["git init",
  36. "git add -A",
  37. "git config user.email 'tdeps@example.com'",
  38. "git config user.name 'tdeps'",
  39. "git commit -a -m 'Initial Commit'"],
  40. ok = apply_cmds(GitCmds, [{dir, "repo/b"}]),
  41. ok = apply_cmds(GitCmds, [{dir, "repo/c"}]),
  42. {ok, _} = retest_sh:run("./rebar -v get-deps", []),
  43. {ok, _} = retest_sh:run("./rebar -v compile", []),
  44. ok.
  45. %%
  46. %% Generate the contents of a simple .app file
  47. %%
  48. app(Name, Modules) ->
  49. App = {application, Name,
  50. [{description, atom_to_list(Name)},
  51. {vsn, "1"},
  52. {modules, Modules},
  53. {registered, []},
  54. {applications, [kernel, stdlib]}]},
  55. io_lib:format("~p.\n", [App]).