Explorar el Código

Fix testcases warns (#3906)

Shawn hace 5 años
padre
commit
10dbb5bc96

+ 2 - 3
Makefile

@@ -19,9 +19,8 @@ ensure-rebar3:
 
 $(REBAR): ensure-rebar3
 
-.PHONY: distclean
-distclean:
-	@rm -rf _build
+ct: $(REBAR)
+	$(REBAR) ct
 
 .PHONY: $(PROFILES)
 $(PROFILES:%=%): $(REBAR)

+ 1 - 1
apps/emqx_auth_ldap/test/emqx_auth_ldap_bind_as_user_SUITE.erl

@@ -16,8 +16,8 @@
 
 -module(emqx_auth_ldap_bind_as_user_SUITE).
 
+-compile(nowarn_export_all).
 -compile(export_all).
--compile(no_warning_export).
 
 -include_lib("emqx/include/emqx.hrl").
 -include_lib("eunit/include/eunit.hrl").

+ 1 - 0
apps/emqx_auth_mnesia/test/emqx_acl_mnesia_SUITE.erl

@@ -16,6 +16,7 @@
 
 -module(emqx_acl_mnesia_SUITE).
 
+-compile(nowarn_export_all).
 -compile(export_all).
 
 -include("emqx_auth_mnesia.hrl").

+ 1 - 0
apps/emqx_auth_mnesia/test/emqx_auth_mnesia_SUITE.erl

@@ -13,6 +13,7 @@
 
 -module(emqx_auth_mnesia_SUITE).
 
+-compile(nowarn_export_all).
 -compile(export_all).
 
 -include("emqx_auth_mnesia.hrl").

+ 1 - 0
apps/emqx_auth_pgsql/test/emqx_auth_pgsql_SUITE.erl

@@ -16,6 +16,7 @@
 
 -module(emqx_auth_pgsql_SUITE).
 
+-compile(nowarn_export_all).
 -compile(export_all).
 
 -define(POOL, emqx_auth_pgsql).

+ 1 - 0
apps/emqx_auth_redis/test/emqx_auth_redis_SUITE.erl

@@ -16,6 +16,7 @@
 
 -module(emqx_auth_redis_SUITE).
 
+-compile(nowarn_export_all).
 -compile(export_all).
 
 -include_lib("emqx/include/emqx.hrl").

+ 0 - 38
apps/emqx_bridge_mqtt/test/emqx_bridge_worker_tests.erl

@@ -124,39 +124,6 @@ manual_start_stop_test() ->
     emqx_bridge_worker:ensure_stopped(?BRIDGE_REG_NAME),
     emqx_metrics:stop().
 
-%% Feed messages to bridge
-sender_loop(_Pid, [], _) -> exit(normal);
-sender_loop(Pid, [Num | Rest], Interval) ->
-    random_sleep(Interval),
-    Pid ! {deliver, dummy, make_msg(Num)},
-    sender_loop(Pid, Rest, Interval).
-
-%% Feed acknowledgments to bridge
-receiver_loop(_Pid, [], _) -> ok;
-receiver_loop(Pid, Nums, Interval) ->
-    receive
-        {batch, BatchRef, Batch} ->
-            Rest = match_nums(Batch, Nums),
-            random_sleep(Interval),
-            emqx_bridge_worker:handle_ack(Pid, BatchRef),
-            receiver_loop(Pid, Rest, Interval)
-    end.
-
-random_sleep(MaxInterval) ->
-    case rand:uniform(MaxInterval) - 1 of
-        0 -> ok;
-        T -> timer:sleep(T)
-    end.
-
-match_nums([], Rest) -> Rest;
-match_nums([#message{payload = P} | Rest], Nums) ->
-    I = binary_to_integer(P),
-    case Nums of
-        [I | NumsLeft] -> match_nums(Rest, NumsLeft);
-        [J | _] when J > I -> match_nums(Rest, Nums); %% allow retry
-        _ -> error([{received, I}, {expecting, Nums}])
-    end.
-
 make_config(Ref, TestPid, Result) ->
     #{test_pid => TestPid,
       test_ref => Ref,
@@ -165,8 +132,3 @@ make_config(Ref, TestPid, Result) ->
       connect_result => Result,
       start_type => auto
      }.
-
-make_msg(I) ->
-    Payload = integer_to_binary(I),
-    emqx_message:make(<<"test/topic">>, Payload).
-

+ 6 - 6
apps/emqx_coap/test/emqx_coap_SUITE.erl

@@ -84,7 +84,7 @@ t_observe(_Config) ->
     Notif = receive_notification(),
     ?LOGT("observer get Notif=~p", [Notif]),
     {coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv}} = Notif,
-    ?_assertEqual(Payload, PayloadRecv),
+    ?assertEqual(Payload, PayloadRecv),
 
     er_coap_observer:stop(Pid),
     timer:sleep(100),
@@ -107,7 +107,7 @@ t_observe_wildcard(_Config) ->
     Notif = receive_notification(),
     ?LOGT("observer get Notif=~p", [Notif]),
     {coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv}} = Notif,
