From 2f7078f314c5880644eb343d7773bc8e22096604 Mon Sep 17 00:00:00 2001 From: ieQu1 <99872536+ieQu1@users.noreply.github.com> Date: Fri, 1 Jul 2022 09:33:54 +0200 Subject: [PATCH 1/2] fix(bpapi): Make error messages nicer --- apps/emqx/test/emqx_static_checks.erl | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/apps/emqx/test/emqx_static_checks.erl b/apps/emqx/test/emqx_static_checks.erl index 4ff4df612..d1f27a3d6 100644 --- a/apps/emqx/test/emqx_static_checks.erl +++ b/apps/emqx/test/emqx_static_checks.erl @@ -29,9 +29,12 @@ init_per_suite(Config) -> end_per_suite(_Config) -> logger:notice( - "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", - [] + asciiart:visible( + $=, + "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) -> @@ -47,9 +50,14 @@ t_run_check(_) -> check_if_versions_consistent(OldData, NewData) orelse begin logger:critical( - "BPAPI versions were changed, but not committed to the repo.\n" - "Run 'make && make static_checks' and then add the changed " - "'bpapi.versions' files to the commit." + asciiart:visible( + $=, + "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) end, @@ -59,6 +67,8 @@ t_run_check(_) -> logger:info("Backplane API dump files: ~p", [BpapiDumps]), ?assert(emqx_bpapi_static_checks:check_compat(BpapiDumps)) catch + error:version_mismatch -> + error(tc_failed); EC:Err:Stack -> logger:critical("Test suite failed: ~p:~p~nStack:~p", [EC, Err, Stack]), error(tc_failed) From e2c2f7b224e68c48ce9ee77e80d67b0295ca5ea2 Mon Sep 17 00:00:00 2001 From: ieQu1 <99872536+ieQu1@users.noreply.github.com> Date: Fri, 1 Jul 2022 09:50:04 +0200 Subject: [PATCH 2/2] feat(bpapi): Add a header to bpapi.versions file --- apps/emqx/priv/bpapi.versions | 1 + apps/emqx/test/emqx_bpapi_static_checks.erl | 3 +++ 2 files changed, 4 insertions(+) diff --git a/apps/emqx/priv/bpapi.versions b/apps/emqx/priv/bpapi.versions index 80782beca..3b49ce786 100644 --- a/apps/emqx/priv/bpapi.versions +++ b/apps/emqx/priv/bpapi.versions @@ -1,3 +1,4 @@ +%% This file is automatically generated by `make static_checks`, do not edit. {emqx,1}. {emqx_authn,1}. {emqx_authz,1}. diff --git a/apps/emqx/test/emqx_bpapi_static_checks.erl b/apps/emqx/test/emqx_bpapi_static_checks.erl index 63f717be5..acb941d30 100644 --- a/apps/emqx/test/emqx_bpapi_static_checks.erl +++ b/apps/emqx/test/emqx_bpapi_static_checks.erl @@ -300,6 +300,9 @@ dump_versions(APIs) -> logger:notice("Dumping API versions to ~p", [Filename]), ok = filelib:ensure_dir(Filename), {ok, FD} = file:open(Filename, [write]), + io:format( + FD, "%% This file is automatically generated by `make static_checks`, do not edit.~n", [] + ), lists:foreach( fun(API) -> ok = io:format(FD, "~p.~n", [API])