From 083e2da3478f1dd4549a851a33ed7f4d5088ab7f Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Fri, 13 Oct 2023 15:42:08 +0700 Subject: [PATCH] chore(bpapicheck): make some failures more user-friendly --- apps/emqx/test/emqx_bpapi_static_checks.erl | 25 ++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/apps/emqx/test/emqx_bpapi_static_checks.erl b/apps/emqx/test/emqx_bpapi_static_checks.erl index 0be5895f6..657776317 100644 --- a/apps/emqx/test/emqx_bpapi_static_checks.erl +++ b/apps/emqx/test/emqx_bpapi_static_checks.erl @@ -244,19 +244,28 @@ get_param_types(Signatures, {M, F, A}) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% dump() -> - case - { - filelib:wildcard(project_root_dir() ++ "/*_plt"), - filelib:wildcard(project_root_dir() ++ "/_build/check/lib") - } - of + RootDir = project_root_dir(), + TryRelDir = RootDir ++ "/_build/check/lib", + case {filelib:wildcard(RootDir ++ "/*_plt"), filelib:wildcard(TryRelDir)} of {[PLT | _], [RelDir | _]} -> dump(#{ plt => PLT, reldir => RelDir }); - _ -> - error("failed to guess run options") + {[], _} -> + logger:error( + "No usable PLT files found in \"~s\", abort ~n" + "Try running `rebar3 as check dialyzer` at least once first", + [RootDir] + ), + error(run_failed); + {_, []} -> + logger:error( + "No built applications found in \"~s\", abort ~n" + "Try running `rebar3 as check compile` at least once first", + [TryRelDir] + ), + error(run_failed) end. %% Collect the local BPAPI modules to a dump file