diff options
author | mopp <hello@mopp.jp> | 2018-12-30 04:04:03 +0900 |
---|---|---|
committer | mopp <hello@mopp.jp> | 2018-12-30 04:04:03 +0900 |
commit | ecd5e1342a99241e71d809b2172fc1a6f4dd41ba (patch) | |
tree | c0f44192e94d46353e49253cd2fe8753881285b6 /src | |
parent | 44b250c174a2e5c0e0c671c958951a2c280a0524 (diff) |
Refactor normalize
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_prv_eunit.erl | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/rebar_prv_eunit.erl b/src/rebar_prv_eunit.erl index b2f307e..0b00e89 100644 --- a/src/rebar_prv_eunit.erl +++ b/src/rebar_prv_eunit.erl @@ -144,12 +144,16 @@ resolve(Flag, RawOpts) -> resolve(Flag, Flag, RawOpts). resolve(Flag, EUnitKey, RawOpts) -> case proplists:get_value(Flag, RawOpts) of undefined -> []; - Args -> - lists:flatten(lists:map(fun(Arg) -> normalize(EUnitKey, Arg) end, - rebar_string:lexemes(Args, [$,]))) + Args -> normalize(EUnitKey, + rebar_string:lexemes(Args, [$,])) end. -normalize(generator, Value) -> +normalize(generator, Args) -> + lists:flatmap(fun(Value) -> normalize_(generator, Value) end, Args); +normalize(EUnitKey, Args) -> + lists:map(fun(Arg) -> normalize_(EUnitKey, Arg) end, Args). + +normalize_(generator, Value) -> case string:tokens(Value, [$:]) of [Module0, Functions] -> Module = list_to_atom(Module0), @@ -158,8 +162,8 @@ normalize(generator, Value) -> _ -> ?PRV_ERROR({generator, Value}) end; -normalize(Key, Value) when Key == dir; Key == file -> {Key, Value}; -normalize(Key, Value) -> {Key, list_to_atom(Value)}. +normalize_(Key, Value) when Key == dir; Key == file -> {Key, Value}; +normalize_(Key, Value) -> {Key, list_to_atom(Value)}. cfg_tests(State) -> case rebar_state:get(State, eunit_tests, []) of |