Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

108 řádky
3.8 KiB

  1. -module(rebar_cover_SUITE).
  2. -export([suite/0,
  3. init_per_suite/1,
  4. end_per_suite/1,
  5. init_per_testcase/2,
  6. all/0,
  7. flag_coverdata_written/1,
  8. config_coverdata_written/1,
  9. index_written/1,
  10. flag_verbose/1,
  11. config_verbose/1]).
  12. -include_lib("common_test/include/ct.hrl").
  13. -include_lib("eunit/include/eunit.hrl").
  14. -include_lib("kernel/include/file.hrl").
  15. suite() ->
  16. [].
  17. init_per_suite(Config) ->
  18. Config.
  19. end_per_suite(_Config) ->
  20. ok.
  21. init_per_testcase(_, Config) ->
  22. rebar_test_utils:init_rebar_state(Config, "cover_").
  23. all() ->
  24. [flag_coverdata_written, config_coverdata_written,
  25. index_written,
  26. flag_verbose, config_verbose].
  27. flag_coverdata_written(Config) ->
  28. AppDir = ?config(apps, Config),
  29. Name = rebar_test_utils:create_random_name("cover_"),
  30. Vsn = rebar_test_utils:create_random_vsn(),
  31. rebar_test_utils:create_eunit_app(AppDir, Name, Vsn, [kernel, stdlib]),
  32. RebarConfig = [{erl_opts, [{d, some_define}]}],
  33. rebar_test_utils:run_and_check(Config,
  34. RebarConfig,
  35. ["eunit", "--cover"],
  36. {ok, [{app, Name}]}),
  37. true = filelib:is_file(filename:join([AppDir, "_build", "test", "cover", "eunit.coverdata"])).
  38. config_coverdata_written(Config) ->
  39. AppDir = ?config(apps, Config),
  40. Name = rebar_test_utils:create_random_name("cover_"),
  41. Vsn = rebar_test_utils:create_random_vsn(),
  42. rebar_test_utils:create_eunit_app(AppDir, Name, Vsn, [kernel, stdlib]),
  43. RebarConfig = [{erl_opts, [{d, some_define}]}, {cover_enabled, true}],
  44. rebar_test_utils:run_and_check(Config,
  45. RebarConfig,
  46. ["eunit"],
  47. {ok, [{app, Name}]}),
  48. true = filelib:is_file(filename:join([AppDir, "_build", "test", "cover", "eunit.coverdata"])).
  49. index_written(Config) ->
  50. AppDir = ?config(apps, Config),
  51. Name = rebar_test_utils:create_random_name("cover_"),
  52. Vsn = rebar_test_utils:create_random_vsn(),
  53. rebar_test_utils:create_eunit_app(AppDir, Name, Vsn, [kernel, stdlib]),
  54. RebarConfig = [{erl_opts, [{d, some_define}]}],
  55. rebar_test_utils:run_and_check(Config,
  56. RebarConfig,
  57. ["do", "eunit", "--cover", ",", "cover"],
  58. {ok, [{app, Name}]}),
  59. true = filelib:is_file(filename:join([AppDir, "_build", "test", "cover", "index.html"])).
  60. flag_verbose(Config) ->
  61. AppDir = ?config(apps, Config),
  62. Name = rebar_test_utils:create_random_name("cover_"),
  63. Vsn = rebar_test_utils:create_random_vsn(),
  64. rebar_test_utils:create_eunit_app(AppDir, Name, Vsn, [kernel, stdlib]),
  65. RebarConfig = [{erl_opts, [{d, some_define}]}],
  66. rebar_test_utils:run_and_check(Config,
  67. RebarConfig,
  68. ["do", "eunit", "--cover", ",", "cover", "--verbose"],
  69. {ok, [{app, Name}]}),
  70. true = filelib:is_file(filename:join([AppDir, "_build", "test", "cover", "index.html"])).
  71. config_verbose(Config) ->
  72. AppDir = ?config(apps, Config),
  73. Name = rebar_test_utils:create_random_name("cover_"),
  74. Vsn = rebar_test_utils:create_random_vsn(),
  75. rebar_test_utils:create_eunit_app(AppDir, Name, Vsn, [kernel, stdlib]),
  76. RebarConfig = [{erl_opts, [{d, some_define}]}, {cover_opts, [verbose]}],
  77. rebar_test_utils:run_and_check(Config,
  78. RebarConfig,
  79. ["do", "eunit", "--cover", ",", "cover"],
  80. {ok, [{app, Name}]}),
  81. true = filelib:is_file(filename:join([AppDir, "_build", "test", "cover", "index.html"])).