diff --git a/redo/builder.py b/redo/builder.py index f7a9ac9..237c8db 100644 --- a/redo/builder.py +++ b/redo/builder.py @@ -183,6 +183,8 @@ class _BuildJob(object): return self._finalize(0) else: err('no rule to redo %r\n' % t) + sf.set_failed() + sf.save() return self._finalize(1) # There is no good place for us to pre-create a temp file for # stdout. The target dir might not exist yet, or it might currently diff --git a/redo/paths.py b/redo/paths.py index a966af2..17c852d 100644 --- a/redo/paths.py +++ b/redo/paths.py @@ -32,7 +32,7 @@ def possible_do_files(t): # since t is an absolute path, dirbits[0] is always '', so we don't # need to count all the way down to i=0. for i in range(len(dirbits), 0, -1): - basedir = '/'.join(dirbits[:i]) + basedir = '/'.join(dirbits[:i]) or '/' subdir = '/'.join(dirbits[i:]) for dofile, basename, ext in _default_do_files(filename): yield (basedir, dofile, diff --git a/t/122-defaults-parent/all.do b/t/122-defaults-parent/all.do index 838ea31..917d634 100644 --- a/t/122-defaults-parent/all.do +++ b/t/122-defaults-parent/all.do @@ -1,7 +1,6 @@ rm -f x/shouldfail log=$PWD/$1.log -rm -f "$log" expect_fail() { local rv=$1 @@ -15,8 +14,19 @@ expect_fail() { fi } +# These should all fail because there is no matching .do file. +# In previous versions of redo, it would accidentally try to use +# $PWD/default.do even for ../path/file, which is incorrect. That +# could cause it to return success accidentally. + +rm -f "$log" cd inner -expect_fail 11 redo ../x/shouldfail # should fail -expect_fail 12 redo-ifchange ../x/shouldfail # should fail again +expect_fail 11 redo ../x/shouldfail +expect_fail 12 redo-ifchange ../x/shouldfail + +rm -f "$log" +cd ../inner2 +expect_fail 21 redo ../x/shouldfail2 +expect_fail 22 redo-ifchange ../x/shouldfail2 exit 0 diff --git a/t/122-defaults-parent/inner2/default.do b/t/122-defaults-parent/inner2/default.do new file mode 100644 index 0000000..ee989e6 --- /dev/null +++ b/t/122-defaults-parent/inner2/default.do @@ -0,0 +1,2 @@ +echo "inner/default.do: PWD=$PWD '$1' '$2' '$3'" >&2 +# output file is left empty