Skip to content

Commit 110c7d6

Browse files
committed
Try to find app-specific schema in deps/App, otherwise try deps/../priv
1 parent 70b24f6 commit 110c7d6

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/rabbit_ct_config_schema.erl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ init_schemas(App, Config) ->
2525
RabbitSchema = filename:join([DepsDir, "rabbit", "priv", "schema", "rabbitmq.schema"]),
2626
Schemas = case App of
2727
rabbit -> [RabbitSchema];
28-
_ -> [RabbitSchema,
29-
filename:join([DepsDir, App, "priv", "schema", atom_to_list(App) ++ ".schema"])]
28+
_ -> [RabbitSchema, find_app_schema(App, DepsDir)]
3029
end,
3130
ct:pal("Schemas ~p~n", [Schemas]),
3231
SchemaDir = filename:join(?config(data_dir, Config), "schema"),
@@ -45,6 +44,23 @@ init_schemas(App, Config) ->
4544
{conf_snippets, Snippets}
4645
]).
4746

47+
find_app_schema(App, DepsDir) ->
48+
Schema = filename:join([DepsDir, App, "priv", get_schema_for(App)]),
49+
does_schema_exist(filelib:is_regular(Schema), App, DepsDir, Schema, cont).
50+
51+
does_schema_exist(true, _App, _DepsDir, Schema, _) ->
52+
Schema;
53+
does_schema_exist(false, App, _DepsDir, _Schema, stop) ->
54+
ct:fail("Could not find schema for app: ~p~n", [App]);
55+
does_schema_exist(false, App, DepsDir, _Schema, cont) ->
56+
% If not in umbrella, priv will be at ../priv
57+
PrivDir = filename:join([DepsDir, "..", "priv"]),
58+
Schema = filename:join([PrivDir, get_schema_for(App)]),
59+
does_schema_exist(filelib:is_regular(Schema), App, DepsDir, Schema, stop).
60+
61+
get_schema_for(App) ->
62+
filename:join(["schema", atom_to_list(App) ++ ".schema"]).
63+
4864
copy_to(File, Dir) ->
4965
BaseName = filename:basename(File),
5066
{ok, _} = file:copy(File, Dir ++ "/" ++ BaseName).

src/rabbit_ct_helpers.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ ensure_erlang_mk_depsdir(Config) ->
166166
true -> set_config(Config, {erlang_mk_depsdir, Path});
167167
false -> {skip,
168168
"deps directory required, " ++
169-
"please set DEPSD_DIR or 'erlang_mk_depsdir' " ++
169+
"please set DEPS_DIR or 'erlang_mk_depsdir' " ++
170170
"in ct config"}
171171
end.
172172

0 commit comments

Comments
 (0)