If the created target is a directory, it's okay for the .do to create it.

Normally, creating the target $1 yourself is bad; create $3 instead.  But if
$1 is a directory, we'll allow it.  That way 'redo subdir' can call
subdir.do, and subdir.do can both create the directory *and* run a bunch of
sub-.do files on it.
This commit is contained in:
Avery Pennarun 2010-11-24 02:30:54 -08:00
commit 282bb0488e
4 changed files with 6 additions and 4 deletions

View file

@ -1,4 +1,4 @@
import sys, os, random, errno import sys, os, random, errno, stat
import vars, jwack, state import vars, jwack, state
from helpers import log, log_, debug2, err, unlink, close_on_exec from helpers import log, log_, debug2, err, unlink, close_on_exec
@ -122,7 +122,7 @@ class BuildJob:
before_tmp = os.fstat(f.fileno()) before_tmp = os.fstat(f.fileno())
after_tmp = _try_stat(tmpname) after_tmp = _try_stat(tmpname)
after_where = os.lseek(f.fileno(), 0, os.SEEK_CUR) after_where = os.lseek(f.fileno(), 0, os.SEEK_CUR)
if after_t != before_t: if after_t != before_t and not stat.S_ISDIR(after_t.st_mode):
err('%r modified %r directly!\n' % (self.argv[2], t)) err('%r modified %r directly!\n' % (self.argv[2], t))
err('...you should update $3 (a temp file) instead of $1.\n') err('...you should update $3 (a temp file) instead of $1.\n')
rv = 206 rv = 206

View file

@ -1,4 +1,4 @@
redo example/clean curse/clean deps/clean "space dir/clean" redo example/clean curse/clean deps/clean "space dir/clean"
rm -f c c.c c.c.c c.c.c.b c.c.c.b.b d mode1 rm -f c c.c c.c.c c.c.c.b c.c.c.b.b d mode1
rm -f hello [by]ellow *.o *~ .*~ CC LD passfail rm -f hello [by]ellow *.o *~ .*~ CC LD passfail
rm -rf makedir

2
t/makedir.do Normal file
View file

@ -0,0 +1,2 @@
[ -e "$1" ] && rmdir $1
mkdir $1

View file

@ -1,4 +1,4 @@
redo-ifchange all redo-ifchange all
./hello >&2 ./hello >&2
redo deltest deltest2 test.args test2.args passfailtest \ redo deltest deltest2 test.args test2.args passfailtest \
curse/test deps/test "space dir/test" modetest curse/test deps/test "space dir/test" modetest makedir