* [PATCH 1/2] test_helper: support TAIL= env for watching tests
2020-07-26 1:57 5% [PATCH 0/2] minor test improvements Eric Wong
@ 2020-07-26 1:57 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-07-26 1:57 UTC (permalink / raw)
To: unicorn-public
This can be useful for diagnosing failures, especially since
GNU tail supports inotify these days.
---
test/test_helper.rb | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 94a5b1b6..e3c6ad4e 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -37,13 +37,25 @@
def redirect_test_io
orig_err = STDERR.dup
orig_out = STDOUT.dup
- STDERR.reopen("test_stderr.#{$$}.log", "a")
- STDOUT.reopen("test_stdout.#{$$}.log", "a")
+ new_out = File.open("test_stdout.#$$.log", "a")
+ new_err = File.open("test_stderr.#$$.log", "a")
+ new_out.sync = new_err.sync = true
+
+ if tail = ENV['TAIL'] # "tail -F" if GNU, "tail -f" otherwise
+ require 'shellwords'
+ cmd = tail.shellsplit
+ cmd << new_out.path
+ cmd << new_err.path
+ pid = Process.spawn(*cmd, { 1 => 2, :pgroup => true })
+ sleep 0.1 # wait for tail(1) to startup
+ end
+ STDERR.reopen(new_err)
+ STDOUT.reopen(new_out)
STDERR.sync = STDOUT.sync = true
at_exit do
- File.unlink("test_stderr.#{$$}.log") rescue nil
- File.unlink("test_stdout.#{$$}.log") rescue nil
+ File.unlink(new_out.path) rescue nil
+ File.unlink(new_err.path) rescue nil
end
begin
@@ -51,6 +63,7 @@ def redirect_test_io
ensure
STDERR.reopen(orig_err)
STDOUT.reopen(orig_out)
+ Process.kill(:TERM, pid) if pid
end
end
^ permalink raw reply related [relevance 7%]
* [PATCH 0/2] minor test improvements
@ 2020-07-26 1:57 5% Eric Wong
2020-07-26 1:57 7% ` [PATCH 1/2] test_helper: support TAIL= env for watching tests Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-07-26 1:57 UTC (permalink / raw)
To: unicorn-public
Lightly tested, but seems much better than before w.r.t.
unnecessary rebuilds.
Eric Wong (2):
test_helper: support TAIL= env for watching tests
build: revamp and avoid unnecessary rebuilds
GNUmakefile | 160 ++++++++++++++++++++++++++++----------------
t/GNUmakefile | 75 +--------------------
test/test_helper.rb | 21 ++++--
3 files changed, 122 insertions(+), 134 deletions(-)
^ permalink raw reply [relevance 5%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-07-26 1:57 5% [PATCH 0/2] minor test improvements Eric Wong
2020-07-26 1:57 7% ` [PATCH 1/2] test_helper: support TAIL= env for watching tests Eric Wong
Code repositories for project(s) associated with this public inbox
https://yhbt.net/unicorn.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).