diff options
author | Felix Janda <felix.janda@posteo.de> | 2013-04-14 12:45:36 +0200 |
---|---|---|
committer | Felix Janda <felix.janda@posteo.de> | 2013-04-14 12:45:36 +0200 |
commit | a84233539570a004eef42cf14238774b82f9da92 (patch) | |
tree | 6e36384203d134a31cceb2940c327d30f43f5c9e | |
parent | 36ffc5aa3e6bfcab5d628208f4f1508f9b1c2620 (diff) | |
download | toybox-a84233539570a004eef42cf14238774b82f9da92.tar.gz |
Add tests for find's expression parsing
-rw-r--r-- | scripts/test/find.test | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/test/find.test b/scripts/test/find.test new file mode 100644 index 00000000..cbbce5fd --- /dev/null +++ b/scripts/test/find.test @@ -0,0 +1,42 @@ +#!/bin/bash + +[ -f testing.sh ] && . testing.sh + +mkdir dir +cd dir +touch file +mkfifo fifo +ln -s fifo link +cd .. + +#testing "name" "command" "result" "infile" "stdin" + +# Testing operators + +testing "find -type l -a -type d -o -type p" \ + "find dir -type l -a -type d -o -type p" "dir/fifo\n" "" "" +testing "find -type l -type d -o -type p" "find dir -type l -type d -o -type p" \ + "dir/fifo\n" "" "" +testing "find -type l -o -type d -a -type p" \ + "find dir -type l -o -type d -a -type p" "dir/link\n" "" "" +testing "find -type l -o -type d -type p" "find dir -type l -o -type d -type p" \ + "dir/link\n" "" "" +testing "find -type l ( -type d -o -type l )" \ + "find dir -type l \( -type d -o -type l \)" "dir/link\n" "" "" +testing "find extra parantheses" \ + "find dir \( \( -type l \) \( -type d -o \( \( -type l \) \) \) \)" \ + "dir/link\n" "" "" +testing "find ( -type p -o -type d ) -type p" \ + "find dir \( -type p -o -type d \) -type p" "dir/fifo\n" "" "" +testing "find -type l -o -type d -type p -o -type f" \ + "find dir -type l -o -type d -type p -o -type f | sort" \ + "dir/file\ndir/link\n" "" "" + +# Testing short-circuit evaluations + +testing "find -type f -a -print" \ + "find dir -type f -a -print" "dir/file\n" "" "" +testing "find -print -o -print" \ + "find dir -type f -a \( -print -o -print \)" "dir/file\n" "" "" + +rm -rf dir |