redo-whichdo: fix a bug where the last dir was checked twice, and add tests.
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.
This commit is contained in:
parent
f835becde4
commit
e40dc5bad2
10 changed files with 133 additions and 50 deletions
|
|
@ -2,9 +2,9 @@
|
|||
import sys, os
|
||||
|
||||
import vars_init
|
||||
vars_init.init([])
|
||||
vars_init.init_no_state()
|
||||
|
||||
import builder
|
||||
import paths
|
||||
from log import err
|
||||
|
||||
if len(sys.argv[1:]) != 1:
|
||||
|
|
@ -13,7 +13,7 @@ if len(sys.argv[1:]) != 1:
|
|||
|
||||
want = sys.argv[1]
|
||||
abswant = os.path.abspath(want)
|
||||
for dodir,dofile,basedir,basename,ext in builder.possible_do_files(abswant):
|
||||
for dodir,dofile,basedir,basename,ext in paths.possible_do_files(abswant):
|
||||
dopath = os.path.join('/', dodir, dofile)
|
||||
relpath = os.path.relpath(dopath, '.')
|
||||
exists = os.path.exists(dopath)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue