Suppress export-related compiler warnings 1798/head
authorJay Doane <jay.s.doane@gmail.com>
Thu, 27 Dec 2018 20:49:47 +0000 (12:49 -0800)
committerJay Doane <jay.s.doane@gmail.com>
Thu, 27 Dec 2018 21:07:57 +0000 (13:07 -0800)
- For export_all warnings: either replace with explicit exports, add
nowarn_export_all compiler directives when appropriate, or in the case
of couch_epi_sup, move the test to dedicated test file and export the
function needed for testing.

- For "function already exported" warning in couch_key_tree_prop_tests,
remove include_lib attribute for eunit.hrl since it already gets
imported in triq.hrl

22 files changed:
src/couch/src/couch.erl
src/couch/test/couch_key_tree_prop_tests.erl
src/couch_epi/src/couch_epi_sup.erl
src/couch_epi/test/couch_epi_basic_test.erl [new file with mode: 0644]
src/couch_log/src/couch_log_writer_file.erl
src/couch_log/src/couch_log_writer_syslog.erl
src/couch_log/test/couch_log_test_util.erl
src/couch_mrview/src/couch_mrview_test_util.erl
src/couch_pse_tests/src/cpse_test_attachments.erl
src/couch_pse_tests/src/cpse_test_compaction.erl
src/couch_pse_tests/src/cpse_test_fold_changes.erl
src/couch_pse_tests/src/cpse_test_fold_docs.erl
src/couch_pse_tests/src/cpse_test_fold_purge_infos.erl
src/couch_pse_tests/src/cpse_test_get_set_props.erl
src/couch_pse_tests/src/cpse_test_open_close_delete.erl
src/couch_pse_tests/src/cpse_test_purge_docs.erl
src/couch_pse_tests/src/cpse_test_purge_seqs.erl
src/couch_pse_tests/src/cpse_test_read_write_docs.erl
src/couch_pse_tests/src/cpse_test_ref_counting.erl
src/couch_pse_tests/src/cpse_util.erl
src/ddoc_cache/test/ddoc_cache_tutil.erl
src/fabric/src/fabric_dict.erl

index fd5c9e1..60a8b66 100644 (file)
 
 -module(couch).
 
--compile(export_all).
+-export([
+    start/0,
+    stop/0,
+    restart/0
+]).
 
 
 deps() ->
index 604a828..f814692 100644 (file)
@@ -14,7 +14,6 @@
 
 -include_lib("triq/include/triq.hrl").
 -triq(eunit).
--include_lib("eunit/include/eunit.hrl").
 
 -define(SIZE_REDUCTION, 3).  % How much to reduce size with tree depth.
 -define(MAX_BRANCHES, 4).  % Maximum number of branches.
index 509f5a1..218db54 100644 (file)
 %% Supervisor callbacks
 -export([init/1]).
 
+%% For testing
+-export([
+    plugin_childspecs/3
+]).
+
 %% Helper macro for declaring children of supervisor
 -define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
 
@@ -132,105 +137,3 @@ merge([], Children) ->
     Children;
 merge([{Id, _, _, _, _, _} = Spec | Rest], Children) ->
     merge(Rest, lists:keystore(Id, 1, Children, Spec)).
