diff options
author | Lukas Larsson <[email protected]> | 2010-12-09 11:48:15 +0100 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2010-12-09 11:51:36 +0100 |
commit | 7f25a132488707b167d1d5b3c59ba58b0600e848 (patch) | |
tree | 5da66b637ac732db3a0ce2f29123c2364a58c44e /lib/common_test/src/ct_run.erl | |
parent | 8ed5c47ca047405b2c00a979a8567412e5283322 (diff) | |
download | otp-7f25a132488707b167d1d5b3c59ba58b0600e848.tar.gz otp-7f25a132488707b167d1d5b3c59ba58b0600e848.tar.bz2 otp-7f25a132488707b167d1d5b3c59ba58b0600e848.zip |
Added tests for starting SCB's with arguments and fixed a bug with how SCB's are parsed from the command line
Diffstat (limited to 'lib/common_test/src/ct_run.erl')
-rw-r--r-- | lib/common_test/src/ct_run.erl | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/lib/common_test/src/ct_run.erl b/lib/common_test/src/ct_run.erl index 7d6a2f54d9..a12d4d6f18 100644 --- a/lib/common_test/src/ct_run.erl +++ b/lib/common_test/src/ct_run.erl @@ -172,9 +172,7 @@ script_start1(Parent, Args) -> ([]) -> true end, false, Args), EvHandlers = event_handler_args2opts(Args), - SuiteCBs = get_start_opt(suite_callbacks, - fun(CBs) -> [list_to_atom(CB) || CB <- CBs] end, - [], Args), + SuiteCBs = suite_callbacks_args2opts(Args), %% check flags and set corresponding application env variables @@ -2076,6 +2074,33 @@ get_start_opt(Key, IfExists, IfNotExists, Args) -> IfNotExists end. +suite_callbacks_args2opts(Args) -> + suite_callbacks_args2opts( + proplists:get_value(suite_callbacks, Args, []),[]). + +suite_callbacks_args2opts([SCB,Arg,"and"| Rest],Acc) -> + suite_callbacks_args2opts(Rest,[{list_to_atom(SCB), + parse_scb_args(Arg)}|Acc]); +suite_callbacks_args2opts([SCB], Acc) -> + suite_callbacks_args2opts([SCB,"and"],Acc); +suite_callbacks_args2opts([SCB, "and" | Rest], Acc) -> + suite_callbacks_args2opts(Rest,[list_to_atom(SCB)|Acc]); +suite_callbacks_args2opts([SCB, Args], Acc) -> + suite_callbacks_args2opts([SCB, Args, "and"],Acc); +suite_callbacks_args2opts([],Acc) -> + lists:reverse(Acc). + +parse_scb_args(String) -> + try + true = io_lib:printable_list(String), + {ok,Toks,_} = erl_scan:string(String++"."), + {ok, Args} = erl_parse:parse_term(Toks), + Args + catch _:_ -> + String + end. + + event_handler_args2opts(Args) -> case proplists:get_value(event_handler, Args) of undefined -> @@ -2205,6 +2230,20 @@ opts2args(EnvStartOpts) -> [{event_handler_init,lists:reverse(StrsR)}]; ({suite_callbacks,[]}) -> []; + ({suite_callbacks,SCBs}) when is_list(SCBs) -> + io:format(user,"suite_callbacks: ~p",[SCBs]), + Strs = lists:flatmap( + fun({SCB,Arg}) -> + [atom_to_list(SCB), + lists:flatten( + io_lib:format("~p",[Arg])), + "and"]; + (SCB) when is_atom(SCB) -> + [atom_to_list(SCB),"and"] + end,SCBs), + [_LastAnd|StrsR] = lists:reverse(Strs), + io:format(user,"return: ~p",[lists:reverse(StrsR)]), + [{suite_callbacks,lists:reverse(StrsR)}]; ({Opt,As=[A|_]}) when is_atom(A) -> [{Opt,[atom_to_list(Atom) || Atom <- As]}]; ({Opt,Strs=[S|_]}) when is_list(S) -> |