Просмотр исходного кода

Add tests for multi-app edoc linking working

pull/1308/head
Fred Hebert 8 лет назад
Родитель
Сommit
2c78cfd557
13 измененных файлов: 321 добавлений и 0 удалений
  1. +52
    -0
      test/rebar_edoc_SUITE.erl
  2. +16
    -0
      test/rebar_edoc_SUITE_data/foo/apps/bar1/src/bar1.app.src
  3. +9
    -0
      test/rebar_edoc_SUITE_data/foo/apps/bar1/src/bar1.erl
  4. +26
    -0
      test/rebar_edoc_SUITE_data/foo/apps/bar1/src/bar1_app.erl
  5. +35
    -0
      test/rebar_edoc_SUITE_data/foo/apps/bar1/src/bar1_sup.erl
  6. +16
    -0
      test/rebar_edoc_SUITE_data/foo/apps/bar2/src/bar2.app.src
  7. +9
    -0
      test/rebar_edoc_SUITE_data/foo/apps/bar2/src/bar2.erl
  8. +26
    -0
      test/rebar_edoc_SUITE_data/foo/apps/bar2/src/bar2_app.erl
  9. +35
    -0
      test/rebar_edoc_SUITE_data/foo/apps/bar2/src/bar2_sup.erl
  10. +17
    -0
      test/rebar_edoc_SUITE_data/foo/apps/foo/src/foo.app.src
  11. +19
    -0
      test/rebar_edoc_SUITE_data/foo/apps/foo/src/foo.erl
  12. +26
    -0
      test/rebar_edoc_SUITE_data/foo/apps/foo/src/foo_app.erl
  13. +35
    -0
      test/rebar_edoc_SUITE_data/foo/apps/foo/src/foo_sup.erl

+ 52
- 0
test/rebar_edoc_SUITE.erl Просмотреть файл

