summaryrefslogtreecommitdiff
path: root/test/rebar_edoc_SUITE.erl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2016-08-25 09:35:59 -0400
committerFred Hebert <mononcqc@ferd.ca>2016-08-25 09:35:59 -0400
commit2c78cfd557249166cdd264d976ca191eb8a5061f (patch)
treee7cce69c330459dc72ae40b790496d0153a94b31 /test/rebar_edoc_SUITE.erl
parent5d475eefa27ddbb7876d74a9a3f6f45267333d57 (diff)
Add tests for multi-app edoc linking working
Diffstat (limited to 'test/rebar_edoc_SUITE.erl')
-rw-r--r--test/rebar_edoc_SUITE.erl52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/rebar_edoc_SUITE.erl b/test/rebar_edoc_SUITE.erl
new file mode 100644
index 0000000..fded2b0
--- /dev/null
+++ b/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.