3 # Copyright 2013 Robin Mittal <robinmittal.it@gmail.com>
4 # Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com>
6 [ -f testing.sh ] && . testing.sh
8 #testing "name" "command" "result" "infile" "stdin"
10 echo "abcdefghijklmnopqrstuvwxyz" > file.txt
11 testing "text-file" "rm file.txt && [ ! -e file.txt ] && echo 'yes'" "yes\n" "" ""
15 testing "empty directory" "rm -r dir && [ ! -d dir ] && echo 'yes'" "yes\n" "" ""
18 echo "abcdefghijklmnopqrstuvwxyz" > file.txt && chmod 000 file.txt
19 testing "text file(mode 000)" "rm -f file.txt && [ ! -e file.txt ] && echo 'yes'" \
23 touch file1.txt file2.txt
25 testing "-r (multiple files and dirs)" \
26 "rm -r file1.txt file2.txt dir1 dir2 2>/dev/null &&
27 [ ! -e file1.txt -a ! -e file2.txt -a ! -d dir1 -a ! -d dir2 ] && echo 'yes'" \
31 touch file1.txt file2.txt
33 testing "-rf (present + missing files and dirs)" \
34 "rm -rf file1.txt file2.txt file3.txt dir1 dir2 dir3 2>/dev/null &&
35 [ ! -e file1.txt -a ! -e file2.txt -a ! -d dir1 -a ! -d dir2 ] && echo 'yes'" \
39 # testing with nested dirs.
40 mkdir -p dir1/dir2/dir3 dir1/dir2/dir4
41 touch dir1/file1.txt dir1/dir2/file2.txt dir1/dir2/dir3/file3.txt
42 testing "-r nested_dir" "rm -r dir1/dir2/ 2>/dev/null &&
43 [ -d dir1 -a -f dir1/file1.txt -a ! -d dir1/dir2 ] && echo 'yes'" \