Merge pull request #8376 from ieQu1/nicer-bpapi-errors

fix(bpapi): Make error messages nicer
This commit is contained in:
ieQu1 2022-07-01 14:50:49 +02:00 committed by GitHub
commit 7d46e8671e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 6 deletions

View File

@ -1,3 +1,4 @@
%% This file is automatically generated by `make static_checks`, do not edit.
{emqx,1}. {emqx,1}.
{emqx_authn,1}. {emqx_authn,1}.
{emqx_authz,1}. {emqx_authz,1}.

View File

@ -306,6 +306,9 @@ dump_versions(APIs) ->
logger:notice("Dumping API versions to ~p", [Filename]), logger:notice("Dumping API versions to ~p", [Filename]),
ok = filelib:ensure_dir(Filename), ok = filelib:ensure_dir(Filename),
{ok, FD} = file:open(Filename, [write]), {ok, FD} = file:open(Filename, [write]),
io:format(
FD, "%% This file is automatically generated by `make static_checks`, do not edit.~n", []
),
lists:foreach( lists:foreach(
fun(API) -> fun(API) ->
ok = io:format(FD, "~p.~n", [API]) ok = io:format(FD, "~p.~n", [API])

View File

@ -29,9 +29,12 @@ init_per_suite(Config) ->
end_per_suite(_Config) -> end_per_suite(_Config) ->
logger:notice( logger:notice(
"If this test suite failed, and you are unsure why, read this:~n" asciiart:visible(
"https://github.com/emqx/emqx/blob/master/apps/emqx/src/bpapi/README.md", $=,
[] "If this test suite failed, and you are unsure why, read this:~n"
"https://github.com/emqx/emqx/blob/master/apps/emqx/src/bpapi/README.md",
[]
)
). ).
check_if_versions_consistent(OldData, NewData) -> check_if_versions_consistent(OldData, NewData) ->
@ -47,9 +50,14 @@ t_run_check(_) ->
check_if_versions_consistent(OldData, NewData) orelse check_if_versions_consistent(OldData, NewData) orelse
begin begin
logger:critical( logger:critical(
"BPAPI versions were changed, but not committed to the repo.\n" asciiart:visible(
"Run 'make && make static_checks' and then add the changed " $=,
"'bpapi.versions' files to the commit." "BPAPI versions were changed, but not committed to the repo.\n\n"
"Versions file is generated automatically, to update it, run\n"
"'make && make static_checks' locally, and then add the\n"
"changed 'bpapi.versions' files to the commit.\n",
[]
)
), ),
error(version_mismatch) error(version_mismatch)
end, end,
@ -59,6 +67,8 @@ t_run_check(_) ->
logger:info("Backplane API dump files: ~p", [BpapiDumps]), logger:info("Backplane API dump files: ~p", [BpapiDumps]),
?assert(emqx_bpapi_static_checks:check_compat(BpapiDumps)) ?assert(emqx_bpapi_static_checks:check_compat(BpapiDumps))
catch catch
error:version_mismatch ->
error(tc_failed);
EC:Err:Stack -> EC:Err:Stack ->
logger:critical("Test suite failed: ~p:~p~nStack:~p", [EC, Err, Stack]), logger:critical("Test suite failed: ~p:~p~nStack:~p", [EC, Err, Stack]),
error(tc_failed) error(tc_failed)