1 # TODO(go|ninja): This test is only for ckati. ninja: multiple problems 2 # go: symlink support isn't enough. 3 # ninja: find . finds ninja temporary files 4 # ninja: escaping ! doesn't seem to be working 5 # ninja: stderr gets reordered 6 7 ifeq ($(shell uname),Darwin) 8 USE_GNU_FIND:= 9 else 10 USE_GNU_FIND:=1 11 endif 12 13 define run_find 14 @echo $$ '$(strip $(1))' 15 @echo $(shell $(1)) 16 endef 17 18 test1: 19 mkdir testdir 20 touch testdir/file1 21 touch testdir/file2 22 mkdir testdir/dir1 23 touch testdir/dir1/file1 24 touch testdir/dir1/file2 25 touch testdir/dir1/file3 26 mkdir testdir/dir2 27 touch testdir/dir2/file1 28 touch testdir/dir2/file2 29 touch testdir/dir2/file3 30 ln -s ../dir1/file1 testdir/dir2/link1 31 ln -s ../../testdir/dir1 testdir/dir2/link2 32 ln -s broken testdir/dir2/link3 33 mkdir -p build/tools 34 cp ../../testcase/tools/findleaves.py build/tools 35 36 mkdir -p testdir3/b/c/d 37 ln -s b testdir3/a 38 touch testdir3/b/c/d/e 39 40 mkdir -p testdir4/a/b 41 ln -s self testdir4/self 42 ln -s .. testdir4/a/b/c 43 ln -s b testdir4/a/l 44 45 mkdir -p testdir5 46 ln -s a testdir5/a 47 ln -s b testdir5/c 48 ln -s c testdir5/b 49 50 test2: 51 @echo no options 52 $(call run_find, find testdir) 53 $(call run_find, find .) 54 ifeq ($(USE_GNU_FIND),1) 55 $(call run_find, find ./) 56 $(call run_find, find .///) 57 $(call run_find, find ) 58 $(call run_find, find ./.) 59 $(call run_find, find ././) 60 endif 61 $(call run_find, find testdir/../testdir) 62 @echo print 63 $(call run_find, find testdir -print) 64 @echo conditiions 65 $(call run_find, find testdir -name foo) 66 $(call run_find, find testdir -name file1) 67 $(call run_find, find testdir -name "file1") 68 $(call run_find, find testdir -name "file1") 69 $(call run_find, find testdir -name "*1") 70 $(call run_find, find testdir -name "*1" -and -name "file*") 71 $(call run_find, find testdir -name "*1" -or -name "file*") 72 $(call run_find, find testdir -name "*1" -or -type f) 73 $(call run_find, find testdir -name "*1" -or -not -type f) 74 $(call run_find, find testdir -name "*1" -or \! -type f) 75 $(call run_find, find testdir -name "*1" -or -type d) 76 $(call run_find, find testdir -name "*1" -or -type l) 77 $(call run_find, find testdir -name "*1" -a -type l -o -name "dir*") 78 $(call run_find, find testdir -name "dir*" -o -name "*1" -a -type l) 79 $(call run_find, find testdir \( -name "dir*" -o -name "*1" \) -a -type f) 80 @echo cd 81 $(call run_find, cd testdir && find) 82 $(call run_find, cd testdir/// && find .) 83 $(call run_find, cd testdir///dir1// && find .///) 84 $(call run_find, cd testdir && find ../testdir) 85 @echo test 86 $(call run_find, test -d testdir && find testdir) 87 $(call run_find, if [ -d testdir ] ; then find testdir ; fi) 88 $(call run_find, if [ -d testdir ]; then find testdir; fi) 89 $(call run_find, if [ -d testdir ]; then cd testdir && find .; fi) 90 $(call run_find, test -d testdir//dir1/// && find testdir///dir1///) 91 $(call run_find, test -d testdir//.///dir1/// && find testdir//.///dir1///) 92 @echo prune 93 $(call run_find, find testdir -name dir2 -prune -o -name file1) 94 @echo multi 95 $(call run_find, find testdir testdir) 96 @echo symlink 97 $(call run_find, find -L testdir -type f) 98 $(call run_find, find -L testdir -type d) 99 $(call run_find, find -L testdir -type l) 100 $(call run_find, cd testdir; find -L . -type f) 101 $(call run_find, cd testdir; find -L . -type d) 102 $(call run_find, cd testdir; find -L . -type l) 103 @echo maxdepth 104 $(call run_find, find testdir -maxdepth 1) 105 $(call run_find, find testdir -maxdepth 2) 106 $(call run_find, find testdir -maxdepth 0) 107 $(call run_find, find testdir -maxdepth hoge) 108 $(call run_find, find testdir -maxdepth 1hoge) 109 $(call run_find, find testdir -maxdepth -1) 110 @echo findleaves 111 $(call run_find, build/tools/findleaves.py testdir file1) 112 $(call run_find, build/tools/findleaves.py testdir file3) 113 $(call run_find, build/tools/findleaves.py --prune=dir1 testdir file3) 114 $(call run_find, build/tools/findleaves.py --prune=dir1 --prune=dir2 testdir file3) 115 $(call run_find, build/tools/findleaves.py --mindepth=1 testdir file1) 116 $(call run_find, build/tools/findleaves.py --mindepth=2 testdir file1) 117 $(call run_find, build/tools/findleaves.py --mindepth=3 testdir file1) 118 $(call run_find, build/tools/findleaves.py --mindepth=2 testdir file1) 119 @echo missing chdir / testdir 120 $(call run_find, cd xxx && find .) 121 $(call run_find, if [ -d xxx ]; then find .; fi) 122 123 test3: 124 $(call run_find, find testdir3/a/c) 125 $(call run_find, if [ -d testdir3/a/c ]; then find testdir3/a/c; fi) 126 $(call run_find, cd testdir3/a/c && find .) 127 $(call run_find, build/tools/findleaves.py testdir3 e) 128 129 test4: 130 $(call run_find, find -L testdir4) 131 132 test5: 133 $(call run_find, find -L testdir5) 134 $(call run_find, build/tools/findleaves.py testdir5 x) 135