-
-
-%% ------------------------------------------------------------------
-%% Tests
-%% ------------------------------------------------------------------
-
--ifdef(TEST).
--include_lib("eunit/include/eunit.hrl").
-
-%% ----
-%% BEGIN couch_epi_plugin behaviour callbacks
-
--compile([export_all]).
-
-app() -> test_app.
-providers() ->
-    [
-        {my_service, provider1},
-        {my_service, provider2}
-    ].
-
-services() ->
-    [
-        {my_service, ?MODULE}
-    ].
-
-data_providers() ->
-    [
-        {{test_app, descriptions}, {static_module, ?MODULE}, [{interval, 100}]}
-    ].
-
-data_subscriptions() ->
-    [
-        {test_app, descriptions}
-    ].
-
-processes() ->
-    [
-        {?MODULE, [?CHILD(extra_process, worker)]},
-        {?MODULE, [{to_replace, {new, start_link, [bar]},
-            permanent, 5000, worker, [bar]}]}
-    ].
-
-notify(_Key, _OldData, _NewData) ->
-    ok.
-
-%% END couch_epi_plugin behaviour callbacks
-%% ----
-
-parse_child_id(Id) when is_atom(Id) ->
-    Id;
-parse_child_id(Id) ->
-    ["couch_epi_codechange_monitor", ServiceName, KindStr] = string:tokens(Id, "|"),
-    Kind = list_to_atom(KindStr),
-    case string:tokens(ServiceName, ":") of
-        [ServiceId, Key] ->
-            {{list_to_atom(ServiceId), list_to_atom(Key)}, Kind};
-        [Key] ->
-            {list_to_atom(Key), Kind}
-    end.
-
-basic_test() ->
-    Expected = lists:sort([
-        {extra_process, [], [extra_process]},
-        {to_replace, [bar], [bar]},
-        {{my_service, providers},
-            [couch_epi_functions_gen_my_service],
-            [couch_epi_codechange_monitor, couch_epi_functions_gen_my_service,
-                provider1, provider2]},
-        {{my_service, services},
-            [couch_epi_functions_gen_my_service],
-            [couch_epi_codechange_monitor, couch_epi_functions_gen_my_service,
-                couch_epi_sup]},
-        {{{test_app, descriptions}, data_subscriptions},
-            [couch_epi_data_gen_test_app_descriptions],
-            [couch_epi_codechange_monitor,
-                couch_epi_data_gen_test_app_descriptions, couch_epi_sup]},
-        {{{test_app, descriptions}, data_providers},
-            [couch_epi_data_gen_test_app_descriptions],
-            [couch_epi_codechange_monitor, couch_epi_data_gen_test_app_descriptions,
-                couch_epi_sup]}
-    ]),
-
-    ToReplace = {to_replace, {old, start_link, [foo]}, permanent, 5000, worker, [foo]},
-    Children = lists:sort(plugin_childspecs(?MODULE, [?MODULE], [ToReplace])),
-    Results = [
-        {parse_child_id(Id), Args, lists:sort(Modules)}
-            || {Id, {_M, _F, Args}, _, _, _, Modules} <- Children
-    ],
-
-    Tests = lists:zip(Expected, Results),
-    [?assertEqual(Expect, Result) || {Expect, Result} <- Tests],
-
-    ExpectedChild = {to_replace, {new, start_link, [bar]},
-        permanent, 5000, worker, [bar]},
-    ?assertEqual(
-        ExpectedChild,
-        lists:keyfind(to_replace, 1, Children)),
-
-    ok.
-
--endif.
diff --git a/src/couch_epi/test/couch_epi_basic_test.erl b/src/couch_epi/test/couch_epi_basic_test.erl
new file mode 100644 (file)
index 0000000..587d156
--- /dev/null
@@ -0,0 +1,137 @@
+% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+% use this file except in compliance with the License. You may obtain a copy of
+% the License at
+%
+% http://www.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(couch_epi_basic_test).
+
+-export([
+    start_link/0
+]).
+
+-export([
+    app/0,
+    providers/0,
+    services/0,
+    data_providers/0,
+    data_subscriptions/0,
+    processes/0,
+    notify/3
+]).
+
+-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}).
+
+
+start_link() -> ok.
+
+
+%% BEGIN couch_epi_plugin behaviour callbacks
+
+
+app() -> test_app.
+
+
+providers() ->
+    [
+        {my_service, provider1},
+        {my_service, provider2}
+    ].
+
+
+services() ->
+    [
+        {my_service, ?MODULE}
+    ].
+
+
+data_providers() ->
+    [
+        {{test_app, descriptions}, {static_module, ?MODULE}, [{interval, 100}]}
+    ].
+
+
+data_subscriptions() ->
+    [
+        {test_app, descriptions}
+    ].
+
+
+processes() ->
+    [
+        {?MODULE, [?CHILD(extra_process, worker)]},
+        {?MODULE, [{to_replace, {new, start_link, [bar]},
+            permanent, 5000, worker, [bar]}]}
+    ].
+
+
+notify(_Key, _OldData, _NewData) ->
+    ok.
+
+
+%% END couch_epi_plugin behaviour callbacks
+
+
+parse_child_id(Id) when is_atom(Id) ->
+    Id;
+parse_child_id(Id) ->
+    ["couch_epi_codechange_monitor", ServiceName, KindStr]
+        = string:tokens(Id, "|"),
+    Kind = list_to_atom(KindStr),
+    case string:tokens(ServiceName, ":") of
+        [ServiceId, Key] ->
+            {{list_to_atom(ServiceId), list_to_atom(Key)}, Kind};
+        [Key] ->
+            {list_to_atom(Key), Kind}
+    end.
+
+
+-include_lib("eunit/include/eunit.hrl").
+
+basic_test() ->
+    Expected = lists:sort([
+        {extra_process, [], [extra_process]},
+        {to_replace, [bar], [bar]},
+        {{my_service, providers},
+            [couch_epi_functions_gen_my_service],
+            [couch_epi_codechange_monitor, couch_epi_functions_gen_my_service,
+                provider1, provider2]},
+        {{my_service, services},
+            [couch_epi_functions_gen_my_service],
+            lists:sort([couch_epi_codechange_monitor,
+                couch_epi_functions_gen_my_service, ?MODULE])},
+        {{{test_app, descriptions}, data_subscriptions},
+            [couch_epi_data_gen_test_app_descriptions],
+            lists:sort([couch_epi_codechange_monitor,
+                couch_epi_data_gen_test_app_descriptions, ?MODULE])},
+        {{{test_app, descriptions}, data_providers},
+            [couch_epi_data_gen_test_app_descriptions],
+            lists:sort([couch_epi_codechange_monitor,
+                couch_epi_data_gen_test_app_descriptions, ?MODULE])}
+    ]),
+
+    ToReplace = {to_replace,
+        {old, start_link, [foo]}, permanent, 5000, worker, [foo]},
+    Children = lists:sort(couch_epi_sup:plugin_childspecs(
+        ?MODULE, [?MODULE], [ToReplace])),
+    Results = [
+        {parse_child_id(Id), Args, lists:sort(Modules)}
+            || {Id, {_M, _F, Args}, _, _, _, Modules} <- Children
+    ],
+
+    Tests = lists:zip(Expected, Results),
+    [?assertEqual(Expect, Result) || {Expect, Result} <- Tests],
+
+    ExpectedChild = {to_replace, {new, start_link, [bar]},
+        permanent, 5000, worker, [bar]},
+    ?assertEqual(
+        ExpectedChild,
+        lists:keyfind(to_replace, 1, Children)),
+
+    ok.
index fb01363..1fe35a8 100644 (file)
@@ -37,7 +37,9 @@
 
 
 -ifdef(TEST).
--compile(export_all).
+-export([
+    maybe_reopen/1
+]).
 -endif.
 
 
index d918bb7..e3a6fc4 100644 (file)
 
 
 -ifdef(TEST).
--compile(export_all).
+-export([
+    get_facility/1,
+    get_level/1
+]).
 -endif.
 
 
index c7fd34f..00f3981 100644 (file)
 % the License.
 
 -module(couch_log_test_util).
--compile(export_all).
 
+-export([
+    start/0,
+    stop/1,
+    last_log/0,
+    last_log_key/0,
+    wait_for_config/0,
+    with_config_listener/1,
+    with_level/2,
+    with_meck/2
+]).
 
 -include("couch_log.hrl").
 
index ac29826..a6242cd 100644 (file)
@@ -13,6 +13,7 @@
 -module(couch_mrview_test_util).
 
 -compile(export_all).
+-compile(nowarn_export_all).
 
 -include_lib("couch/include/couch_db.hrl").
 -include_lib("couch/include/couch_eunit.hrl").
index 61ada38..8c454ec 100644 (file)
@@ -12,6 +12,7 @@
 
 -module(cpse_test_attachments).
 -compile(export_all).
+-compile(nowarn_export_all).
 
 
 -include_lib("eunit/include/eunit.hrl").
index d006111..c8a2c1a 100644 (file)
@@ -12,6 +12,7 @@
 
 -module(cpse_test_compaction).
 -compile(export_all).
+-compile(nowarn_export_all).
 
 
 -include_lib("eunit/include/eunit.hrl").
index 00a402c..4363962 100644 (file)
@@ -12,6 +12,7 @@
 
 -module(cpse_test_fold_changes).
 -compile(export_all).
+-compile(nowarn_export_all).
 
 
 -include_lib("eunit/include/eunit.hrl").
index 09fbd26..d43930c 100644 (file)
@@ -12,6 +12,7 @@
 
 -module(cpse_test_fold_docs).
 -compile(export_all).
+-compile(nowarn_export_all).
 
 
 -include_lib("eunit/include/eunit.hrl").
index 42bc536..4826c5d 100644 (file)
@@ -12,6 +12,7 @@
 
 -module(cpse_test_fold_purge_infos).
 -compile(export_all).
+-compile(nowarn_export_all).
 
 
 -include_lib("eunit/include/eunit.hrl").
index 1f86844..02f0eb5 100644 (file)
@@ -12,6 +12,7 @@
 
 -module(cpse_test_get_set_props).
 -compile(export_all).
+-compile(nowarn_export_all).
 
 
 -include_lib("eunit/include/eunit.hrl").
index c19d0ee..d9b589f 100644 (file)
@@ -12,6 +12,7 @@
 
 -module(cpse_test_open_close_delete).
 -compile(export_all).
+-compile(nowarn_export_all).
 
 
 -include_lib("eunit/include/eunit.hrl").
index 34bd34d..1788eec 100644 (file)
@@ -12,6 +12,7 @@
 
 -module(cpse_test_purge_docs).
 -compile(export_all).
+-compile(nowarn_export_all).
 
 
 -include_lib("eunit/include/eunit.hrl").
index a943fc4..057d6da 100644 (file)
@@ -12,6 +12,7 @@
 
 -module(cpse_test_purge_seqs).
 -compile(export_all).
+-compile(nowarn_export_all).
 
 
 -include_lib("eunit/include/eunit.hrl").
index 84bf9f3..fd830d8 100644 (file)
@@ -12,6 +12,7 @@
 
 -module(cpse_test_read_write_docs).
 -compile(export_all).
+-compile(nowarn_export_all).
 
 
 -include_lib("eunit/include/eunit.hrl").
index 2a0e4c2..cb115a7 100644 (file)
@@ -12,6 +12,7 @@
 
 -module(cpse_test_ref_counting).
 -compile(export_all).
+-compile(nowarn_export_all).
 
 
 -include_lib("eunit/include/eunit.hrl").
index d3e1259..7556d23 100644 (file)
@@ -12,6 +12,7 @@
 
 -module(cpse_util).
 -compile(export_all).
+-compile(nowarn_export_all).
 
 
 -include_lib("eunit/include/eunit.hrl").
index ec5d2db..b34d4b1 100644 (file)
 -module(ddoc_cache_tutil).
 
 
--compile(export_all).
+-export([
+    start_couch/0,
+    start_couch/1,
+    stop_couch/1,
+    clear/0,
+    get_rev/2,
+    ddocs/0,
+    purge_modules/0,
+    with/1
+]).
 
 
 -include_lib("couch/include/couch_db.hrl").
index ec2e25c..a336b47 100644 (file)
@@ -12,6 +12,7 @@
 
 -module(fabric_dict).
 -compile(export_all).
+-compile(nowarn_export_all).
 
 % Instead of ets, let's use an ordered keylist. We'll need to revisit if we
 % have >> 100 shards, so a private interface is a good idea. - APK June 2010