summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/rebar_compile_SUITE.erl27
-rw-r--r--test/rebar_erlydtl_SUITE.erl72
2 files changed, 25 insertions, 74 deletions
diff --git a/test/rebar_compile_SUITE.erl b/test/rebar_compile_SUITE.erl
index ee262a1..bdab075 100644
--- a/test/rebar_compile_SUITE.erl
+++ b/test/rebar_compile_SUITE.erl
@@ -19,7 +19,8 @@
delete_beam_if_source_deleted/1,
checkout_priority/1,
compile_plugins/1,
- highest_version_of_pkg_dep/1]).
+ highest_version_of_pkg_dep/1,
+ parse_transform_test/1]).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
@@ -46,7 +47,8 @@ all() ->
build_all_srcdirs, recompile_when_hrl_changes,
recompile_when_opts_change, dont_recompile_when_opts_dont_change,
dont_recompile_yrl_or_xrl, delete_beam_if_source_deleted,
- deps_in_path, checkout_priority, compile_plugins, highest_version_of_pkg_dep].
+ deps_in_path, checkout_priority, compile_plugins, highest_version_of_pkg_dep,
+ parse_transform_test].
build_basic_app(Config) ->
AppDir = ?config(apps, Config),
@@ -449,3 +451,24 @@ highest_version_of_pkg_dep(Config) ->
Config, RConf, ["compile"],
{ok, [{app, Name}, {dep, PkgName, <<"0.1.3">>}]}
).
+
+parse_transform_test(Config) ->
+ AppDir = ?config(apps, Config),
+
+ RebarConfig = [{erl_opts, [{parse_transform, pascal}]}],
+
+ Name = rebar_test_utils:create_random_name("app1_"),
+ Vsn = rebar_test_utils:create_random_vsn(),
+ rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
+
+ ExtraSrc = <<"-module(pascal). "
+ "-export([parse_transform/2]). "
+ "parse_transform(Forms, _Options) -> "
+ "Forms.">>,
+
+ ok = file:write_file(filename:join([AppDir, "src", "pascal.erl"]), ExtraSrc),
+
+ rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], {ok, [{app, Name}]}),
+
+ EbinDir = filename:join([AppDir, "_build", "default", "lib", Name, "ebin"]),
+ true = filelib:is_file(filename:join([EbinDir, "pascal.beam"])).
diff --git a/test/rebar_erlydtl_SUITE.erl b/test/rebar_erlydtl_SUITE.erl
deleted file mode 100644
index c9054fd..0000000
--- a/test/rebar_erlydtl_SUITE.erl
+++ /dev/null
@@ -1,72 +0,0 @@
-%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
-%% ex: ts=4 sw=4 et
--module(rebar_erlydtl_SUITE).
-
--export([suite/0,
- init_per_suite/1,
- end_per_suite/1,
- init_per_testcase/2,
- end_per_testcase/2,
- all/0,
- compile/1]).
-
--include_lib("common_test/include/ct.hrl").
--include_lib("eunit/include/eunit.hrl").
--include_lib("kernel/include/file.hrl").
-
-%% ===================================================================
-%% common_test callbacks
-%% ===================================================================
-
-suite() ->
- [].
-
-init_per_suite(Config) ->
- Config.
-
-end_per_suite(_Config) ->
- ok.
-
-
-init_per_testcase(_, Config) ->
- UpdConfig = rebar_test_utils:init_rebar_state(Config),
- AppDir = ?config(apps, UpdConfig),
-
- Name = rebar_test_utils:create_random_name("erlydtlapp_"),
- Vsn = rebar_test_utils:create_random_vsn(),
- rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
-
- write_dtl_file(AppDir, Name),
-
- RebarConfig = [{erl_opts, [debug_info]},
- {erlydtl_opts, []}],
- [{app_name, Name},
- {rebar_config, RebarConfig} | UpdConfig].
-
-end_per_testcase(_, _Config) ->
- ok.
-
-all() ->
- [compile].
-
-compile(Config) ->
- AppDir = ?config(apps, Config),
- AppName = ?config(app_name, Config),
- RebarConfig = ?config(rebar_config, Config),
- Beam = beam_file(AppDir, AppName),
- rebar_test_utils:run_and_check(
- Config, RebarConfig, ["erlydtl", "compile"],
- {ok, [{file, Beam}]}
- ).
-
-beam_file(AppDir, AppName) ->
- filename:join([AppDir, "_build", "default", "lib",
- AppName, "ebin", AppName++"_template_dtl.beam"]).
-
-write_dtl_file(Dir, AppName) ->
- Erl = filename:join([Dir, "priv", "templates", AppName++"_template.dtl"]),
- ok = filelib:ensure_dir(Erl),
- ok = ec_file:write(Erl, get_body()).
-
-get_body() ->
- ["[]"].