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.

49 lines
1.5 KiB

  1. -module(rebar_disable_app_SUITE).
  2. -compile(export_all).
  3. -include_lib("common_test/include/ct.hrl").
  4. -include_lib("eunit/include/eunit.hrl").
  5. -define(MOD(Name),
  6. io_lib:format("-module(~s).~n-export([x/0]).~nx() -> ok.~n", [Name])).
  7. all() -> [disable_app].
  8. init_per_testcase(_, Config) ->
  9. rebar_test_utils:init_rebar_state(Config).
  10. end_per_testcase(_, _Config) ->
  11. ok.
  12. disable_app(Config) ->
  13. AppDir = ?config(apps, Config),
  14. Name1 = create_random_app(AppDir, "app1_"),
  15. Name2 = create_random_app(AppDir, "app2_"),
  16. RebarConfig = [{excluded_apps, [list_to_atom(Name1)]}],
  17. %RebarConfig = [],
  18. rebar_test_utils:run_and_check(
  19. Config, RebarConfig, ["compile"],
  20. {ok, [{app, Name2}]}),
  21. App1 = filename:join([AppDir, "_build", "default", "lib", Name1, "ebin", Name1 ++ ".app"]),
  22. ?assertEqual(filelib:is_file(App1), false),
  23. App2 = filename:join([AppDir, "_build", "default", "lib", Name2, "ebin", Name2 ++ ".app"]),
  24. ?assertEqual(filelib:is_file(App2), true).
  25. %%
  26. %% Utils
  27. %%
  28. create_random_app(AppDir, Prefix) ->
  29. Name = rebar_test_utils:create_random_name(Prefix),
  30. Vsn = rebar_test_utils:create_random_vsn(),
  31. rebar_test_utils:create_empty_app(filename:join([AppDir, "apps", Name]), Name, Vsn, [kernel, stdlib]),
  32. ModName = rebar_test_utils:create_random_name("mod1_"),
  33. Mod = filename:join([AppDir, "apps", Name, "src", ModName ++ ".erl"]),
  34. ok = filelib:ensure_dir(Mod),
  35. Src = ?MOD(ModName),
  36. ok = ec_file:write(Mod, Src),
  37. Name.