Skip to content

Commit ceb4409

Browse files
authored
Merge pull request #9 from rabbitmq/rabbitmq-ct-helpers-8
Find app schema either in deps/App/priv or priv/
2 parents 70b24f6 + d12e687 commit ceb4409

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/rabbit_ct_config_schema.erl

Lines changed: 17 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,22 @@ init_schemas(App, Config) ->
4544
{conf_snippets, Snippets}
4645
]).
4746

47+
find_app_schema(App, DepsDir) ->
48+
Schema = get_schema_for([DepsDir, App, "priv"], 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+
Schema = get_schema_for([DepsDir, "..", "priv"], App),
58+
does_schema_exist(filelib:is_regular(Schema), App, DepsDir, Schema, stop).
59+
60+
get_schema_for(Prefix, App) ->
61+
filename:join(Prefix ++ ["schema", atom_to_list(App) ++ ".schema"]).
62+
4863
copy_to(File, Dir) ->
4964
BaseName = filename:basename(File),
5065
{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)