diff options
author | Eric Wong <e@80x24.org> | 2017-04-27 00:50:02 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2017-04-27 00:50:02 +0000 |
commit | 55fbe513ff4f9a113af3a08852364e65096bd307 (patch) | |
tree | f61c11483d2c7c1906b5c2e26638829f9c725975 | |
parent | 5cd7c327fa74cfd923824612be40aed8a9e979ee (diff) | |
download | yahns-55fbe513ff4f9a113af3a08852364e65096bd307.tar.gz |
Setting TAIL=1 will automatically use the portable "tail -f". This can be helpful in diagnosing failures during development. GNU tail users may set TAIL="tail -F" (or "gtail -F") to use the "-F" ("--follow=name") option to track changes across SIGUSR1 log reopening testing.
-rw-r--r-- | test/server_helper.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/server_helper.rb b/test/server_helper.rb index cb11e79..9ef15c6 100644 --- a/test/server_helper.rb +++ b/test/server_helper.rb @@ -65,12 +65,29 @@ module ServerHelper @srv.close if defined?(@srv) && !@srv.closed? @ru.close! if defined?(@ru) && @ru check_err if defined?(@err) + Timeout.timeout(30) do + Process.kill(:TERM, @tail_pid) + Process.waitpid(@tail_pid) + end if @tail_pid end def server_helper_setup @srv = TCPServer.new(ENV["TEST_HOST"] || "127.0.0.1", 0) @err = tmpfile(%w(srv .err)) @ru = nil + @tail_pid = nil + case tail = ENV['TAIL'] + when '1' + tail = 'tail -f' # POSIX + when nil, '0' + tail = nil + # else : allow users to specify 'tail -F' or 'gtail -F' for GNU + end + if tail + cmd = tail.split(/\s+/) + cmd << @err.path + @tail_pid = spawn(*cmd) + end end def mkserver(cfg, srv = @srv) |