No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

72 líneas
1.9 KiB

  1. %% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
  2. %% ex: ts=4 sw=4 et
  3. -module(rebar_erlydtl_SUITE).
  4. -export([suite/0,
  5. init_per_suite/1,
  6. end_per_suite/1,
  7. init_per_testcase/2,
  8. end_per_testcase/2,
  9. all/0,
  10. compile/1]).
  11. -include_lib("common_test/include/ct.hrl").
  12. -include_lib("eunit/include/eunit.hrl").
  13. -include_lib("kernel/include/file.hrl").
  14. %% ===================================================================
  15. %% common_test callbacks
  16. %% ===================================================================
  17. suite() ->
  18. [].
  19. init_per_suite(Config) ->
  20. Config.
  21. end_per_suite(_Config) ->
  22. ok.
  23. init_per_testcase(_, Config) ->
  24. UpdConfig = rebar_test_utils:init_rebar_state(Config),
  25. AppDir = ?config(apps, UpdConfig),
  26. Name = rebar_test_utils:create_random_name("erlydtlapp_"),
  27. Vsn = rebar_test_utils:create_random_vsn(),
  28. rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
  29. write_dtl_file(AppDir, Name),
  30. RebarConfig = [{erl_opts, [debug_info]},
  31. {erlydtl_opts, []}],
  32. [{app_name, Name},
  33. {rebar_config, RebarConfig} | UpdConfig].
  34. end_per_testcase(_, _Config) ->
  35. ok.
  36. all() ->
  37. [compile].
  38. compile(Config) ->
  39. AppDir = ?config(apps, Config),
  40. AppName = ?config(app_name, Config),
  41. RebarConfig = ?config(rebar_config, Config),
  42. Beam = beam_file(AppDir, AppName),
  43. rebar_test_utils:run_and_check(
  44. Config, RebarConfig, ["erlydtl", "compile"],
  45. {ok, [{file, Beam}]}
  46. ).
  47. beam_file(AppDir, AppName) ->
  48. filename:join([AppDir, "_build", "default", "lib",
  49. AppName, "ebin", AppName++"_template_dtl.beam"]).
  50. write_dtl_file(Dir, AppName) ->
  51. Erl = filename:join([Dir, "priv", "templates", AppName++"_template.dtl"]),
  52. ok = filelib:ensure_dir(Erl),
  53. ok = ec_file:write(Erl, get_body()).
  54. get_body() ->
  55. ["[]"].