Home | History | Annotate | Download | only in testcase
      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" -name "file*")
     71 	$(call run_find, find testdir -name "*1" -and -name "file*")
     72 	$(call run_find, find testdir -name "*1" -or -name "file*")
     73 	$(call run_find, find testdir -name "*1" -or -type f)
     74 	$(call run_find, find testdir -name "*1" -or -not -type f)
     75 	$(call run_find, find testdir -name "*1" -or \! -type f)
     76 	$(call run_find, find testdir -name "*1" -or -type d)
     77 	$(call run_find, find testdir -name "*1" -or -type l)
     78 	$(call run_find, find testdir -name "*1" -a -type l -o -name "dir*")
     79 	$(call run_find, find testdir -name "dir*" -o -name "*1" -a -type l)
     80 	$(call run_find, find testdir \( -name "dir*" -o -name "*1" \) -a -type f)
     81 	@echo cd
     82 	$(call run_find, cd testdir && find)
     83 	$(call run_find, cd testdir/// && find .)
     84 	$(call run_find, cd testdir///dir1// && find .///)
     85 	$(call run_find, cd testdir && find ../testdir)
     86 	@echo test
     87 	$(call run_find, test -d testdir && find testdir)
     88 	$(call run_find, if [ -d testdir ] ; then find testdir ; fi)
     89 	$(call run_find, if [ -d testdir ]; then find testdir; fi)
     90 	$(call run_find, if [ -d testdir ]; then cd testdir && find .; fi)
     91 	$(call run_find, test -d testdir//dir1/// && find testdir///dir1///)
     92 	$(call run_find, test -d testdir//.///dir1/// && find testdir//.///dir1///)
     93 	@echo prune
     94 	$(call run_find, find testdir -name dir2 -prune -o -name file1)
     95 	@echo multi
     96 	$(call run_find, find testdir testdir)
     97 	@echo symlink
     98 	$(call run_find, find -L testdir -type f)
     99 	$(call run_find, find -L testdir -type d)
    100 	$(call run_find, find -L testdir -type l)
    101 	$(call run_find, cd testdir; find -L . -type f)
    102 	$(call run_find, cd testdir; find -L . -type d)
    103 	$(call run_find, cd testdir; find -L . -type l)
    104 	@echo maxdepth
    105 	$(call run_find, find testdir -maxdepth 1)
    106 	$(call run_find, find testdir -maxdepth 2)
    107 	$(call run_find, find testdir -maxdepth 0)
    108 	$(call run_find, find testdir -maxdepth hoge)
    109 	$(call run_find, find testdir -maxdepth 1hoge)
    110 	$(call run_find, find testdir -maxdepth -1)
    111 	@echo findleaves
    112 	$(call run_find, build/tools/findleaves.py testdir file1)
    113 	$(call run_find, build/tools/findleaves.py testdir file3)
    114 	$(call run_find, build/tools/findleaves.py --prune=dir1 testdir file3)
    115 	$(call run_find, build/tools/findleaves.py --prune=dir1 --prune=dir2 testdir file3)
    116 	$(call run_find, build/tools/findleaves.py --mindepth=1 testdir file1)
    117 	$(call run_find, build/tools/findleaves.py --mindepth=2 testdir file1)
    118 	$(call run_find, build/tools/findleaves.py --mindepth=3 testdir file1)
    119 	$(call run_find, build/tools/findleaves.py --mindepth=2 testdir file1)
    120 	$(call run_find, build/tools/findleaves.py --prune=dir1 --dir=testdir file1)
    121 	$(call run_find, build/tools/findleaves.py --prune=dir1 --dir=testdir file3 link3)
    122 	@echo missing chdir / testdir
    123 	$(call run_find, cd xxx && find .)
    124 	$(call run_find, if [ -d xxx ]; then find .; fi)
    125 
    126 test3:
    127 	$(call run_find, find testdir3/a/c)
    128 	$(call run_find, if [ -d testdir3/a/c ]; then find testdir3/a/c; fi)
    129 	$(call run_find, cd testdir3/a/c && find .)
    130 	$(call run_find, build/tools/findleaves.py testdir3 e)
    131 
    132 test4:
    133 	$(call run_find, find -L testdir4)
    134 
    135 test5:
    136 	$(call run_find, find -L testdir5)
    137 	$(call run_find, build/tools/findleaves.py testdir5 x)
    138