minimal/do: redo vs redo-ifchange, and fix empty target handling.
We previously assumed that redo and redo-ifchange are the same in minimal/do's design, because it rebuilds all targets on every run, and so there's no reason to ever build the same target more than once. Unfortunately that's incorrect: if you run 'redo x' from two points in a single run (or even twice in the same .do file), we expect x to be built twice. If you wanted redo to decide whether to build it the second time, you should have used redo-ifchange. t/102-empty/touchtest was trying to test for this. However, a second bug in minimal/do made the test pass anyway. minimal/do would *always* rebuild any target x that produced no output, not caring whether it had tried to build before, whether you used redo or redo-ifchange. And while we tested that redo would redo a file that had been deleted, we didn't ensure that it would redo a file that was *not* deleted, nor that redo-ifchange would *not* redo that file. Fix both bugs in minimal/do, and make t/102-empty/touchtest cover the missing cases.
This commit is contained in:
parent
887df98ead
commit
f345eae290
3 changed files with 32 additions and 3 deletions
|
|
@ -33,6 +33,7 @@ dirname()
|
|||
|
||||
_dirsplit "$0"
|
||||
export REDO=$(cd "${dir:-.}" && echo "$PWD/$base")
|
||||
if [ "$base" = "redo-ifchange" ]; then ifchange=1; else ifchange=; fi
|
||||
|
||||
DO_TOP=
|
||||
if [ -z "$DO_BUILT" ]; then
|
||||
|
|
@ -107,7 +108,7 @@ _run_dofile()
|
|||
_do()
|
||||
{
|
||||
local dir="$1" target="$2" tmp="$3"
|
||||
if [ ! -e "$target" ] || [ -d "$target" -a ! -e "$target.did" ]; then
|
||||
if [ -z "$ifchange" ] || ( [ ! -e "$target" -o -d "$target" ] && [ ! -e "$target.did" ] ); then
|
||||
printf '%sdo %s%s%s%s\n' \
|
||||
"$green" "$DO_DEPTH" "$bold" "$dir$target" "$plain" >&2
|
||||
echo "$PWD/$target" >>"$DO_BUILT"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue