diff options
author | Peter Andersson <[email protected]> | 2013-04-19 14:57:06 +0200 |
---|---|---|
committer | Peter Andersson <[email protected]> | 2013-04-19 14:57:06 +0200 |
commit | 59584feb6fdd8c94b2ea699402812d7edb61b630 (patch) | |
tree | 2ffe06ac0296f2582e621935825f75503643b470 /lib/test_server/src/test_server_io.erl | |
parent | abf2f3c8042becaec9ff2eceb95ac54d95216b54 (diff) | |
download | otp-59584feb6fdd8c94b2ea699402812d7edb61b630.tar.gz otp-59584feb6fdd8c94b2ea699402812d7edb61b630.tar.bz2 otp-59584feb6fdd8c94b2ea699402812d7edb61b630.zip |
Make test_server close log files properly and include correct footer
OTP-11046
Diffstat (limited to 'lib/test_server/src/test_server_io.erl')
-rw-r--r-- | lib/test_server/src/test_server_io.erl | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/test_server/src/test_server_io.erl b/lib/test_server/src/test_server_io.erl index a979deffc3..73d4468bda 100644 --- a/lib/test_server/src/test_server_io.erl +++ b/lib/test_server/src/test_server_io.erl @@ -29,7 +29,7 @@ %% -module(test_server_io). --export([start_link/0,stop/0,get_gl/1,set_fd/2, +-export([start_link/0,stop/1,get_gl/1,set_fd/2, start_transaction/0,end_transaction/0, print_buffered/1,print/3,print_unexpected/1, set_footer/1,set_job_name/1,set_gl_props/1]). @@ -55,10 +55,10 @@ start_link() -> Other end. -stop() -> +stop(FilesToClose) -> OldGL = group_leader(), group_leader(self(), self()), - req(stop), + req({stop,FilesToClose}), group_leader(OldGL, self()), ok. @@ -213,12 +213,21 @@ handle_call({set_job_name,Name}, _From, St) -> handle_call({set_gl_props,Props}, _From, #st{shared_gl=Shared}=St) -> test_server_gl:set_props(Shared, Props), {reply,ok,St#st{gl_props=Props}}; -handle_call(stop, From, #st{shared_gl=SGL,gls=Gls0}=St0) -> +handle_call({stop,FdTags}, From, #st{fds=Fds,shared_gl=SGL,gls=Gls0}=St0) -> St = St0#st{gls=gb_sets:insert(SGL, Gls0),stopping=From}, gc(St), %% Give the users of the surviving group leaders some %% time to finish. erlang:send_after(2000, self(), stop_group_leaders), + %% close open log files + lists:foreach(fun(Tag) -> + case gb_trees:lookup(Tag, Fds) of + none -> + ok; + {value,Fd} -> + file:close(Fd) + end + end, FdTags), {noreply,St}. handle_info({'EXIT',Pid,normal}, #st{gls=Gls0,stopping=From}=St) -> |