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.

117 lines
3.7 KiB

  1. -module(all_SUITE).
  2. -include_lib("common_test/include/ct.hrl").
  3. -include_lib("eunit/include/eunit.hrl").
  4. -compile([export_all, nowarn_export_all]).
  5. init_per_suite(Config) ->
  6. %% TODO: figure out how to use a local rebar3 copy?
  7. %% Ensure global rebar3 has the same version as current one!
  8. {ok, Vsn} = application:get_key(rebar, vsn),
  9. {ok, ExecVsn} = rebar3("version", [{path, "."} | Config]),
  10. case rebar_string:lexemes(ExecVsn, " ") of
  11. ["rebar", Vsn | _] ->
  12. %% Copy all base cases to priv_dir
  13. rebar_file_utils:cp_r([?config(data_dir, Config)],
  14. ?config(priv_dir, Config)),
  15. Config;
  16. _ ->
  17. {skip, "expected current version "++Vsn++" in path "
  18. "and found '"++ ExecVsn ++ "'"}
  19. end.
  20. end_per_suite(Config) ->
  21. Config.
  22. init_per_testcase(Name, Config) ->
  23. set_name_config(Name, Config).
  24. end_per_testcase(_Name, Config) ->
  25. Config.
  26. all() ->
  27. [noop, resource_plugins, alias_clash, grisp_explode, compile_deps].
  28. %groups() ->
  29. % [{plugins, [shuffle], []},
  30. % {deps, [shuffle], []}].
  31. %%%%%%%%%%%%%%%%%%
  32. %%% TEST CASES %%%
  33. %%%%%%%%%%%%%%%%%%
  34. noop() ->
  35. [{doc, "just a sanity check on the handling of the test suite init/end"}].
  36. noop(_Config) ->
  37. true.
  38. resource_plugins() ->
  39. [{doc, "Issue #1673: "
  40. "Ensure that deps using resource plugins with semver compile."}].
  41. resource_plugins(Config) ->
  42. %% When the environment handling is wrong, the run fails violently.
  43. {ok, Output} = rebar3("compile", Config),
  44. ct:pal("Rebar3 Output:~n~s",[Output]),
  45. ok.
  46. alias_clash() ->
  47. [{doc, "checking that the provider won't get plugin interference."},
  48. {timetrap, 10000}].
  49. alias_clash(Config) ->
  50. {ok, Help} = rebar3("help", Config), % should be redefined, but by the plugin
  51. ?assertNotEqual(nomatch,
  52. re:run(Help, "Alias help is already the name of a command[a-z ]+and will be ignored")
  53. ),
  54. {ok, Output} = rebar3("test", Config, [{env, [{"DEBUG", "1"}]}]),
  55. ?assertNotEqual(nomatch, re:run(Output, "cover summary written to:")),
  56. ?assertNotEqual(nomatch,
  57. re:run(Output, "Not adding provider default test from module rebar_prv_alias_test "
  58. "because it already exists from module rebar_prv_alias_test")),
  59. ok.
  60. grisp_explode() ->
  61. [{doc, "Don't force purge a plugin that runs the compile job itself"}].
  62. grisp_explode(Config) ->
  63. %% When the purge handling is wrong, the run fails violently.
  64. {error, {_,Output}} = rebar3("grisp deploy -n robot -v 0.1.0", Config),
  65. ct:pal("Rebar3 Output:~n~s",[Output]),
  66. ?assertNotEqual(nomatch,
  67. re:run(Output, "No releases exist in the system for robot:0.1.0!")
  68. ),
  69. ok.
  70. compile_deps() ->
  71. [{doc, "When compiling a project multiple times, the deps should always be built event if refetched"}].
  72. compile_deps(Config) ->
  73. rebar3("compile", Config),
  74. rebar3("compile", Config),
  75. PrivDir = ?config(path, Config),
  76. EbinDir = filename:join([PrivDir, "_build", "default", "lib", "fake_dep", "ebin"]),
  77. {ok, Beams} = file:list_dir(EbinDir),
  78. ?assert(length(Beams) > 1).
  79. %%%%%%%%%%%%%%%
  80. %%% Helpers %%%
  81. %%%%%%%%%%%%%%%
  82. set_name_config(Atom, Config) ->
  83. [{path,
  84. filename:join([?config(priv_dir, Config),
  85. atom_to_list(?MODULE)++"_data", atom_to_list(Atom)])}
  86. | Config].
  87. rebar3(Args, Config) -> rebar3(Args, Config, []).
  88. rebar3(Args, Config, UserOpts) ->
  89. Exec = case os:type() of
  90. {win32, _} ->
  91. "rebar3.cmd";
  92. _ ->
  93. "rebar3"
  94. end,
  95. Cmd = Exec ++ " " ++ Args,
  96. Opts = [{cd, ?config(path, Config)}, return_on_error, use_stdout
  97. | UserOpts],
  98. ct:pal("Calling rebar3 ~s with options ~p", [Cmd, Opts]),
  99. rebar_utils:sh(Cmd, Opts).