summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-02-11 11:09:42 -0500
committerTavian Barnes <tavianator@tavianator.com>2017-02-11 11:10:14 -0500
commitb30e1f47363f9b378c5860182ca570d66687488f (patch)
treedeb55b10e5061706ca350d9cffd07a24147e0e8a
parent2495dbb6960c1fc94809ea68ae5c5cca82ac0f0e (diff)
downloadbfs-b30e1f47363f9b378c5860182ca570d66687488f.tar.xz
Add some tests for the operators themselves
-rwxr-xr-xtests.sh60
-rw-r--r--tests/test_a.out2
-rw-r--r--tests/test_and.out2
-rw-r--r--tests/test_bang.out16
-rw-r--r--tests/test_implicit_and.out2
-rw-r--r--tests/test_not.out16
-rw-r--r--tests/test_o.out13
-rw-r--r--tests/test_or.out13
-rw-r--r--tests/test_precedence.out4
9 files changed, 118 insertions, 10 deletions
diff --git a/tests.sh b/tests.sh
index ded74ac..f2eb26d 100755
--- a/tests.sh
+++ b/tests.sh
@@ -141,7 +141,6 @@ posix_tests=(
test_size_plus
test_size_bytes
test_exec
- test_parens
test_flag_comma
test_perm_222
test_perm_222_minus
@@ -151,6 +150,11 @@ posix_tests=(
test_perm_symbolic_minus
test_perm_leading_plus_symbolic_minus
test_ok_stdin
+ test_parens
+ test_bang
+ test_implicit_and
+ test_a
+ test_o
)
bsd_tests=(
@@ -242,7 +246,6 @@ gnu_tests=(
test_execdir
test_execdir_substring
test_execdir_pwd
- test_comma
test_weird_names
test_flag_weird_names
test_follow_comma
@@ -283,6 +286,11 @@ gnu_tests=(
test_quit_after_print
test_quit_before_print
test_printf_leak
+ test_not
+ test_and
+ test_or
+ test_comma
+ test_precedence
)
bfs_tests=(
@@ -655,14 +663,6 @@ function test_execdir_pwd() {
bfs_diff basic -execdir bash -c "pwd | cut -b$OFFSET-" ';'
}
-function test_parens() {
- bfs_diff basic \( -name '*f*' \)
-}
-
-function test_comma() {
- bfs_diff basic -name '*f*' -print , -print
-}
-
function test_weird_names() {
cd weirdnames
bfs_diff '-' '(-' '!-' ',' ')' './(' './!' \( \! -print , -print \)
@@ -999,6 +999,46 @@ function test_expr_path_flag() {
bfs_diff -type l links/h -H
}
+function test_parens() {
+ bfs_diff basic \( -name '*f*' \)
+}
+
+function test_bang() {
+ bfs_diff basic \! -name foo
+}
+
+function test_not() {
+ bfs_diff basic -not -name foo
+}
+
+function test_implicit_and() {
+ bfs_diff basic -name foo -type d
+}
+
+function test_a() {
+ bfs_diff basic -name foo -a -type d
+}
+
+function test_and() {
+ bfs_diff basic -name foo -and -type d
+}
+
+function test_o() {
+ bfs_diff basic -name foo -o -type d
+}
+
+function test_or() {
+ bfs_diff basic -name foo -or -type d
+}
+
+function test_comma() {
+ bfs_diff basic -name '*f*' -print , -print
+}
+
+function test_precedence() {
+ bfs_diff basic \( -name foo -type d -o -name bar -a -type f \) -print , \! -empty -type f -print
+}
+
result=0
for test in ${!run_*}; do
diff --git a/tests/test_a.out b/tests/test_a.out
new file mode 100644
index 0000000..722962c
--- /dev/null
+++ b/tests/test_a.out
@@ -0,0 +1,2 @@
+basic/k/foo
+basic/l/foo
diff --git a/tests/test_and.out b/tests/test_and.out
new file mode 100644
index 0000000..722962c
--- /dev/null
+++ b/tests/test_and.out
@@ -0,0 +1,2 @@
+basic/k/foo
+basic/l/foo
diff --git a/tests/test_bang.out b/tests/test_bang.out
new file mode 100644
index 0000000..2501b2f
--- /dev/null
+++ b/tests/test_bang.out
@@ -0,0 +1,16 @@
+basic
+basic/a
+basic/b
+basic/c
+basic/e
+basic/g
+basic/i
+basic/j
+basic/k
+basic/l
+basic/c/d
+basic/e/f
+basic/g/h
+basic/k/foo/bar
+basic/l/foo/bar
+basic/l/foo/bar/baz
diff --git a/tests/test_implicit_and.out b/tests/test_implicit_and.out
new file mode 100644
index 0000000..722962c
--- /dev/null
+++ b/tests/test_implicit_and.out
@@ -0,0 +1,2 @@
+basic/k/foo
+basic/l/foo
diff --git a/tests/test_not.out b/tests/test_not.out
new file mode 100644
index 0000000..2501b2f
--- /dev/null
+++ b/tests/test_not.out
@@ -0,0 +1,16 @@
+basic
+basic/a
+basic/b
+basic/c
+basic/e
+basic/g
+basic/i
+basic/j
+basic/k
+basic/l
+basic/c/d
+basic/e/f
+basic/g/h
+basic/k/foo/bar
+basic/l/foo/bar
+basic/l/foo/bar/baz
diff --git a/tests/test_o.out b/tests/test_o.out
new file mode 100644
index 0000000..9a82ee2
--- /dev/null
+++ b/tests/test_o.out
@@ -0,0 +1,13 @@
+basic
+basic/c
+basic/e
+basic/g
+basic/i
+basic/j
+basic/k
+basic/l
+basic/g/h
+basic/j/foo
+basic/k/foo
+basic/l/foo
+basic/l/foo/bar
diff --git a/tests/test_or.out b/tests/test_or.out
new file mode 100644
index 0000000..9a82ee2
--- /dev/null
+++ b/tests/test_or.out
@@ -0,0 +1,13 @@
+basic
+basic/c
+basic/e
+basic/g
+basic/i
+basic/j
+basic/k
+basic/l
+basic/g/h
+basic/j/foo
+basic/k/foo
+basic/l/foo
+basic/l/foo/bar
diff --git a/tests/test_precedence.out b/tests/test_precedence.out
new file mode 100644
index 0000000..b3d7a51
--- /dev/null
+++ b/tests/test_precedence.out
@@ -0,0 +1,4 @@
+basic/k/foo
+basic/l/foo
+basic/k/foo/bar
+basic/l/foo/bar/baz