diff options
author | Tristan Sloughter <[email protected]> | 2014-10-06 10:54:30 -0500 |
---|---|---|
committer | Tristan Sloughter <[email protected]> | 2014-10-11 11:13:05 -0500 |
commit | 12514d2314ed52ba6d26dba7846f51e943057a2f (patch) | |
tree | be83fed15da6a78128d538320eeb6ad31cbcb975 | |
parent | e4849bd132b28ba1e1420686aadf8b2136c44fbd (diff) | |
download | relx-12514d2314ed52ba6d26dba7846f51e943057a2f.tar.gz relx-12514d2314ed52ba6d26dba7846f51e943057a2f.tar.bz2 relx-12514d2314ed52ba6d26dba7846f51e943057a2f.zip |
fix tests for providers moved to new app and config list option
-rw-r--r-- | src/rlx_cmd_args.erl | 27 | ||||
-rw-r--r-- | test/rlx_discover_SUITE.erl | 24 |
2 files changed, 31 insertions, 20 deletions
diff --git a/src/rlx_cmd_args.erl b/src/rlx_cmd_args.erl index 84aeca5..ac3e718 100644 --- a/src/rlx_cmd_args.erl +++ b/src/rlx_cmd_args.erl @@ -90,12 +90,16 @@ format_error({invalid_target, Target}) -> -spec handle_config(any(), [atom()], proplists:proplist()) -> {ok, {rlx_state:t(), [string()]}} | relx:error(). handle_config(Opts, Targets, CommandLineConfig) -> - {ok, Config} = validate_config(proplists:get_value(config, Opts, [])), - case rlx_state:new(Config, CommandLineConfig, Targets) of - {error, Error} -> - {error, Error}; - State -> - {ok, State} + case validate_config(proplists:get_value(config, Opts, [])) of + Error = {error, _} -> + Error; + {ok, Config} -> + case rlx_state:new(Config, CommandLineConfig, Targets) of + {error, Error} -> + {error, Error}; + State -> + {ok, State} + end end. -spec convert_targets([string()]) -> {ok, release | relup} | relx:error(). @@ -118,7 +122,7 @@ convert_targets([Target | _T], _Acc) -> ?RLX_ERROR({invalid_target, Target}). -spec validate_config(file:filename() | list() | undefined) -> - {ok, file:filename() | list() | undefined}. + {ok, file:filename() | list() | undefined} | relx:error(). validate_config(undefined) -> {ok, undefined}; validate_config("") -> @@ -128,7 +132,14 @@ validate_config(Config) -> true -> {ok, filename:absname(Config)}; false -> - {ok, Config} + case io_lib:printable_list(Config) of + true -> + ?RLX_ERROR({invalid_config_file, Config}); + false when is_list(Config) -> + {ok, Config}; + false -> + ?RLX_ERROR({invalid_config_file, Config}) + end end. run_creates(Opts) -> diff --git a/test/rlx_discover_SUITE.erl b/test/rlx_discover_SUITE.erl index ffa64d4..2db8e4d 100644 --- a/test/rlx_discover_SUITE.erl +++ b/test/rlx_discover_SUITE.erl @@ -77,9 +77,9 @@ normal_case(Config) -> || _ <- lists:seq(1, 100)]], State0 = rlx_state:put(proplists:get_value(state, Config), default_libs, false), - {ok, State1} = rlx_provider:new(rlx_prv_discover, State0), - DiscoverProvider = rlx_provider:get_provider(discover, rlx_state:providers(State1)), - {ok, State2} = rlx_provider:do(DiscoverProvider, State1), + {ok, State1} = providers:new(rlx_prv_discover, State0), + DiscoverProvider = providers:get_provider(discover, rlx_state:providers(State1)), + {ok, State2} = providers:do(DiscoverProvider, State1), lists:foreach(fun(App) -> ?assertMatch(true, lists:member(App, rlx_state:available_apps(State2))) @@ -116,11 +116,11 @@ no_beam_case(Config) -> State0 = proplists:get_value(state, Config), %% Deliberately disable release discovery when running `rlx_prv_discover` State1 = rlx_state:put(State0, disable_rel_discovery, true), - {ok, State2} = rlx_provider:new(rlx_prv_discover, State1), - DiscoverProvider = rlx_provider:get_provider(discover, rlx_state:providers(State2)), + {ok, State2} = providers:new(rlx_prv_discover, State1), + DiscoverProvider = providers:get_provider(discover, rlx_state:providers(State2)), ?assertMatch({ok, _}, - rlx_provider:do(DiscoverProvider, State2)). + providers:do(DiscoverProvider, State2)). bad_ebin_case(Config) -> LibDir1 = proplists:get_value(lib1, Config), @@ -146,9 +146,9 @@ bad_ebin_case(Config) -> ok = filelib:ensure_dir(Filename), ok = ec_file:write_term(Filename, get_bad_app_metadata(BadName, BadVsn)), State0 = proplists:get_value(state, Config), - {ok, State1} = rlx_provider:new(rlx_prv_discover, State0), - DiscoverProvider = rlx_provider:get_provider(discover, rlx_state:providers(State1)), - {ok, State2} = rlx_provider:do(DiscoverProvider, State1), + {ok, State1} = providers:new(rlx_prv_discover, State0), + DiscoverProvider = providers:get_provider(discover, rlx_state:providers(State1)), + {ok, State2} = providers:do(DiscoverProvider, State1), ?assertMatch([], [App || App <- rlx_state:available_apps(State2), BadName =:= rlx_app_info:name(App)]). @@ -172,9 +172,9 @@ shallow_app_discovery(Config) -> State0 = rlx_state:put(proplists:get_value(state, Config), default_libs, false), State1 = rlx_state:put(State0, enable_shallow_app_discovery, true), - {ok, State2} = rlx_provider:new(rlx_prv_discover, State1), - DiscoverProvider = rlx_provider:get_provider(discover, rlx_state:providers(State2)), - {ok, State3} = rlx_provider:do(DiscoverProvider, State2), + {ok, State2} = providers:new(rlx_prv_discover, State1), + DiscoverProvider = providers:get_provider(discover, rlx_state:providers(State2)), + {ok, State3} = providers:do(DiscoverProvider, State2), lists:foreach(fun(App) -> ?assertMatch(true, lists:member(App, rlx_state:available_apps(State3))) end, Apps1), |