-    ?_assertEqual(Payload, PayloadRecv),
+    ?assertEqual(Payload, PayloadRecv),
 
     er_coap_observer:stop(Pid),
     timer:sleep(100),
@@ -133,7 +133,7 @@ t_observe_pub(_Config) ->
     Notif2 = receive_notification(),
     ?LOGT("observer get Notif2=~p", [Notif2]),
     {coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv2}} = Notif2,
-    ?_assertEqual(Payload2, PayloadRecv2),
+    ?assertEqual(Payload2, PayloadRecv2),
 
     Topic3 = <<"j/b">>, Payload3 = <<"ET629">>,
     TopicStr3 = http_uri:encode(binary_to_list(Topic3)),
@@ -144,7 +144,7 @@ t_observe_pub(_Config) ->
     Notif3 = receive_notification(),
     ?LOGT("observer get Notif3=~p", [Notif3]),
     {coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv3}} = Notif3,
-    ?_assertEqual(Payload3, PayloadRecv3),
+    ?assertEqual(Payload3, PayloadRecv3),
 
     er_coap_observer:stop(Pid).
 
@@ -172,14 +172,14 @@ t_one_clientid_sub_2_topics(_Config) ->
     Notif1 = receive_notification(),
     ?LOGT("observer 1 get Notif=~p", [Notif1]),
     {coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv1}} = Notif1,
-    ?_assertEqual(Payload1, PayloadRecv1),
+    ?assertEqual(Payload1, PayloadRecv1),
 
     emqx:publish(emqx_message:make(Topic2, Payload2)),
 
     Notif2 = receive_notification(),
     ?LOGT("observer 2 get Notif=~p", [Notif2]),
     {coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv2}} = Notif2,
-    ?_assertEqual(Payload2, PayloadRecv2),
+    ?assertEqual(Payload2, PayloadRecv2),
 
     er_coap_observer:stop(Pid1),
     er_coap_observer:stop(Pid2).

+ 3 - 3
apps/emqx_coap/test/emqx_coap_ps_SUITE.erl

@@ -417,13 +417,13 @@ t_case01_subscribe(_Config) ->
     ?LOGT("observer get Notif=~p", [Notif]),
     {coap_notify, _, _, {ok,content}, #coap_content{payload = PayloadRecv}} = Notif,
 
-    ?_assertEqual(Payload, PayloadRecv),
+    ?assertEqual(Payload, PayloadRecv),
 
     %% GET to read the publish message of the topic
     Reply1 = er_coap_client:request(get, Uri1),
     ?LOGT("Reply=~p", [Reply1]),
     {ok,content, #coap_content{max_age = MaxAgeLeft,payload = <<"123">>}} = Reply1,
-    ?_assertEqual(true, MaxAgeLeft<60),
+    ?assertEqual(true, MaxAgeLeft<60),
 
     er_coap_observer:stop(Pid),
     {ok, deleted, #coap_content{}} = er_coap_client:request(delete, Uri1).
@@ -515,7 +515,7 @@ t_case01_read(_Config) ->
     Reply1 = er_coap_client:request(get, Uri),
     ?LOGT("Reply=~p", [Reply1]),
     {ok,content, #coap_content{max_age = MaxAgeLeft,payload = Payload}} = Reply1,
-    ?_assertEqual(true, MaxAgeLeft<60),
+    ?assertEqual(true, MaxAgeLeft<60),
 
     {ok, deleted, #coap_content{}} = er_coap_client:request(delete, Uri).
 

+ 1 - 0
apps/emqx_dashboard/test/emqx_dashboard_SUITE.erl

@@ -16,6 +16,7 @@
 
 -module(emqx_dashboard_SUITE).
 
+-compile(nowarn_export_all).
 -compile(export_all).
 
 -import(emqx_ct_http,

+ 2 - 3
apps/emqx_lwm2m/test/test_mqtt_broker.erl

@@ -16,6 +16,7 @@
 
 -module(test_mqtt_broker).
 
+-compile(nowarn_export_all).
 -compile(export_all).
 
 -define(LOGT(Format, Args), logger:debug("TEST_BROKER: " ++ Format, Args)).
@@ -28,8 +29,6 @@
 
 -include_lib("eunit/include/eunit.hrl").
 
--import(proplists, [get_value/2, get_value/3]).
-
 start(_, <<"attacker">>, _, _, _) ->
     {stop, auth_failure};
 start(ClientId, Username, Password, _Channel, KeepaliveInterval) ->
@@ -51,7 +50,7 @@ unsubscribe(Topic) ->
     gen_server:call(?MODULE, {unsubscribe, Topic}).
 
 get_subscrbied_topics() ->
-    [Topic || {Client, Topic} <- ets:tab2list(emqx_subscription)].
+    [Topic || {_Client, Topic} <- ets:tab2list(emqx_subscription)].
 
 start_link() ->
     gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).

+ 1 - 0
apps/emqx_plugin_template/test/emqx_plugin_template_SUITE.erl

@@ -16,6 +16,7 @@
 
 -module(emqx_plugin_template_SUITE).
 
+-compile(nowarn_export_all).
 -compile(export_all).
 
 all() -> [].

+ 1 - 0
apps/emqx_prometheus/test/emqx_prometheus_SUITE.erl

@@ -16,6 +16,7 @@
 
 -module(emqx_prometheus_SUITE).
 
+-compile(nowarn_export_all).
 -compile(export_all).
 
 all() ->

+ 1 - 0
apps/emqx_psk_file/test/emqx_psk_file_SUITE.erl

@@ -15,6 +15,7 @@
 %%--------------------------------------------------------------------
 
 -module(emqx_psk_file_SUITE).
+-compile(nowarn_export_all).
 -compile(export_all).
 
 all() -> [].

+ 1 - 0
apps/emqx_recon/test/emqx_recon_SUITE.erl

@@ -16,6 +16,7 @@
 
 -module(emqx_recon_SUITE).
 
+-compile(nowarn_export_all).
 -compile(export_all).
 
 -include_lib("eunit/include/eunit.hrl").

+ 1 - 1
apps/emqx_retainer/src/emqx_retainer.erl

@@ -177,7 +177,7 @@ handle_info(Info, State) ->
     ?LOG(error, "Unexpected info: ~p", [Info]),
     {noreply, State}.
 
-terminate(_Reason, #state{stats_timer = TRef1, expiry_timer = TRef2} = State) ->
+terminate(_Reason, #state{stats_timer = TRef1, expiry_timer = TRef2}) ->
     _ = timer:cancel(TRef1),
     _ = timer:cancel(TRef2),
     ok.

+ 1 - 1
apps/emqx_rule_engine/test/emqx_rule_engine_SUITE.erl

@@ -2103,7 +2103,7 @@ failure_action(_Id, _Params) ->
 crash_action(_Id, _Params) ->
     fun(Data, _Envs) ->
         ct:pal("applying crash action, Data: ~p", [Data]),
-        1/0
+        error(crash)
     end.
 
 init_plus_by_one_action() ->

+ 1 - 0
rebar.config

@@ -25,6 +25,7 @@
 {cover_enabled, true}.
 {cover_opts, [verbose]}.
 {cover_export_enabled, true}.
+{cover_excl_mods, [emqx_exproto_pb, emqx_exhook_pb]}.
 
 {provider_hooks,[{pre,[{release,{relup_helper,gen_appups}}]},
                  {post,[{release,{relup_helper,otp_vsn}},

+ 4 - 1
rebar.config.erl

@@ -48,7 +48,7 @@ profiles() ->
     , {check,           [ {erl_opts, [debug_info]}
                         ]}
     , {test,            [ {deps, test_deps()}
-                        , {erl_opts, [debug_info]}
+                        , {erl_opts, [debug_info] ++ erl_opts_i()}
                         ]}
     ].
 
@@ -212,3 +212,6 @@ path(Dir, Path) -> str(filename:join([Dir, Path])).
 
 str(L) when is_list(L) -> L;
 str(B) when is_binary(B) -> unicode:characters_to_list(B, utf8).
+
+erl_opts_i() ->
+    [{i, Dir}  || Dir <- filelib:wildcard("apps/**/include")].

+ 1 - 0
test/emqx_passwd_SUITE.erl

@@ -16,6 +16,7 @@
 
 -module(emqx_passwd_SUITE).
 
+-compile(nowarn_export_all).
 -compile(export_all).
 
 all() -> [t_hash].