diff options
author | Lukas Larsson <[email protected]> | 2011-02-17 17:12:58 +0100 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2011-02-17 17:12:58 +0100 |
commit | 62e3328272e3bac139e765e6a5147daca02ec833 (patch) | |
tree | 6598446fa99d235a3a726a6c08c62d19942b41cd /lib/test_server/src/ts_run.erl | |
parent | 53974a3517268389ae18fabee509ebf4bbfce747 (diff) | |
parent | 00db7dddae0c6f1acddf52d97c9e6c65393d2459 (diff) | |
download | otp-62e3328272e3bac139e765e6a5147daca02ec833.tar.gz otp-62e3328272e3bac139e765e6a5147daca02ec833.tar.bz2 otp-62e3328272e3bac139e765e6a5147daca02ec833.zip |
Merge branch 'lukas/common_test/updates_needed_before_migration/OTP-8768' into dev
* lukas/common_test/updates_needed_before_migration/OTP-8768:
Update ts to take the config path as an invironmental and as a variables passed with all_tests and also with the normal run
Update TEST_SERVER_FRAMEWORK os variable to be regarded as undet if set to undefined
Fix bug with subgroups after introduction of remote groups
Rename Suite Callback to Common Test Hook
Update so that cover is skipper for applications without a .cover file
Update minimal build target to include runtime_tools and common_test
Update ts to start common test with both ts.config and ts.PLATFORM.config
Update ts scb to add nodenames in all pre_init clauses
Add release/tests/test_server to path
Add ts_install_scb which is a common_test SCB that handles making of test modules.
Update ts to work with common test instead of test_server
Add kill_slavenodes/0 as an exported function
Change format of remote groups to {group, Module, GroupName}, note that this is an unsupported feature
Add possibility to get all testdata
Fix bug when groups refer to groups in the groups/0 function
Add support for external groups.
Refactor code to make it easier to debug
Update so that when asking for os and we are in the test_server_ctrl process, just use os:type().
Fix so that groups can return external test cases, i.e.
Diffstat (limited to 'lib/test_server/src/ts_run.erl')
-rw-r--r-- | lib/test_server/src/ts_run.erl | 93 |
1 files changed, 68 insertions, 25 deletions
diff --git a/lib/test_server/src/ts_run.erl b/lib/test_server/src/ts_run.erl index 888ac98973..60e01600e1 100644 --- a/lib/test_server/src/ts_run.erl +++ b/lib/test_server/src/ts_run.erl @@ -63,32 +63,13 @@ run(File, Args0, Options, Vars0) -> _ -> {false, fun run_interactive/3} end, - HandleTopcase = case member(keep_topcase, Options) of - true -> [fun copy_topcase/3]; - false -> [fun remove_original_topcase/3, - fun init_topcase/3] - end, - MakefileHooks = [fun make_make/3, - fun add_make_testcase/3], - MakeLoop = fun(V, Sp, St) -> make_loop(MakefileHooks, V, Sp, St) end, Hooks = [fun init_state/3, - fun read_spec_file/3] ++ - HandleTopcase ++ - [fun run_preinits/3, - fun find_makefiles/3, - MakeLoop, - fun make_test_suite/3, - fun add_topcase_to_spec/3, - fun write_spec_file/3, + fun run_preinits/3, fun make_command/3, Runner], - Args = make_test_server_args(Args0,Options,Vars), + Args = make_common_test_args(Args0,Options,Vars), St = #state{file=File,test_server_args=Args,batch=Batch}, R = execute(Hooks, Vars, [], St), - case Batch of - true -> ts_reports:make_index(); - false -> ok % ts_reports:make_index() is run on the test_server node - end, case R of {ok,_,_,_} -> ok; Error -> Error @@ -430,6 +411,15 @@ write_spec_file(Vars, Spec, _State) -> MoreConfig = io_lib:format("~p.\n", [{config,Conf}]), file:write_file("current.spec", [DiskLess,Hosts,MoreConfig,SpecFile]). +get_config_files() -> + TSConfig = "ts.config", + [TSConfig | case os:type() of + {unix,_} -> ["ts.unix.config"]; + {win32,_} -> ["ts.win32.config"]; + vxworks -> ["ts.vxworks.config"]; + _ -> [] + end]. + consult_config() -> {ok,Conf} = file:consult("ts.config"), case os:type() of @@ -457,6 +447,7 @@ backslashify([]) -> []. make_command(Vars, Spec, State) -> + {ok,Cwd} = file:get_cwd(), TestDir = State#state.test_dir, TestPath = filename:nativename(TestDir), Erl = case os:getenv("TS_RUN_VALGRIND") of @@ -487,7 +478,7 @@ make_command(Vars, Spec, State) -> {value,{erl_start_args,Args}} -> Args; false -> "" end, - CrashFile = State#state.file ++ "_erl_crash.dump", + CrashFile = filename:join(Cwd,State#state.file ++ "_erl_crash.dump"), case filelib:is_file(CrashFile) of true -> io:format("ts_run: Deleting dump: ~s\n",[CrashFile]), @@ -495,7 +486,8 @@ make_command(Vars, Spec, State) -> false -> ok end, - Cmd = [Erl, Naming, "test_server -pa ", $", TestPath, $", + %% NOTE: Do not use ' in these commands as it wont work on windows + Cmd = [Erl, Naming, "test_server" " -rsh ", ts_lib:var(rsh_name, Vars), " -env PATH \"", backslashify(lists:flatten([TestPath, path_separator(), @@ -505,15 +497,20 @@ make_command(Vars, Spec, State) -> %% uncomment the line below to disable exception formatting %% " -test_server_format_exception false", " -boot start_sasl -sasl errlog_type error", - " -s test_server_ctrl run_test ", State#state.test_server_args, + " -pz ",Cwd, + " -eval \"file:set_cwd(\\\"",TestDir,"\\\")\" " + " -eval \"ct:run_test(", + backslashify(lists:flatten(State#state.test_server_args)),")\"" " ", ExtraArgs], {ok, Vars, Spec, State#state{command=lists:flatten(Cmd)}}. + run_batch(Vars, _Spec, State) -> process_flag(trap_exit, true), Command = State#state.command ++ " -noinput -s erlang halt", ts_lib:progress(Vars, 1, "Command: ~s~n", [Command]), + io:format(user, "Command: ~s~n",[Command]), Port = open_port({spawn, Command}, [stream, in, eof]), tricky_print_data(Port). @@ -554,7 +551,7 @@ is_testnode_dead([{"test_server",_}|_]) -> false; is_testnode_dead([_|T]) -> is_testnode_dead(T). run_interactive(Vars, _Spec, State) -> - Command = State#state.command ++ " -s ts_reports make_index", + Command = State#state.command, ts_lib:progress(Vars, 1, "Command: ~s~n", [Command]), case ts_lib:var(os, Vars) of "Windows 95" -> @@ -604,6 +601,52 @@ path_separator() -> end. +make_common_test_args(Args0, Options, _Vars) -> + Trace = + case lists:keysearch(trace,1,Options) of + {value,{trace,TI}} when is_tuple(TI); is_tuple(hd(TI)) -> + ok = file:write_file(?tracefile,io_lib:format("~p.~n",[TI])), + [{ct_trace,?tracefile}]; + {value,{trace,TIFile}} when is_atom(TIFile) -> + [{ct_trace,atom_to_list(TIFile)}]; + {value,{trace,TIFile}} -> + [{ct_trace,TIFile}]; + false -> + [] + end, + Cover = + case lists:keysearch(cover,1,Options) of + {value,{cover, App, none, _Analyse}} -> + io:format("No cover file found for ~p~n",[App]), + []; + {value,{cover,_App,File,_Analyse}} -> + [{cover,to_list(File)}]; + false -> + [] + end, + + Logdir = case lists:keysearch(logdir, 1, Options) of + {value,{logdir, _}} -> + []; + false -> + [{logdir,"../test_server"}] + end, + + ConfigPath = case {os:getenv("TEST_CONFIG_PATH"), + lists:keysearch(config, 1, Options)} of + {false,{value, {config, Path}}} -> + Path; + {false,false} -> + "../test_server"; + {Path,_} -> + Path + end, + ConfigFiles = [{config,[filename:join(ConfigPath,File) + || File <- get_config_files()]}], + + io_lib:format("~100000p",[Args0++Trace++Cover++Logdir++ + ConfigFiles++Options]). + make_test_server_args(Args0,Options,Vars) -> Parameters = case ts_lib:var(os, Vars) of |