summaryrefslogtreecommitdiff
path: root/inttest/erlc/erlc_rt.erl
diff options
context:
space:
mode:
authorSlava Yurin <v.yurin@office.ngs.ru>2014-05-28 14:05:26 +0700
committerSlava Yurin <v.yurin@office.ngs.ru>2014-05-30 18:24:57 +0700
commit23c63f7003c3f80fddc8580cfcf208aa0639b80c (patch)
tree24d8fc4fcd73bdda046e3e02c25685103d5c2c8d /inttest/erlc/erlc_rt.erl
parent755c6023d181b4aa87a581ac71e96d2de90a015f (diff)
Regression test for #249
Diffstat (limited to 'inttest/erlc/erlc_rt.erl')
-rw-r--r--inttest/erlc/erlc_rt.erl41
1 files changed, 40 insertions, 1 deletions
diff --git a/inttest/erlc/erlc_rt.erl b/inttest/erlc/erlc_rt.erl
index 354ad29..50cdb83 100644
--- a/inttest/erlc/erlc_rt.erl
+++ b/inttest/erlc/erlc_rt.erl
@@ -1,3 +1,5 @@
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 ft=erlang et
-module(erlc_rt).
-export([files/0,
run/1]).
@@ -7,6 +9,7 @@
-define(MODULES,
[first_xrl,
first_yrl,
+ first_erl,
foo,
foo_app,
foo_sup,
@@ -17,6 +20,7 @@
-define(BEAM_FILES,
["first_xrl.beam",
"first_yrl.beam",
+ "first_erl.beam",
"foo.beam",
"foo_app.beam",
"foo_sup.beam",
@@ -35,7 +39,10 @@ files() ->
{copy, "extra-src", "extra-src"},
{copy, "mibs", "mibs"},
{copy, "asn1", "asn1"},
- {create, "ebin/foo.app", app(foo, ?MODULES)}
+ {create, "ebin/foo.app", app(foo, ?MODULES)},
+ %% deps
+ {create, "deps/foobar/ebin/foobar.app", app(foobar, [foobar])},
+ {copy, "foobar.erl", "deps/foobar/src/foobar.erl"}
].
run(_Dir) ->
@@ -53,6 +60,38 @@ run(_Dir) ->
ok = check_beams(true),
ok = check_debug_info(false),
?assertMatch(true, filelib:is_regular(MibResult)),
+ %% Regression test for https://github.com/rebar/rebar/issues/249
+ %%
+ %% Root cause: We didn't have per-project .rebar/erlcinfo but just one in
+ %% <base_dir>/.rebar/erlcinfo.
+ %%
+ %% Solution: Ensure every project has its own .rebar/erlcinfo
+ %%
+ %% For the bug to happen, the following conditions must be met:
+ %%
+ %% 1. <base_dir>/rebar.config has erl_first_files
+ %% 2. one of the 'first' files depends on another file (in this
+ %% case via -include_lib())
+ %% 3. a sub project's rebar.config, if any, has no erl_first_files entry
+ %%
+ %% Now because erl_first_files is retrieved via rebar_config:get_list/3,
+ %% base_dir/rebar.config's erl_first_files is inherited, and because we had
+ %% a shared <base_dir>/.rebar/erlcinfo instead of one per project, the
+ %% cached entry was reused. Next, while compiling the sub project
+ %% rebar_erlc_compiler:needs_compile/3 gets a last modification time of
+ %% zero for the 'first' file which does not exist inside the sub project.
+ %% This, and the fact that it has at least one dependency, makes
+ %% needs_compile/3 return 'true'. The root cause is that we didn't have per
+ %% project .rebar/erlcinfo. For <base_dir>/.rebar/erlcinfo to be populated,
+ %% base_dir has to be compiled at least once. Therefore, after the first
+ %% compile any compile processing the sub project will fail because
+ %% needs_compile/3 will always return true for the non-existent 'first'
+ %% file.
+ ?assertMatch({ok, _}, retest_sh:run("./rebar clean", [])),
+ ?assertMatch({ok, _}, retest_sh:run("./rebar compile", [])),
+ ok = check_beams(true),
+ ?assertMatch({ok, _}, retest_sh:run("./rebar compile", [])),
+ ok = check_beams(true),
ok.
check_beams(Exist) ->