diff options
author | suexcxine <suex.bestwishes@gmail.com> | 2017-08-25 22:50:22 +0800 |
---|---|---|
committer | suexcxine <suex.bestwishes@gmail.com> | 2017-08-29 23:27:30 +0800 |
commit | 7095382e2c769f43214c32c4cb7f357b15ee095c (patch) | |
tree | 153c72f1a6a04f66d3fc0dd4408ef3786d45dbb3 /test | |
parent | 92d3fa9272582eea6ce77faab19fb74be0d4c6ce (diff) |
Recompile when include files change
Diffstat (limited to 'test')
-rw-r--r-- | test/rebar_compile_SUITE.erl | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/rebar_compile_SUITE.erl b/test/rebar_compile_SUITE.erl index 5a18745..6579617 100644 --- a/test/rebar_compile_SUITE.erl +++ b/test/rebar_compile_SUITE.erl @@ -24,6 +24,7 @@ clean_extra_dirs_in_project_root/1, recompile_when_hrl_changes/1, recompile_when_included_hrl_changes/1, + recompile_when_opts_included_hrl_changes/1, recompile_when_opts_change/1, dont_recompile_when_opts_dont_change/1, dont_recompile_yrl_or_xrl/1, @@ -66,6 +67,7 @@ all() -> {group, basic_extras}, {group, release_extras}, {group, unbalanced_extras}, {group, root_extras}, recompile_when_hrl_changes, recompile_when_included_hrl_changes, + recompile_when_opts_included_hrl_changes, recompile_when_opts_change, dont_recompile_when_opts_dont_change, dont_recompile_yrl_or_xrl, delete_beam_if_source_deleted, @@ -752,6 +754,53 @@ recompile_when_included_hrl_changes(Config) -> ?assert(ModTime =/= NewModTime). +recompile_when_opts_included_hrl_changes(Config) -> + AppsDir = ?config(apps, Config), + + Name = rebar_test_utils:create_random_name("app1_"), + Vsn = rebar_test_utils:create_random_vsn(), + AppDir = filename:join([AppsDir, "apps", Name]), + + rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + + ExtraSrc = <<"-module(test_header_include).\n" + "-export([main/0]).\n" + "-include(\"test_header_include.hrl\").\n" + "main() -> ?SOME_DEFINE.\n">>, + + ExtraHeader = <<"-define(SOME_DEFINE, true).\n">>, + ok = filelib:ensure_dir(filename:join([AppsDir, "include", "dummy"])), + HeaderFile = filename:join([AppsDir, "include", "test_header_include.hrl"]), + ok = file:write_file(filename:join([AppDir, "src", "test_header_include.erl"]), ExtraSrc), + ok = file:write_file(HeaderFile, ExtraHeader), + + %% Using relative path from the project root + RebarConfig = [{erl_opts, [{i, "include/"}]}], + {ok,Cwd} = file:get_cwd(), + ok = file:set_cwd(AppsDir), + + rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], {ok, [{app, Name}]}), + + EbinDir = filename:join([AppsDir, "_build", "default", "lib", Name, "ebin"]), + {ok, Files} = rebar_utils:list_dir(EbinDir), + ModTime = [filelib:last_modified(filename:join([EbinDir, F])) + || F <- Files, filename:extension(F) == ".beam"], + + timer:sleep(1000), + + NewExtraHeader = <<"-define(SOME_DEFINE, false).\n">>, + ok = file:write_file(HeaderFile, NewExtraHeader), + + rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], {ok, [{app, Name}]}), + + {ok, NewFiles} = rebar_utils:list_dir(EbinDir), + NewModTime = [filelib:last_modified(filename:join([EbinDir, F])) + || F <- NewFiles, filename:extension(F) == ".beam"], + + ok = file:set_cwd(Cwd), + + ?assert(ModTime =/= NewModTime). + recompile_when_opts_change(Config) -> AppDir = ?config(apps, Config), |