1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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.
|