aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFumitoshi Ukai <ukai@google.com>2015-08-11 17:50:56 +0900
committerFumitoshi Ukai <ukai@google.com>2015-08-11 17:53:21 +0900
commit2c6eff6ea834bd2c81974edc9b07fef8c1abb06a (patch)
tree41934eb7882714b932a5e0ed11f1ed319e85ed89
parent59956606c56b1ffc79eca2c85701bce1bca027d2 (diff)
downloadandroid_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.go20
-rw-r--r--pathutil_test.go4
-rwxr-xr-xruntest.rb1
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
diff --git a/runtest.rb b/runtest.rb
index 4d391fc..60a7e84 100755
--- a/runtest.rb
+++ b/runtest.rb
@@ -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