Shinichiro Hamaji | 9c5ec1d | 2015-10-15 15:20:14 +0900 | [diff] [blame] | 1 | # TODO(go|ninja): This test is only for ckati. ninja: multiple problems |
| 2 | # go: symlink support isn't enough. |
Dan Willemsen | 48d6e8c | 2015-08-05 14:38:34 -0700 | [diff] [blame] | 3 | # ninja: find . finds ninja temporary files |
| 4 | # ninja: escaping ! doesn't seem to be working |
| 5 | # ninja: stderr gets reordered |
Shinichiro Hamaji | 5f57a99 | 2015-06-30 19:39:39 +0900 | [diff] [blame] | 6 | |
Shinichiro Hamaji | 40c856e | 2015-07-13 20:48:24 -0700 | [diff] [blame] | 7 | ifeq ($(shell uname),Darwin) |
| 8 | USE_GNU_FIND:= |
| 9 | else |
| 10 | USE_GNU_FIND:=1 |
| 11 | endif |
| 12 | |
Shinichiro Hamaji | 5f57a99 | 2015-06-30 19:39:39 +0900 | [diff] [blame] | 13 | define run_find |
| 14 | @echo $$ '$(strip $(1))' |
Dan Willemsen | 48d6e8c | 2015-08-05 14:38:34 -0700 | [diff] [blame] | 15 | @echo $(shell $(1)) |
Shinichiro Hamaji | 5f57a99 | 2015-06-30 19:39:39 +0900 | [diff] [blame] | 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 |
Shinichiro Hamaji | e7a6822 | 2015-08-06 17:07:29 +0900 | [diff] [blame] | 25 | touch testdir/dir1/file3 |
Shinichiro Hamaji | 5f57a99 | 2015-06-30 19:39:39 +0900 | [diff] [blame] | 26 | mkdir testdir/dir2 |
| 27 | touch testdir/dir2/file1 |
| 28 | touch testdir/dir2/file2 |
Shinichiro Hamaji | e7a6822 | 2015-08-06 17:07:29 +0900 | [diff] [blame] | 29 | touch testdir/dir2/file3 |
Shinichiro Hamaji | 5f57a99 | 2015-06-30 19:39:39 +0900 | [diff] [blame] | 30 | ln -s ../dir1/file1 testdir/dir2/link1 |
| 31 | ln -s ../../testdir/dir1 testdir/dir2/link2 |
| 32 | ln -s broken testdir/dir2/link3 |
Shinichiro Hamaji | e7a6822 | 2015-08-06 17:07:29 +0900 | [diff] [blame] | 33 | mkdir -p build/tools |
| 34 | cp ../../testcase/tools/findleaves.py build/tools |
Shinichiro Hamaji | 5f57a99 | 2015-06-30 19:39:39 +0900 | [diff] [blame] | 35 | |
Shinichiro Hamaji | bd3bb23 | 2015-10-09 16:35:54 +0900 | [diff] [blame] | 36 | mkdir -p testdir3/b/c/d |
| 37 | ln -s b testdir3/a |
Shinichiro Hamaji | b717561 | 2015-10-13 16:15:34 +0900 | [diff] [blame] | 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 |
Shinichiro Hamaji | bd3bb23 | 2015-10-09 16:35:54 +0900 | [diff] [blame] | 49 | |
Shinichiro Hamaji | 5f57a99 | 2015-06-30 19:39:39 +0900 | [diff] [blame] | 50 | test2: |
| 51 | @echo no options |
| 52 | $(call run_find, find testdir) |
| 53 | $(call run_find, find .) |
Shinichiro Hamaji | 40c856e | 2015-07-13 20:48:24 -0700 | [diff] [blame] | 54 | ifeq ($(USE_GNU_FIND),1) |
Shinichiro Hamaji | 5f57a99 | 2015-06-30 19:39:39 +0900 | [diff] [blame] | 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 ././) |
Shinichiro Hamaji | 40c856e | 2015-07-13 20:48:24 -0700 | [diff] [blame] | 60 | endif |
Shinichiro Hamaji | 5f57a99 | 2015-06-30 19:39:39 +0900 | [diff] [blame] | 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 .) |
Shinichiro Hamaji | 6801397 | 2015-08-07 15:28:19 +0900 | [diff] [blame] | 83 | $(call run_find, cd testdir///dir1// && find .///) |
Shinichiro Hamaji | 5f57a99 | 2015-06-30 19:39:39 +0900 | [diff] [blame] | 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) |
Shinichiro Hamaji | 6801397 | 2015-08-07 15:28:19 +0900 | [diff] [blame] | 90 | $(call run_find, test -d testdir//dir1/// && find testdir///dir1///) |
| 91 | $(call run_find, test -d testdir//.///dir1/// && find testdir//.///dir1///) |
Shinichiro Hamaji | 5f57a99 | 2015-06-30 19:39:39 +0900 | [diff] [blame] | 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) |
Shinichiro Hamaji | d45a09d | 2015-07-02 00:35:57 +0900 | [diff] [blame] | 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) |
Shinichiro Hamaji | 6801397 | 2015-08-07 15:28:19 +0900 | [diff] [blame] | 110 | @echo findleaves |
Shinichiro Hamaji | b717561 | 2015-10-13 16:15:34 +0900 | [diff] [blame] | 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) |
Shinichiro Hamaji | e7a6822 | 2015-08-06 17:07:29 +0900 | [diff] [blame] | 118 | $(call run_find, build/tools/findleaves.py --mindepth=2 testdir file1) |
Shinichiro Hamaji | c15a824 | 2016-05-30 16:11:14 +0900 | [diff] [blame] | 119 | $(call run_find, build/tools/findleaves.py --prune=dir1 --dir=testdir file1) |
| 120 | $(call run_find, build/tools/findleaves.py --prune=dir1 --dir=testdir file3 link3) |
Shinichiro Hamaji | 3498f34 | 2015-08-11 14:23:12 +0900 | [diff] [blame] | 121 | @echo missing chdir / testdir |
| 122 | $(call run_find, cd xxx && find .) |
| 123 | $(call run_find, if [ -d xxx ]; then find .; fi) |
Shinichiro Hamaji | bd3bb23 | 2015-10-09 16:35:54 +0900 | [diff] [blame] | 124 | |
| 125 | test3: |
| 126 | $(call run_find, find testdir3/a/c) |
| 127 | $(call run_find, if [ -d testdir3/a/c ]; then find testdir3/a/c; fi) |
| 128 | $(call run_find, cd testdir3/a/c && find .) |
Shinichiro Hamaji | b717561 | 2015-10-13 16:15:34 +0900 | [diff] [blame] | 129 | $(call run_find, build/tools/findleaves.py testdir3 e) |
| 130 | |
| 131 | test4: |
| 132 | $(call run_find, find -L testdir4) |
| 133 | |
| 134 | test5: |
| 135 | $(call run_find, find -L testdir5) |
| 136 | $(call run_find, build/tools/findleaves.py testdir5 x) |