summaryrefslogtreecommitdiff
path: root/inttest
diff options
context:
space:
mode:
Diffstat (limited to 'inttest')
-rw-r--r--inttest/ct1/app.config2
-rw-r--r--inttest/ct1/ct1_rt.erl2
-rw-r--r--inttest/ct1/rebar.config1
-rw-r--r--inttest/ct1/test_SUITE.erl8
-rw-r--r--inttest/erlc/erlc_rt.erl41
-rw-r--r--inttest/erlc/extra-include/foo_extra.hrl2
-rw-r--r--inttest/erlc/extra-src/foo_sup.erl2
-rw-r--r--inttest/erlc/foobar.erl8
-rw-r--r--inttest/erlc/include/foo_core.hrl2
-rw-r--r--inttest/erlc/rebar-no_debug_info.config2
-rw-r--r--inttest/erlc/rebar.config5
-rw-r--r--inttest/erlc/src/first_erl.erl10
12 files changed, 81 insertions, 4 deletions
diff --git a/inttest/ct1/app.config b/inttest/ct1/app.config
new file mode 100644
index 0000000..bb718b2
--- /dev/null
+++ b/inttest/ct1/app.config
@@ -0,0 +1,2 @@
+%% This file is an application config file, not a CT test config file
+[{a1, [{foo, bar}]}].
diff --git a/inttest/ct1/ct1_rt.erl b/inttest/ct1/ct1_rt.erl
index f173d3f..f9de372 100644
--- a/inttest/ct1/ct1_rt.erl
+++ b/inttest/ct1/ct1_rt.erl
@@ -7,10 +7,12 @@ files() ->
[{create, "ebin/a1.app", app(a1)},
{copy, "../../rebar", "rebar"},
{copy, "rebar.config", "rebar.config"},
+ {copy, "app.config", "app.config"},
{copy, "test_SUITE.erl", "itest/test_SUITE.erl"}].
run(_Dir) ->
{ok, _} = retest:sh("./rebar compile ct"),
+ {ok, _} = retest:sh("./rebar compile ct -v"),
ok.
diff --git a/inttest/ct1/rebar.config b/inttest/ct1/rebar.config
index a4b5284..58047ba 100644
--- a/inttest/ct1/rebar.config
+++ b/inttest/ct1/rebar.config
@@ -1 +1,2 @@
{ct_dir, "itest"}.
+{ct_extra_params, "-repeat 2 -erl_args -config app"}.
diff --git a/inttest/ct1/test_SUITE.erl b/inttest/ct1/test_SUITE.erl
index 92f2b2e..e8a2bb8 100644
--- a/inttest/ct1/test_SUITE.erl
+++ b/inttest/ct1/test_SUITE.erl
@@ -5,7 +5,13 @@
-include_lib("ct.hrl").
all() ->
- [simple_test].
+ [simple_test,
+ app_config_file_test].
simple_test(Config) ->
io:format("Test: ~p\n", [Config]).
+
+app_config_file_test(_Config) ->
+ application:start(a1),
+ {ok, bar} = application:get_env(a1, foo),
+ application:stop(a1).
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) ->
diff --git a/inttest/erlc/extra-include/foo_extra.hrl b/inttest/erlc/extra-include/foo_extra.hrl
index 228affa..19e9f94 100644
--- a/inttest/erlc/extra-include/foo_extra.hrl
+++ b/inttest/erlc/extra-include/foo_extra.hrl
@@ -1 +1,3 @@
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 ft=erlang et
-define(FOO_EXTRA, foo_extra).
diff --git a/inttest/erlc/extra-src/foo_sup.erl b/inttest/erlc/extra-src/foo_sup.erl
index a0f06b6..c68194e 100644
--- a/inttest/erlc/extra-src/foo_sup.erl
+++ b/inttest/erlc/extra-src/foo_sup.erl
@@ -1,3 +1,5 @@
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 ft=erlang et
-module(foo_sup).
-behavior(supervisor).
diff --git a/inttest/erlc/foobar.erl b/inttest/erlc/foobar.erl
new file mode 100644
index 0000000..b6d55a8
--- /dev/null
+++ b/inttest/erlc/foobar.erl
@@ -0,0 +1,8 @@
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 ft=erlang et
+-module(foobar).
+
+-export([test/0]).
+
+test() ->
+ true.
diff --git a/inttest/erlc/include/foo_core.hrl b/inttest/erlc/include/foo_core.hrl
index 2363140..803f2f0 100644
--- a/inttest/erlc/include/foo_core.hrl
+++ b/inttest/erlc/include/foo_core.hrl
@@ -1 +1,3 @@
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 ft=erlang et
-define(FOO_CORE, foo_core).
diff --git a/inttest/erlc/rebar-no_debug_info.config b/inttest/erlc/rebar-no_debug_info.config
index 1a7113a..07b6fed 100644
--- a/inttest/erlc/rebar-no_debug_info.config
+++ b/inttest/erlc/rebar-no_debug_info.config
@@ -1,6 +1,6 @@
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 ft=erlang et
-{erl_first_files, ["first_xrl.erl", "first_yrl.erl"]}.
+{erl_first_files, ["src/first_xrl.erl", "src/first_yrl.erl"]}.
{erl_opts,
[
diff --git a/inttest/erlc/rebar.config b/inttest/erlc/rebar.config
index 6a1082a..71d6660 100644
--- a/inttest/erlc/rebar.config
+++ b/inttest/erlc/rebar.config
@@ -1,6 +1,9 @@
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 ft=erlang et
-{erl_first_files, ["first_xrl.erl", "first_yrl.erl"]}.
+{erl_first_files,
+ ["src/first_xrl.erl", "src/first_yrl.erl", "src/first_erl.erl"]}.
+
+{deps, [foobar]}.
{erl_opts,
[
diff --git a/inttest/erlc/src/first_erl.erl b/inttest/erlc/src/first_erl.erl
new file mode 100644
index 0000000..4e9ff20
--- /dev/null
+++ b/inttest/erlc/src/first_erl.erl
@@ -0,0 +1,10 @@
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ts=4 sw=4 ft=erlang et
+-module(first_erl).
+
+-include_lib("eunit/include/eunit.hrl").
+
+-export([test/0]).
+
+test() ->
+ ?debugHere.