Merge branch 'redo-log'

* redo-log:
  redo-log: add man page.
  redo-log: add automated tests, and fix some path bugs revealed by them.
  redo-log: fix stdout vs stderr; don't recapture if .do script redirects stderr.
  redo-log: don't show status line until >1.0 seconds after starting.
  Add --color and --no-color options.
  redo-log: --debug-pids works properly again.
  Split --raw-logs into --no-pretty and --no-log options.
  redo-log: prioritize the "foreground" process.
  redo-log: correctly indent first level of recursion.
  Raw logs contain @@REDO lines instead of formatted data.
  redo-log: status line should use actual terminal width.
  redo-log: capture and linearize the output of redo builds.
  Use signal.setitimer instead of signal.alarm.
This commit is contained in:
Avery Pennarun 2018-11-19 19:33:04 -05:00
commit 4842996b5b
32 changed files with 1114 additions and 182 deletions

3
t/370-logs/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
pid
x
y

5
t/370-logs/a/b/xlog.do Normal file
View file

@ -0,0 +1,5 @@
read pid <../../pid
# Test that log retrieval works correctly when run from a different base dir.
redo-log -ru ../../x | grep -q "^$pid x stderr" || exit 45
redo-log -ru ../../x | grep -q "^$pid y stderr" || exit 46

52
t/370-logs/all.do Normal file
View file

@ -0,0 +1,52 @@
exec >&2
rm -f x pid
pid=$$
echo "$pid" >pid
xout=$(redo x)
[ "$(printf "$xout" | wc -l)" -eq 0 ] || exit 2
if [ -n "$REDO_LOG" ]; then
# redo has redo-log support enabled, so check that it saves logs.
# recursive log dump should show both x and y stderr.
redo-log -ru x | grep -q "^$pid x stderr" || exit 10
redo-log -ru x | grep -q "^$pid y stderr" || exit 11
# stdout captured by redo into the files x and y, *not* to log
redo-log -ru x | grep -q "^$pid x stdout" && exit 20
redo-log -ru x | grep -q "^$pid y stdout" && exit 21
[ "$(cat x)" = "$pid x stdout" ] || exit 22
[ "$(cat y)" = "$pid y stdout" ] || exit 23
# non-recursive log dump of x should *not* include y
redo-log x | grep -q "^$pid y stdout" && exit 30
redo-log x | grep -q "^$pid y stderr" && exit 31
redo a/b/xlog
(cd a && redo b/xlog)
# Test retrieval from a different $PWD.
(
cd a/b || exit 40
redo-log -ru ../../x | grep -q "^$pid x stderr" || exit 41
redo-log -ru ../../x | grep -q "^$pid y stderr" || exit 42
) || exit
fi
# whether or not redo-log is available, redirecting stderr should work.
pid=$$-bork
rm -f x pid
echo "$pid" >pid
out=$(redo x 2>&1)
# x's stderr should obviously go where we sent it
echo "$out" | grep -q "^$pid x stderr" || exit 50
# This one is actually tricky: with redo-log, x's call to 'redo y' would
# normally implicitly redirect y's stderr to a new log. redo needs to
# detect that we've already redirected it where we want, and not take it
# away.
echo "$out" | grep -q "^$pid y stderr" || exit 51
exit 0

1
t/370-logs/clean.do Normal file
View file

@ -0,0 +1 @@
rm -f *~ .*~ all x y pid

5
t/370-logs/x.do Normal file
View file

@ -0,0 +1,5 @@
read pid <pid
echo "$pid x stdout"
echo "$pid x stderr" >&2
rm -f y
redo y

3
t/370-logs/y.do Normal file
View file

@ -0,0 +1,3 @@
read pid <pid
echo "$pid y stdout"
echo "$pid y stderr" >&2