aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common_test/src')
-rw-r--r--lib/common_test/src/ct.erl6
-rw-r--r--lib/common_test/src/ct_logs.erl2
-rw-r--r--lib/common_test/src/ct_run.erl83
-rw-r--r--lib/common_test/src/ct_util.erl3
-rw-r--r--lib/common_test/src/vts.erl6
5 files changed, 67 insertions, 33 deletions
diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl
index 77bcf34981..eb16a04c7b 100644
--- a/lib/common_test/src/ct.erl
+++ b/lib/common_test/src/ct.erl
@@ -142,8 +142,9 @@ run(TestDirs) ->
%%% {userconfig, UserConfig} |
%%% {testcase,Cases} | {group,Groups} | {spec,TestSpecs} |
%%% {allow_user_terms,Bool} | {logdir,LogDir} |
-%%% {silent_connections,Conns} | {cover,CoverSpecFile} |
-%%% {step,StepOpts} | {event_handler,EventHandlers} | {include,InclDirs} |
+%%% {silent_connections,Conns} | {stylesheet,CSSFile} |
+%%% {cover,CoverSpecFile} | {step,StepOpts} |
+%%% {event_handler,EventHandlers} | {include,InclDirs} |
%%% {auto_compile,Bool} | {multiply_timetraps,M} | {scale_timetraps,Bool} |
%%% {repeat,N} | {duration,DurTime} | {until,StopTime} |
%%% {force_stop,Bool} | {decrypt,DecryptKeyOrFile} |
@@ -159,6 +160,7 @@ run(TestDirs) ->
%%% TestSpecs = [string()] | string()
%%% LogDir = string()
%%% Conns = all | [atom()]
+%%% CSSFile = string()
%%% CoverSpecFile = string()
%%% StepOpts = [StepOpt] | []
%%% StepOpt = config | keep_inactive
diff --git a/lib/common_test/src/ct_logs.erl b/lib/common_test/src/ct_logs.erl
index bd6fdfcd4f..8a4432ef08 100644
--- a/lib/common_test/src/ct_logs.erl
+++ b/lib/common_test/src/ct_logs.erl
@@ -505,7 +505,7 @@ logger_loop(State) ->
logger_loop(State);
{set_stylesheet,TC,SSFile} ->
Fd = State#logger_state.ct_log_fd,
- io:format(Fd, "~p uses external style sheet: ~s~n", [TC,SSFile]),
+ io:format(Fd, "~p loading external style sheet: ~s~n", [TC,SSFile]),
logger_loop(State#logger_state{stylesheet=SSFile});
{clear_stylesheet,_} when State#logger_state.stylesheet == undefined ->
logger_loop(State);
diff --git a/lib/common_test/src/ct_run.erl b/lib/common_test/src/ct_run.erl
index 3d9b579a0c..4b9c9b6981 100644
--- a/lib/common_test/src/ct_run.erl
+++ b/lib/common_test/src/ct_run.erl
@@ -55,6 +55,7 @@
event_handlers = [],
include = [],
silent_connections,
+ stylesheet,
multiply_timetraps = 1,
scale_timetraps = false,
testspecs = [],
@@ -170,7 +171,7 @@ script_start1(Parent, Args) ->
case proplists:get_value(ct_decrypt_file, Args) of
[DecryptFile] ->
application:set_env(common_test, decrypt,
- {file,filename:absname(DecryptFile)});
+ {file,?abs(DecryptFile)});
undefined ->
application:unset_env(common_test, decrypt)
end
@@ -182,9 +183,9 @@ script_start1(Parent, Args) ->
application:set_env(common_test, auto_compile, true),
InclDirs =
case proplists:get_value(include, Args) of
- {include,Incl} when is_list(hd(Incl)) ->
+ Incl when is_list(hd(Incl)) ->
Incl;
- {include,Incl} when is_list(Incl) ->
+ Incl when is_list(Incl) ->
[Incl];
undefined ->
[]
@@ -203,6 +204,15 @@ script_start1(Parent, Args) ->
application:set_env(common_test, auto_compile, false),
[]
end,
+ %% silent connections
+ SilentConns =
+ get_start_opt(silent_connections,
+ fun(["all"]) -> [];
+ (Conns) -> [list_to_atom(Conn) || Conn <- Conns]
+ end, Args),
+ %% stylesheet
+ Stylesheet = get_start_opt(stylesheet,
+ fun([SS]) -> ?abs(SS) end, Args),
%% basic_html - used by ct_logs
case proplists:get_value(basic_html, Args) of
undefined ->
@@ -214,6 +224,8 @@ script_start1(Parent, Args) ->
StartOpts = #opts{vts = Vts, shell = Shell, cover = Cover,
logdir = LogDir, event_handlers = EvHandlers,
include = IncludeDirs,
+ silent_connections = SilentConns,
+ stylesheet = Stylesheet,
multiply_timetraps = MultTT,
scale_timetraps = ScaleTT},
@@ -326,7 +338,16 @@ script_start2(StartOpts = #opts{vts = undefined,
end;
script_start2(StartOpts, Args) ->
- script_start3(StartOpts, Args).
+ %% read config/userconfig from start flags
+ InitConfig = ct_config:prepare_config_list(Args),
+ case check_and_install_configfiles(InitConfig,
+ which(logdir,StartOpts#opts.logdir),
+ StartOpts#opts.event_handlers) of
+ ok -> % go on read tests from start flags
+ script_start3(StartOpts#opts{config=InitConfig}, Args);
+ Error ->
+ Error
+ end.
check_and_install_configfiles(Configs, LogDir, EvHandlers) ->
case ct_config:check_config_files(Configs) of
@@ -386,7 +407,17 @@ script_start3(StartOpts, Args) ->
script_start4(#opts{vts = true, config = Config, event_handlers = EvHandlers,
tests = Tests, logdir = LogDir}, _Args) ->
- vts:init_data(Config, EvHandlers, ?abs(LogDir), Tests);
+ ConfigFiles =
+ lists:foldl(fun({ct_config_plain,CfgFiles}, AllFiles) when
+ is_list(hd(CfgFiles)) ->
+ AllFiles ++ CfgFiles;
+ ({ct_config_plain,CfgFile}, AllFiles) when
+ is_integer(hd(CfgFile)) ->
+ AllFiles ++ [CfgFile];
+ (_, AllFiles) ->
+ AllFiles
+ end, [], Config),
+ vts:init_data(ConfigFiles, EvHandlers, ?abs(LogDir), Tests);
script_start4(#opts{shell = true, config = Config, event_handlers = EvHandlers,
logdir = LogDir, testspecs = Specs}, _Args) ->
@@ -396,6 +427,12 @@ script_start4(#opts{shell = true, config = Config, event_handlers = EvHandlers,
true ->
io:format("\nInstalling: ~p\n\n", [Config])
end,
+
+ %%! --- Sun Jun 6 00:58:41 2010 --- peppe was here!
+ %%! HERE!!
+ %%! Something's not right here. Can't start shell mode
+ %%! properly!
+
case install(InstallOpts) of
ok ->
ct_util:start(interactive, LogDir),
@@ -610,8 +647,13 @@ run_test1(StartOpts) ->
fun(all) -> [];
(Conns) -> Conns
end, StartOpts),
+ %% stylesheet
+ Stylesheet = get_start_opt(stylesheet,
+ fun(SS) -> ?abs(SS) end,
+ StartOpts),
%% code coverage
- Cover = get_start_opt(cover, fun(CoverFile) -> ?abs(CoverFile) end, StartOpts),
+ Cover = get_start_opt(cover,
+ fun(CoverFile) -> ?abs(CoverFile) end, StartOpts),
%% timetrap manipulation
MultiplyTT = get_start_opt(multiply_timetraps, value, 1, StartOpts),
@@ -653,7 +695,7 @@ run_test1(StartOpts) ->
Key={key,_} ->
application:set_env(common_test, decrypt, Key);
{file,KeyFile} ->
- application:set_env(common_test, decrypt, {file,filename:absname(KeyFile)})
+ application:set_env(common_test, decrypt, {file,?abs(KeyFile)})
end,
%% basic html - used by ct_logs
@@ -669,7 +711,9 @@ run_test1(StartOpts) ->
Opts = #opts{cover = Cover, step = Step, logdir = LogDir, config = CfgFiles,
event_handlers = EvHandlers, include = Include,
- silent_connections = SilentConns, multiply_timetraps = MultiplyTT,
+ silent_connections = SilentConns,
+ stylesheet = Stylesheet,
+ multiply_timetraps = MultiplyTT,
scale_timetraps = ScaleTT},
%% test specification
@@ -1079,25 +1123,14 @@ do_run(Tests, Skip, Opts, Args) ->
"run ct:start_interactive()\n\n",[]),
{error,interactive_mode};
_Pid ->
- %% save style sheet info
- case lists:keysearch(stylesheet, 1, Args) of
- {value,{_,SSFile}} ->
- ct_util:set_testdata({stylesheet,SSFile});
- _ ->
- ct_util:set_testdata({stylesheet,undefined})
- end,
-
- case lists:keysearch(silent_connections, 1, Args) of
- {value,{silent_connections,undefined}} ->
- ok;
- {value,{silent_connections,[]}} ->
+ %% save stylesheet info
+ ct_util:set_testdata({stylesheet,Opts#opts.stylesheet}),
+ %% enable silent connections
+ case Opts#opts.silent_connections of
+ [] ->
Conns = ct_util:override_silence_all_connections(),
ct_logs:log("Silent connections", "~p", [Conns]);
- {value,{silent_connections,Cs}} ->
- Conns = lists:map(fun(S) when is_list(S) ->
- list_to_atom(S);
- (A) -> A
- end, Cs),
+ Conns when is_list(Conns) ->
ct_util:override_silence_connections(Conns),
ct_logs:log("Silent connections", "~p", [Conns]);
_ ->
diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl
index f1692caf24..40925b761a 100644
--- a/lib/common_test/src/ct_util.erl
+++ b/lib/common_test/src/ct_util.erl
@@ -125,7 +125,6 @@ do_start(Parent,Mode,LogDir) ->
Parent ! {self(),Error},
exit(Error)
end,
-
%% start an event manager (if not already started by master)
case ct_event:start_link() of
{error,{already_started,_}} ->
@@ -305,9 +304,9 @@ loop(Mode,TestData,StartDir) ->
ets:delete(?board_table),
ets:delete(?suite_table),
ct_logs:close(How),
- file:set_cwd(StartDir),
ct_event:stop(),
ct_config:stop(),
+ file:set_cwd(StartDir),
return(From,ok);
{get_mode,From} ->
return(From,Mode),
diff --git a/lib/common_test/src/vts.erl b/lib/common_test/src/vts.erl
index 22399aff2a..eb6d82d601 100644
--- a/lib/common_test/src/vts.erl
+++ b/lib/common_test/src/vts.erl
@@ -160,9 +160,9 @@ init(Parent) ->
loop(State) ->
receive
- {{init_data,ConfigFiles,EvHandlers,LogDir,Tests},From} ->
- ct:pal("State#state.current_log_dir=~p", [State#state.current_log_dir]),
- NewState = State#state{config=ConfigFiles,event_handler=EvHandlers,
+ {{init_data,Config,EvHandlers,LogDir,Tests},From} ->
+ %% ct:pal("State#state.current_log_dir=~p", [State#state.current_log_dir]),
+ NewState = State#state{config=Config,event_handler=EvHandlers,
current_log_dir=LogDir,tests=Tests},
ct_install(NewState),
return(From,ok),