Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

93 rindas
2.9 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].
  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. %%%%%%%%%%%%%%%
  61. %%% Helpers %%%
  62. %%%%%%%%%%%%%%%
  63. set_name_config(Atom, Config) ->
  64. [{path,
  65. filename:join([?config(priv_dir, Config),
  66. atom_to_list(?MODULE)++"_data", atom_to_list(Atom)])}
  67. | Config].
  68. rebar3(Args, Config) -> rebar3(Args, Config, []).
  69. rebar3(Args, Config, UserOpts) ->
  70. Exec = case os:type() of
  71. {win32, _} ->
  72. "rebar3.cmd";
  73. _ ->
  74. "rebar3"
  75. end,
  76. Cmd = Exec ++ " " ++ Args,
  77. Opts = [{cd, ?config(path, Config)}, return_on_error, use_stdout
  78. | UserOpts],
  79. ct:pal("Calling rebar3 ~s with options ~p", [Cmd, Opts]),
  80. rebar_utils:sh(Cmd, Opts).