redo-log: add automated tests, and fix some path bugs revealed by them.
When a log for X was saying it wanted to refer to Y, we used a relative path, but it was sometimes relative to the wrong starting location, so redo-log couldn't find it later. Two examples: - if default.o.do is handling builds for a/b/x.o, and default.o.do does 'redo a/b/x.h', the log for x.o should refer to ./x.h, not a/b/x.h. - if foo.do is handling builds for foo, and it does "cd a/b && redo x", the log for foo should refer to a/b/x, not just x.
This commit is contained in:
parent
7165b342f5
commit
4edb6f78e0
10 changed files with 125 additions and 20 deletions
3
t/370-logs/.gitignore
vendored
Normal file
3
t/370-logs/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
pid
|
||||
x
|
||||
y
|
||||
5
t/370-logs/a/b/xlog.do
Normal file
5
t/370-logs/a/b/xlog.do
Normal 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
52
t/370-logs/all.do
Normal 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
1
t/370-logs/clean.do
Normal file
|
|
@ -0,0 +1 @@
|
|||
rm -f *~ .*~ all x y pid
|
||||
5
t/370-logs/x.do
Normal file
5
t/370-logs/x.do
Normal 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
3
t/370-logs/y.do
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
read pid <pid
|
||||
echo "$pid y stdout"
|
||||
echo "$pid y stderr" >&2
|
||||
Loading…
Add table
Add a link
Reference in a new issue