From ecd5e1342a99241e71d809b2172fc1a6f4dd41ba Mon Sep 17 00:00:00 2001 From: mopp Date: Sun, 30 Dec 2018 04:04:03 +0900 Subject: Refactor normalize --- src/rebar_prv_eunit.erl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') 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 -- cgit v1.1