3 [ -f testing.sh ] && . testing.sh
5 #testing "name" "command" "result" "infile" "stdin"
7 testing "mkdir" "mkdir one && [ -d one ] && echo yes" "yes\n" "" ""
12 "mkdir existing 2> /dev/null || [ -f existing ] && echo yes" "yes\n" "" ""
16 "mkdir one two && [ -d one ] && [ -d two ] && echo yes" "yes\n" "" ""
19 testing "missing/one" \
20 "mkdir missing/one 2> /dev/null || [ ! -d missing ] && echo yes" "yes\n" "" ""
23 "mkdir -p one/two/three && [ -d one/two/three ] && echo yes" "yes\n" "" ""
27 testing "-p existing" "mkdir -p existing && echo yes" "yes\n" "" ""
31 testing "(default permissions)" \
32 "mkdir one && stat -c %a one" "654\n" "" ""
36 "mkdir -m 124 one && stat -c %a one" "124\n" "" ""
41 "mkdir -p -m 653 one/two && stat -c %a one && stat -c %a one/two" \
45 testing "-p one/two/ (trailing slash)" \
46 "mkdir -p one/two/ && [ -d one/two ] && echo yes" "yes\n" "" ""
50 testing "-p -m 777 (022 umask)" \
51 "mkdir -p -m 777 one/two && stat -c %a one && stat -c %a one/two" \
56 testing "-p -m 777 (377 umask)" \
57 "mkdir -p -m 777 one/two && stat -c %a one && stat -c %a one/two" \
62 testing "-vp" "mkdir -vp walrus 2>&1" \
63 "mkdir: created directory 'walrus'\n" "" ""
65 testing "-vp exists" "mkdir -vp walrus 2>&1" \
70 testing "continue after fail" \
71 "mkdir -m 777 one two three 2>/dev/null || stat -c %a three" \