When we can't find a .do file, we walk all the way back to the root directory. When that happens, the root directory is actually searched twice. This is harmless (since a .do file doesn't exist there anyway) but causes redo-whichdo to produce the wrong output. Also, add a test, which I forgot to do when writing whichdo in the first place. To make the test work from the root directory, we need a way to initialize redo without actually creating a .redo directory. Add a init_no_state() function for that purpose, and split the necessary path functions into their own module so we can avoid importing builder.py.
25 lines
676 B
Text
25 lines
676 B
Text
exec >&2
|
|
|
|
a=$(cd fakesub && redo-whichdo ../a/b/x.y.z)
|
|
# if sh doesn't abort after the above, then it found a .do file as expected
|
|
|
|
# Note: we expect redo-whichdo to return paths relative to $PWD at the time
|
|
# it's run, which in this case is fakesub.
|
|
# Likely bugs would be to return paths relative to the start dir, the .redo
|
|
# dir, the current target dir, the requested target dir, etc.
|
|
b=$(cat <<EOF
|
|
../a/b/x.y.z.do
|
|
../a/b/default.y.z.do
|
|
../a/b/default.z.do
|
|
../a/b/default.do
|
|
../a/default.y.z.do
|
|
../a/default.z.do
|
|
../a/default.do
|
|
../default.y.z.do
|
|
EOF
|
|
)
|
|
|
|
if [ "$a" != "$b" ]; then
|
|
printf 'redo-whichdo mismatch.\n\ngot:\n%s\n\nexpected:\n%s\n' "$a" "$b"
|
|
exit 11
|
|
fi
|