diff options
author | Fumitoshi Ukai <ukai@google.com> | 2015-08-11 17:50:56 +0900 |
---|---|---|
committer | Fumitoshi Ukai <ukai@google.com> | 2015-08-11 17:53:21 +0900 |
commit | 2c6eff6ea834bd2c81974edc9b07fef8c1abb06a (patch) | |
tree | 41934eb7882714b932a5e0ed11f1ed319e85ed89 | |
parent | 59956606c56b1ffc79eca2c85701bce1bca027d2 (diff) | |
download | android_build_kati-2c6eff6ea834bd2c81974edc9b07fef8c1abb06a.tar.gz android_build_kati-2c6eff6ea834bd2c81974edc9b07fef8c1abb06a.tar.bz2 android_build_kati-2c6eff6ea834bd2c81974edc9b07fef8c1abb06a.zip |
[go] fix find_command.mk - "cd xxx && find ."
-rw-r--r-- | pathutil.go | 20 | ||||
-rw-r--r-- | pathutil_test.go | 4 | ||||
-rwxr-xr-x | runtest.rb | 1 |
3 files changed, 19 insertions, 6 deletions
diff --git a/pathutil.go b/pathutil.go index 68d06c4..0d3aa05 100644 --- a/pathutil.go +++ b/pathutil.go @@ -470,16 +470,24 @@ func parseFindCommand(cmd string) (findCommand, error) { } } glog.V(3).Infof("find command: %#v", fcp.fc) + + // TODO(ukai): handle this in run() instead of fallback shell. + _, ents := fsCache.readdir(filepathClean(fcp.fc.testdir), unknownFileid) + if ents == nil { + glog.V(1).Infof("find: testdir %s - not dir", fcp.fc.testdir) + return fcp.fc, errFindNoSuchDir + } + _, ents = fsCache.readdir(filepathClean(fcp.fc.chdir), unknownFileid) + if ents == nil { + glog.V(1).Infof("find: cd %s: No such file or directory", fcp.fc.chdir) + return fcp.fc, errFindNoSuchDir + } + return fcp.fc, nil } func (fc findCommand) run(w evalWriter) { glog.V(3).Infof("find: %#v", fc) - _, ents := fsCache.readdir(filepathClean(fc.testdir), unknownFileid) - if ents == nil { - glog.V(1).Infof("find: testdir %s - not dir", fc.testdir) - return - } for _, dir := range fc.finddirs { seen := make(map[fileid]string) id, _ := fsCache.readdir(filepathClean(filepathJoin(fc.chdir, dir)), unknownFileid) @@ -520,7 +528,7 @@ var ( errFindExtra = errors.New("find command: extra") errFindUnexpectedEnd = errors.New("find command: unexpected end") errFindAbspath = errors.New("find command: abs path") - errFindChdirAndTestdir = errors.New("find command: chdir, testdir") + errFindNoSuchDir = errors.New("find command: no such dir") ) type findCommandParser struct { diff --git a/pathutil_test.go b/pathutil_test.go index d64bb65..33b7e32 100644 --- a/pathutil_test.go +++ b/pathutil_test.go @@ -142,6 +142,10 @@ func TestFilepathClean(t *testing.T) { } func TestParseFindCommand(t *testing.T) { + fs := newFS() + defer fs.close() + fs.add(fs.dir, "testdir") + maxdepth := 1<<31 - 1 for _, tc := range []struct { cmd string @@ -137,6 +137,7 @@ def normalize_kati_log(output) "\\1: Command not found") output.gsub!(/.*: warning for parse error in an unevaluated line: .*\n/, '') output.gsub!(/^FindEmulator: /, '') + output.gsub!(/^\/bin\/sh: line 0: /, '') output.gsub!(/ (\.\/+)+kati\.\S+/, '') # kati log files in find_command.mk output.gsub!(/ (\.\/+)+test\S+.json/, '') # json files in find_command.mk output |