Skip to content

Find app schema either in deps/App/priv or priv/ #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/rabbit_ct_config_schema.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ init_schemas(App, Config) ->
RabbitSchema = filename:join([DepsDir, "rabbit", "priv", "schema", "rabbitmq.schema"]),
Schemas = case App of
rabbit -> [RabbitSchema];
_ -> [RabbitSchema,
filename:join([DepsDir, App, "priv", "schema", atom_to_list(App) ++ ".schema"])]
_ -> [RabbitSchema, find_app_schema(App, DepsDir)]
end,
ct:pal("Schemas ~p~n", [Schemas]),
SchemaDir = filename:join(?config(data_dir, Config), "schema"),
Expand All @@ -45,6 +44,22 @@ init_schemas(App, Config) ->
{conf_snippets, Snippets}
]).

find_app_schema(App, DepsDir) ->
Schema = get_schema_for([DepsDir, App, "priv"], App),
does_schema_exist(filelib:is_regular(Schema), App, DepsDir, Schema, cont).

does_schema_exist(true, _App, _DepsDir, Schema, _) ->
Schema;
does_schema_exist(false, App, _DepsDir, _Schema, stop) ->
ct:fail("Could not find schema for app: ~p~n", [App]);
does_schema_exist(false, App, DepsDir, _Schema, cont) ->
% If not in umbrella, priv will be at ../priv
Schema = get_schema_for([DepsDir, "..", "priv"], App),
does_schema_exist(filelib:is_regular(Schema), App, DepsDir, Schema, stop).

get_schema_for(Prefix, App) ->
filename:join(Prefix ++ ["schema", atom_to_list(App) ++ ".schema"]).

copy_to(File, Dir) ->
BaseName = filename:basename(File),
{ok, _} = file:copy(File, Dir ++ "/" ++ BaseName).
Expand Down
2 changes: 1 addition & 1 deletion src/rabbit_ct_helpers.erl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ ensure_erlang_mk_depsdir(Config) ->
true -> set_config(Config, {erlang_mk_depsdir, Path});
false -> {skip,
"deps directory required, " ++
"please set DEPSD_DIR or 'erlang_mk_depsdir' " ++
"please set DEPS_DIR or 'erlang_mk_depsdir' " ++
"in ct config"}
end.

Expand Down