@ -0,0 +1,52 @@
-module(rebar_edoc_SUITE).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
-compile(export_all).
all() -> [multiapp].
init_per_testcase(multiapp, Config) ->
application:load(rebar),
DataDir = ?config(data_dir, Config),
PrivDir = ?config(priv_dir, Config),
Name = rebar_test_utils:create_random_name("multiapp"),
AppsDir = filename:join([PrivDir, rebar_test_utils:create_random_name(Name)]),
ec_file:copy(filename:join([DataDir, "foo"]), AppsDir, [recursive]),
Verbosity = rebar3:log_level(),
rebar_log:init(command_line, Verbosity),
State = rebar_state:new([{base_dir, filename:join([AppsDir, "_build"])}
,{root_dir, AppsDir}]),
[{apps, AppsDir}, {state, State}, {name, Name} | Config].
end_per_testcase(_, Config) ->
Config.
multiapp(Config) ->
%% With an empty config (no `dir'), links are being processed
RebarConfig = [],
rebar_test_utils:run_and_check(Config, RebarConfig, ["edoc"], {ok, []}),
%% validate that all doc entries are generated and links work
AppsDir = ?config(apps, Config),
ct:pal("AppsDir: ~s", [AppsDir]),
?assert(file_content_matches(
filename:join([AppsDir, "apps", "bar1", "doc", "bar1.html"]),
"barer1")),
?assert(file_content_matches(
filename:join([AppsDir, "apps", "bar2", "doc", "bar2.html"]),
"barer2")),
%% Links are in place for types
?assert(file_content_matches(
filename:join([AppsDir, "apps", "foo", "doc", "foo.html"]),
"barer1")),
?assert(file_content_matches(
filename:join([AppsDir, "apps", "foo", "doc", "foo.html"]),
"apps/bar1/doc/bar1.html")).
file_content_matches(Path, Regex) ->
case file:read_file(Path) of
{ok, Bin} ->
nomatch =/= re:run(Bin, Regex);
{error, Reason} ->
Reason
end.

+ 16
- 0
test/rebar_edoc_SUITE_data/foo/apps/bar1/src/bar1.app.src Просмотреть файл

@ -0,0 +1,16 @@
{application, bar1,
[{description, "An OTP application"},
{vsn, "0.1.0"},
{registered, []},
{mod, { bar1_app, []}},
{applications,
[kernel,
stdlib
]},
{env,[]},
{modules, []},
{maintainers, []},
{licenses, []},
{links, []}
]}.

+ 9
- 0
test/rebar_edoc_SUITE_data/foo/apps/bar1/src/bar1.erl Просмотреть файл

@ -0,0 +1,9 @@
-module(bar1).
-export([bar1/0]).
-export_type([barer1/0]).
-type barer1() :: string().
% @doc Bar1 bars the bar.
-spec bar1() -> barer1().
bar1() -> "Barer1".

+ 26
- 0
test/rebar_edoc_SUITE_data/foo/apps/bar1/src/bar1_app.erl Просмотреть файл

@ -0,0 +1,26 @@
%%%-------------------------------------------------------------------
%% @doc bar1 public API
%% @end
%%%-------------------------------------------------------------------
-module(bar1_app).
-behaviour(application).
%% Application callbacks
-export([start/2, stop/1]).
%%====================================================================
%% API
%%====================================================================
start(_StartType, _StartArgs) ->
bar1_sup:start_link().
%%--------------------------------------------------------------------
stop(_State) ->
ok.
%%====================================================================
%% Internal functions
%%====================================================================

+ 35
- 0
test/rebar_edoc_SUITE_data/foo/apps/bar1/src/bar1_sup.erl Просмотреть файл

@ -0,0 +1,35 @@
%%%-------------------------------------------------------------------
%% @doc bar1 top level supervisor.
%% @end
%%%-------------------------------------------------------------------
-module(bar1_sup).
-behaviour(supervisor).
%% API
-export([start_link/0]).
%% Supervisor callbacks
-export([init/1]).
-define(SERVER, ?MODULE).
%%====================================================================
%% API functions
%%====================================================================
start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
%%====================================================================
%% Supervisor callbacks
%%====================================================================
%% Child :: {Id,StartFunc,Restart,Shutdown,Type,Modules}
init([]) ->
{ok, { {one_for_all, 0, 1}, []} }.
%%====================================================================
%% Internal functions
%%====================================================================

+ 16
- 0
test/rebar_edoc_SUITE_data/foo/apps/bar2/src/bar2.app.src Просмотреть файл

@ -0,0 +1,16 @@
{application, bar2,
[{description, "An OTP application"},
{vsn, "0.1.0"},
{registered, []},
{mod, { bar2_app, []}},
{applications,
[kernel,
stdlib
]},
{env,[]},
{modules, []},
{maintainers, []},
{licenses, []},
{links, []}
]}.

+ 9
- 0
test/rebar_edoc_SUITE_data/foo/apps/bar2/src/bar2.erl Просмотреть файл

@ -0,0 +1,9 @@
-module(bar2).
-export([bar2/0]).
-export_type([barer2/0]).
-type barer2() :: string().
% @doc Bar2 bars the bar2.
-spec bar2() -> barer2().
bar2() -> "Barer2".

+ 26
- 0
test/rebar_edoc_SUITE_data/foo/apps/bar2/src/bar2_app.erl Просмотреть файл

@ -0,0 +1,26 @@
%%%-------------------------------------------------------------------
%% @doc bar2 public API
%% @end
%%%-------------------------------------------------------------------
-module(bar2_app).
-behaviour(application).
%% Application callbacks
-export([start/2, stop/1]).
%%====================================================================
%% API
%%====================================================================
start(_StartType, _StartArgs) ->
bar2_sup:start_link().
%%--------------------------------------------------------------------
stop(_State) ->
ok.
%%====================================================================
%% Internal functions
%%====================================================================

+ 35
- 0
test/rebar_edoc_SUITE_data/foo/apps/bar2/src/bar2_sup.erl Просмотреть файл

@ -0,0 +1,35 @@
%%%-------------------------------------------------------------------
%% @doc bar2 top level supervisor.
%% @end
%%%-------------------------------------------------------------------
-module(bar2_sup).
-behaviour(supervisor).
%% API
-export([start_link/0]).
%% Supervisor callbacks
-export([init/1]).
-define(SERVER, ?MODULE).
%%====================================================================
%% API functions
%%====================================================================
start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
%%====================================================================
%% Supervisor callbacks
%%====================================================================
%% Child :: {Id,StartFunc,Restart,Shutdown,Type,Modules}
init([]) ->
{ok, { {one_for_all, 0, 1}, []} }.
%%====================================================================
%% Internal functions
%%====================================================================

+ 17
- 0
test/rebar_edoc_SUITE_data/foo/apps/foo/src/foo.app.src Просмотреть файл

@ -0,0 +1,17 @@
{application, foo,
[{description, "An OTP application"},
{vsn, "0.1.0"},
{registered, []},
{mod, { foo_app, []}},
{applications,
[kernel,
stdlib,
bar1, bar2
]},
{env,[]},
{modules, []},
{maintainers, []},
{licenses, []},
{links, []}
]}.

+ 19
- 0
test/rebar_edoc_SUITE_data/foo/apps/foo/src/foo.erl Просмотреть файл

@ -0,0 +1,19 @@
-module(foo).
-export([foo/0, bar1/0, bar2/0]).
-export_type([fooer/0]).
-type fooer() :: string().
% @doc Foo function returns fooer.
-spec foo() -> fooer().
foo() -> "fooer".
% @doc Bar1 function returns barer1.
-spec bar1() -> bar1:barer1().
bar1() -> bar1:bar1().
% @doc Bar2 functions returns barer2.
-spec bar2() -> bar2:barer2().
bar2() -> bar2:bar2().

+ 26
- 0
test/rebar_edoc_SUITE_data/foo/apps/foo/src/foo_app.erl Просмотреть файл

@ -0,0 +1,26 @@
%%%-------------------------------------------------------------------
%% @doc foo public API
%% @end
%%%-------------------------------------------------------------------
-module(foo_app).
-behaviour(application).
%% Application callbacks
-export([start/2, stop/1]).
%%====================================================================
%% API
%%====================================================================
start(_StartType, _StartArgs) ->
foo_sup:start_link().
%%--------------------------------------------------------------------
stop(_State) ->
ok.
%%====================================================================
%% Internal functions
%%====================================================================

+ 35
- 0
test/rebar_edoc_SUITE_data/foo/apps/foo/src/foo_sup.erl Просмотреть файл

@ -0,0 +1,35 @@
%%%-------------------------------------------------------------------
%% @doc foo top level supervisor.
%% @end
%%%-------------------------------------------------------------------
-module(foo_sup).
-behaviour(supervisor).
%% API
-export([start_link/0]).
%% Supervisor callbacks
-export([init/1]).
-define(SERVER, ?MODULE).
%%====================================================================
%% API functions
%%====================================================================
start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
%%====================================================================
%% Supervisor callbacks
%%====================================================================
%% Child :: {Id,StartFunc,Restart,Shutdown,Type,Modules}
init([]) ->
{ok, { {one_for_all, 0, 1}, []} }.
%%====================================================================
%% Internal functions
%%====================================================================

Загрузка…
Отмена
Сохранить