diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/mock_pkg_resource.erl | 2 | ||||
-rw-r--r-- | test/rebar_compile_SUITE.erl | 27 | ||||
-rw-r--r-- | test/rebar_test_utils.erl | 4 |
3 files changed, 28 insertions, 5 deletions
diff --git a/test/mock_pkg_resource.erl b/test/mock_pkg_resource.erl index 615e8a5..560caef 100644 --- a/test/mock_pkg_resource.erl +++ b/test/mock_pkg_resource.erl @@ -152,7 +152,7 @@ find_parts([{AppName, Deps}|Rest], Skip, Acc) -> end. to_graph_parts(Dict) -> - LastUpdated = now(), + LastUpdated = os:timestamp(), dict:fold(fun(K,V,{Ks,Vs}) -> {_,Deps} = lists:keyfind(<<"deps">>, 1, V), {[{K,LastUpdated}|Ks], 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_test_utils.erl b/test/rebar_test_utils.erl index f764146..2cdc58b 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -104,12 +104,12 @@ create_config(AppDir, Contents) -> %% @doc Util to create a random variation of a given name. create_random_name(Name) -> - random:seed(erlang:now()), + random:seed(os:timestamp()), Name ++ erlang:integer_to_list(random:uniform(1000000)). %% @doc Util to create a random variation of a given version. create_random_vsn() -> - random:seed(erlang:now()), + random:seed(os:timestamp()), lists:flatten([erlang:integer_to_list(random:uniform(100)), ".", erlang:integer_to_list(random:uniform(100)), ".", erlang:integer_to_list(random:uniform(100))]). |