diff options
| author | Rin Kuryloski <kuryloskip@vmware.com> | 2023-05-01 10:32:59 +0200 |
|---|---|---|
| committer | Rin Kuryloski <kuryloskip@vmware.com> | 2023-05-12 17:50:43 +0200 |
| commit | 23f8cd8f4d29e91c8fed4e762632e8bdbb109e76 (patch) | |
| tree | d2d93c4bab75be8e3579db3d8c82441be3b8548e /tools/erlang_app_equal | |
| parent | c79cb38c7de301589c4ec0581f7ee67af4dc2e5b (diff) | |
| download | rabbitmq-server-git-rin/nightly-compare-build-systems.tar.gz | |
Add a workflow to compare the bazel/erlang.mk outputrin/nightly-compare-build-systems
To catch any drift between the builds
Diffstat (limited to 'tools/erlang_app_equal')
| -rwxr-xr-x | tools/erlang_app_equal | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tools/erlang_app_equal b/tools/erlang_app_equal new file mode 100755 index 0000000000..ba3a4bef28 --- /dev/null +++ b/tools/erlang_app_equal @@ -0,0 +1,68 @@ +#!/usr/bin/env escript +%% -*- erlang -*- +%%! -nocookie + +-mode(compile). + +main([Left, Right]) -> + {ok, LeftMetadata} = file:consult(Left), + {ok, RightMetadata} = file:consult(Right), + compare(LeftMetadata, RightMetadata), + halt(); +main(_) -> + halt(1). + +compare(LeftMetadata, RightMetadata) -> + [{application, LeftApp, LeftProps}] = LeftMetadata, + [{application, RightApp, RightProps}] = RightMetadata, + + assert_equal(LeftApp, RightApp, "application name"), + + LeftId = proplists:get_value(id, LeftProps), + RightId = proplists:get_value(id, RightProps), + case LeftId of + RightId -> + ok; + _ -> + io:format(standard_error, + "Warning:\t 'id' does not match (~p != ~p)~n", [LeftId, RightId]) + end, + + LeftPropsMap = proplists:to_map(proplists:delete(id, LeftProps)), + RightPropsMap = proplists:to_map(proplists:delete(id, RightProps)), + assert_equal( + lists:sort(maps:keys(LeftPropsMap)), + lists:sort(maps:keys(RightPropsMap)), + "app property keys" + ), + [case K of + K when K =:= applications orelse K =:= modules -> + assert_equal( + lists:sort(maps:get(K, LeftPropsMap)), + lists:sort(maps:get(K, RightPropsMap)), + K + ); + env -> + assert_equal( + proplists:to_map(maps:get(K, LeftPropsMap)), + proplists:to_map(maps:get(K, RightPropsMap)), + K + ); + _ -> + assert_equal( + maps:get(K, LeftPropsMap), + maps:get(K, RightPropsMap), + K + ) + end || K <- lists:sort(maps:keys(LeftPropsMap))], + ok. + +assert_equal(Expected, Actual, Context) -> + case Actual of + Expected -> + ok; + _ -> + io:format(standard_error, + "Expected:\t~p~n But got:\t~p~n For:\t~p~n", [Expected, Actual, Context]), + erlang:error(assertion_failed) + end. |
