Merge pull request #12 from rabbitmq/find-rabbit-schema
Correctly find schema for rabbit application named "rabbit.schema"
This commit is contained in:
		
						commit
						f0e85e168a
					
				|  | @ -22,8 +22,7 @@ | ||||||
| 
 | 
 | ||||||
| init_schemas(App, Config) -> | init_schemas(App, Config) -> | ||||||
|     DepsDir = ?config(erlang_mk_depsdir, Config), |     DepsDir = ?config(erlang_mk_depsdir, Config), | ||||||
|     % Note: the schema for the rabbit app is named "rabbitmq.schema" |     RabbitSchema = find_app_schema(rabbit, DepsDir), | ||||||
|     RabbitSchema = filename:join([DepsDir, "rabbit", "priv", "schema", "rabbitmq.schema"]), |  | ||||||
|     Schemas = case App of |     Schemas = case App of | ||||||
|         rabbit -> [RabbitSchema]; |         rabbit -> [RabbitSchema]; | ||||||
|         _      -> [RabbitSchema, find_app_schema(App, DepsDir)] |         _      -> [RabbitSchema, find_app_schema(App, DepsDir)] | ||||||
|  | @ -46,20 +45,21 @@ init_schemas(App, Config) -> | ||||||
|         ]). |         ]). | ||||||
| 
 | 
 | ||||||
| find_app_schema(App, DepsDir) -> | find_app_schema(App, DepsDir) -> | ||||||
|     Schema = get_schema_for([DepsDir, App, "priv"], App), |     SchemaFile = get_schema_for([DepsDir, App], App), | ||||||
|     does_schema_exist(filelib:is_regular(Schema), App, DepsDir, Schema, cont). |     does_schema_exist(filelib:is_regular(SchemaFile), App, DepsDir, SchemaFile, cont). | ||||||
| 
 | 
 | ||||||
| does_schema_exist(true, _App, _DepsDir, Schema, _) -> | does_schema_exist(true, _App, _DepsDir, SchemaFile, _) -> | ||||||
|     Schema; |     SchemaFile; | ||||||
| does_schema_exist(false, App, _DepsDir, _Schema, stop) -> | does_schema_exist(false, App, _DepsDir, _SchemaFile, stop) -> | ||||||
|     ct:fail("Could not find schema for app: ~p~n", [App]); |     ct:fail("Could not find schema for app: ~p~n", [App]); | ||||||
| does_schema_exist(false, App, DepsDir, _Schema, cont) -> | does_schema_exist(false, App, DepsDir, _SchemaFile, cont) -> | ||||||
|     % If not in umbrella, priv will be at ../priv |     % If not in umbrella, priv will be at ../priv | ||||||
|     Schema = get_schema_for([DepsDir, "..", "priv"], App), |     SchemaFile = get_schema_for([DepsDir, ".."], App), | ||||||
|     does_schema_exist(filelib:is_regular(Schema), App, DepsDir, Schema, stop). |     does_schema_exist(filelib:is_regular(SchemaFile), App, DepsDir, SchemaFile, stop). | ||||||
| 
 | 
 | ||||||
| get_schema_for(Prefix, App) -> | get_schema_for(Prefix, App) -> | ||||||
|     filename:join(Prefix ++ ["schema", atom_to_list(App) ++ ".schema"]). |     SchemaFileName = atom_to_list(App) ++ ".schema", | ||||||
|  |     filename:join(Prefix ++ ["priv", "schema", SchemaFileName]). | ||||||
| 
 | 
 | ||||||
| copy_to(File, Dir) -> | copy_to(File, Dir) -> | ||||||
|     BaseName = filename:basename(File), |     BaseName = filename:basename(File), | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue