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.

82 lines
3.0 KiB

  1. -module(rebar_profiles_SUITE).
  2. -export([init_per_suite/1,
  3. end_per_suite/1,
  4. init_per_testcase/2,
  5. end_per_testcase/2,
  6. all/0,
  7. profile_new_key/1,
  8. profile_merge_keys/1]).
  9. -include_lib("common_test/include/ct.hrl").
  10. -include_lib("eunit/include/eunit.hrl").
  11. -include_lib("kernel/include/file.hrl").
  12. all() ->
  13. [profile_new_key, profile_merge_keys].
  14. init_per_suite(Config) ->
  15. application:start(meck),
  16. Config.
  17. end_per_suite(_Config) ->
  18. application:stop(meck).
  19. init_per_testcase(_, Config) ->
  20. rebar_test_utils:init_rebar_state(Config).
  21. end_per_testcase(_, Config) ->
  22. meck:unload(),
  23. Config.
  24. profile_new_key(Config) ->
  25. AppDir = ?config(apps, Config),
  26. AllDeps = rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}
  27. ,{"b", "1.0.0", []}]),
  28. mock_git_resource:mock([{deps, rebar_test_utils:flat_deps(AllDeps)}]),
  29. Name = rebar_test_utils:create_random_name("profile_new_key_"),
  30. Vsn = rebar_test_utils:create_random_vsn(),
  31. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  32. Deps = rebar_test_utils:top_level_deps(
  33. rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}
  34. ,{"b", "1.0.0", []}])),
  35. ct:pal("Deps ~p", [Deps]),
  36. RebarConfig = [{profiles,
  37. [{ct,
  38. [{deps, Deps}]}]}],
  39. rebar_test_utils:run_and_check(Config, RebarConfig,
  40. ["as", "ct", "compile"], {ok, [{app, Name}
  41. ,{dep, "a", "1.0.0"}
  42. ,{dep, "b", "1.0.0"}]}).
  43. profile_merge_keys(Config) ->
  44. AppDir = ?config(apps, Config),
  45. AllDeps = rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}
  46. ,{"b", "1.0.0", []}
  47. ,{"b", "2.0.0", []}]),
  48. mock_git_resource:mock([{deps, rebar_test_utils:flat_deps(AllDeps)}]),
  49. Name = rebar_test_utils:create_random_name("profile_new_key_"),
  50. Vsn = rebar_test_utils:create_random_vsn(),
  51. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  52. Deps = rebar_test_utils:top_level_deps(
  53. rebar_test_utils:expand_deps(git, [{"a", "1.0.0", []}
  54. ,{"b", "1.0.0", []}])),
  55. ProfileDeps = rebar_test_utils:top_level_deps(
  56. rebar_test_utils:expand_deps(git, [{"b", "2.0.0", []}])),
  57. RebarConfig = [{deps, Deps},
  58. {profiles,
  59. [{ct,
  60. [{deps, ProfileDeps}]}]}],
  61. rebar_test_utils:run_and_check(Config, RebarConfig,
  62. ["as", "ct", "compile"], {ok, [{app, Name}
  63. ,{dep, "a", "1.0.0"}
  64. ,{dep, "b", "2.0.0"}]}).