summaryrefslogtreecommitdiffstats
path: root/tests/common
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common')
-rw-r--r--tests/common/L_ilname.sh2
-rw-r--r--tests/common/L_ls.sh3
-rw-r--r--tests/common/L_mount.out10
-rw-r--r--tests/common/L_mount.sh22
-rw-r--r--tests/common/delete.out2
-rw-r--r--tests/common/delete.sh11
-rw-r--r--tests/common/delete_error.out8
-rw-r--r--tests/common/delete_error.sh9
-rw-r--r--tests/common/delete_many.out2
-rw-r--r--tests/common/delete_many.sh10
-rw-r--r--tests/common/empty.out8
-rw-r--r--tests/common/empty.sh1
-rw-r--r--tests/common/empty_error.out3
-rw-r--r--tests/common/empty_error.sh7
-rw-r--r--tests/common/empty_special.out20
-rw-r--r--tests/common/empty_special.sh1
-rw-r--r--tests/common/execdir_nonexistent.sh7
-rw-r--r--tests/common/execdir_ulimit.out2
-rw-r--r--tests/common/execdir_ulimit.sh11
-rw-r--r--tests/common/ilname.sh2
-rw-r--r--tests/common/iname.sh2
-rw-r--r--tests/common/inum_bind_mount.out4
-rw-r--r--tests/common/inum_bind_mount.sh15
-rw-r--r--tests/common/inum_mount.out2
-rw-r--r--tests/common/inum_mount.sh15
-rw-r--r--tests/common/ipath.sh2
-rw-r--r--tests/common/ls.sh3
-rw-r--r--tests/common/maxdepth_incomplete.sh2
-rw-r--r--tests/common/mindepth_incomplete.sh2
-rw-r--r--tests/common/mount.out8
-rw-r--r--tests/common/mount.sh18
-rw-r--r--tests/common/newermt.sh4
-rw-r--r--tests/common/samefile_wordesc.sh4
33 files changed, 133 insertions, 89 deletions
diff --git a/tests/common/L_ilname.sh b/tests/common/L_ilname.sh
index cfb15a8..e0495ed 100644
--- a/tests/common/L_ilname.sh
+++ b/tests/common/L_ilname.sh
@@ -1,2 +1,2 @@
-skip_unless invoke_bfs -quit -ilname PATTERN
+invoke_bfs -quit -ilname PATTERN || skip
bfs_diff -L links -ilname '[AQ]'
diff --git a/tests/common/L_ls.sh b/tests/common/L_ls.sh
index ced16c6..7ee2b44 100644
--- a/tests/common/L_ls.sh
+++ b/tests/common/L_ls.sh
@@ -1,2 +1 @@
-clean_scratch
-invoke_bfs -L rainbow -ls >scratch/L_ls.out
+invoke_bfs -L rainbow -ls >"$OUT"
diff --git a/tests/common/L_mount.out b/tests/common/L_mount.out
index 2e80082..788579d 100644
--- a/tests/common/L_mount.out
+++ b/tests/common/L_mount.out
@@ -1,5 +1,5 @@
-scratch
-scratch/foo
-scratch/foo/bar
-scratch/foo/qux
-scratch/mnt
+.
+./foo
+./foo/bar
+./foo/qux
+./mnt
diff --git a/tests/common/L_mount.sh b/tests/common/L_mount.sh
index dad7e00..fd8042a 100644
--- a/tests/common/L_mount.sh
+++ b/tests/common/L_mount.sh
@@ -1,15 +1,13 @@
-skip_unless test "$SUDO"
-skip_if test "$UNAME" = "Darwin"
+test "$UNAME" = "Darwin" && skip
-clean_scratch
-mkdir scratch/{foo,mnt}
-sudo mount -t tmpfs tmpfs scratch/mnt
-ln -s ../mnt scratch/foo/bar
-"$XTOUCH" scratch/mnt/baz
-ln -s ../mnt/baz scratch/foo/qux
+cd "$TEST"
+mkdir foo mnt
-bfs_diff -L scratch -mount
-ret=$?
+bfs_sudo mount -t tmpfs tmpfs mnt || skip
+defer bfs_sudo umount mnt
-sudo umount scratch/mnt
-return $ret
+ln -s ../mnt foo/bar
+"$XTOUCH" mnt/baz
+ln -s ../mnt/baz foo/qux
+
+bfs_diff -L . -mount
diff --git a/tests/common/delete.out b/tests/common/delete.out
index fb188b9..9c558e3 100644
--- a/tests/common/delete.out
+++ b/tests/common/delete.out
@@ -1 +1 @@
-scratch
+.
diff --git a/tests/common/delete.sh b/tests/common/delete.sh
index 89cf2a2..638f307 100644
--- a/tests/common/delete.sh
+++ b/tests/common/delete.sh
@@ -1,7 +1,4 @@
-clean_scratch
-"$XTOUCH" -p scratch/foo/bar/baz
-
-# Don't try to delete '.'
-(cd scratch && invoke_bfs . -delete)
-
-bfs_diff scratch
+cd "$TEST"
+"$XTOUCH" -p foo/bar/baz
+invoke_bfs . -delete
+bfs_diff .
diff --git a/tests/common/delete_error.out b/tests/common/delete_error.out
new file mode 100644
index 0000000..b6b6505
--- /dev/null
+++ b/tests/common/delete_error.out
@@ -0,0 +1,8 @@
+.
+.
+./baz
+./baz
+./baz/qux
+./baz/qux
+./foo
+./foo/bar
diff --git a/tests/common/delete_error.sh b/tests/common/delete_error.sh
new file mode 100644
index 0000000..e6327f3
--- /dev/null
+++ b/tests/common/delete_error.sh
@@ -0,0 +1,9 @@
+cd "$TEST"
+
+"$XTOUCH" -p foo/bar baz/qux
+chmod -w foo
+defer chmod +w foo
+
+! invoke_bfs . -print -delete -print >"$OUT" || fail
+sort_output
+diff_output
diff --git a/tests/common/delete_many.out b/tests/common/delete_many.out
index fb188b9..9c558e3 100644
--- a/tests/common/delete_many.out
+++ b/tests/common/delete_many.out
@@ -1 +1 @@
-scratch
+.
diff --git a/tests/common/delete_many.sh b/tests/common/delete_many.sh
index 6274319..48fe4c2 100644
--- a/tests/common/delete_many.sh
+++ b/tests/common/delete_many.sh
@@ -1,8 +1,8 @@
# Test for https://github.com/tavianator/bfs/issues/67
-clean_scratch
-mkdir scratch/foo
-"$XTOUCH" scratch/foo/{1..256}
+cd "$TEST"
+mkdir foo
+"$XTOUCH" foo/{1..256}
-invoke_bfs scratch/foo -delete
-bfs_diff scratch
+invoke_bfs foo -delete
+bfs_diff .
diff --git a/tests/common/empty.out b/tests/common/empty.out
new file mode 100644
index 0000000..a0f4b76
--- /dev/null
+++ b/tests/common/empty.out
@@ -0,0 +1,8 @@
+basic/a
+basic/b
+basic/c/d
+basic/e/f
+basic/g/h
+basic/i
+basic/j/foo
+basic/k/foo/bar
diff --git a/tests/common/empty.sh b/tests/common/empty.sh
new file mode 100644
index 0000000..95ee988
--- /dev/null
+++ b/tests/common/empty.sh
@@ -0,0 +1 @@
+bfs_diff basic -empty
diff --git a/tests/common/empty_error.out b/tests/common/empty_error.out
new file mode 100644
index 0000000..da45e23
--- /dev/null
+++ b/tests/common/empty_error.out
@@ -0,0 +1,3 @@
+./bar
+./baz
+./qux
diff --git a/tests/common/empty_error.sh b/tests/common/empty_error.sh
new file mode 100644
index 0000000..7c8049c
--- /dev/null
+++ b/tests/common/empty_error.sh
@@ -0,0 +1,7 @@
+cd "$TEST"
+
+"$XTOUCH" -p foo/ bar/ baz qux
+chmod -r foo baz
+defer chmod +r foo baz
+
+! bfs_diff . -empty
diff --git a/tests/common/empty_special.out b/tests/common/empty_special.out
new file mode 100644
index 0000000..fa35478
--- /dev/null
+++ b/tests/common/empty_special.out
@@ -0,0 +1,20 @@
+rainbow//
+rainbow/exec.sh
+rainbow/file.dat
+rainbow/file.txt
+rainbow/lower.gz
+rainbow/lower.tar
+rainbow/lower.tar.gz
+rainbow/lu.tar.GZ
+rainbow/mh1
+rainbow/mh2
+rainbow/ow
+rainbow/sgid
+rainbow/sticky
+rainbow/sticky_ow
+rainbow/sugid
+rainbow/suid
+rainbow/ul.TAR.gz
+rainbow/upper.GZ
+rainbow/upper.TAR
+rainbow/upper.TAR.GZ
diff --git a/tests/common/empty_special.sh b/tests/common/empty_special.sh
new file mode 100644
index 0000000..31e9d2e
--- /dev/null
+++ b/tests/common/empty_special.sh
@@ -0,0 +1 @@
+bfs_diff rainbow -empty
diff --git a/tests/common/execdir_nonexistent.sh b/tests/common/execdir_nonexistent.sh
index 5d116e5..0ec013c 100644
--- a/tests/common/execdir_nonexistent.sh
+++ b/tests/common/execdir_nonexistent.sh
@@ -1,5 +1,2 @@
-stderr=$(invoke_bfs basic -execdir "$TESTS/nonexistent" {} \; 2>&1 >/dev/null)
-[ -n "$stderr" ] || return 1
-
-bfs_diff basic -print -execdir "$TESTS/nonexistent" {} \; -print
-(($? == EX_BFS))
+bfs_diff basic -print -execdir "$TESTS/nonexistent" {} \; -print 2>"$TEST/err" && fail
+test -s "$TEST/err"
diff --git a/tests/common/execdir_ulimit.out b/tests/common/execdir_ulimit.out
index 7f53982..bf52c09 100644
--- a/tests/common/execdir_ulimit.out
+++ b/tests/common/execdir_ulimit.out
@@ -1,3 +1,4 @@
+./.
./0
./1
./2
@@ -30,7 +31,6 @@
./q
./r
./s
-./scratch
./t
./u
./v
diff --git a/tests/common/execdir_ulimit.sh b/tests/common/execdir_ulimit.sh
index 8bd9edd..122c282 100644
--- a/tests/common/execdir_ulimit.sh
+++ b/tests/common/execdir_ulimit.sh
@@ -1,7 +1,6 @@
-clean_scratch
-mkdir -p scratch/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z
-mkdir -p scratch/a/b/c/d/e/f/g/h/i/j/k/l/m/0/1/2/3/4/5/6/7/8/9/A/B/C
+cd "$TEST"
+mkdir -p a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z
+mkdir -p a/b/c/d/e/f/g/h/i/j/k/l/m/0/1/2/3/4/5/6/7/8/9/A/B/C
-closefrom 4
-ulimit -n 13
-bfs_diff scratch -execdir echo {} \;
+ulimit -n $((NOPENFD + 10))
+bfs_diff . -execdir echo {} \;
diff --git a/tests/common/ilname.sh b/tests/common/ilname.sh
index 7ab0793..fc7e9e4 100644
--- a/tests/common/ilname.sh
+++ b/tests/common/ilname.sh
@@ -1,2 +1,2 @@
-skip_unless invoke_bfs -quit -ilname PATTERN
+invoke_bfs -quit -ilname PATTERN || skip
bfs_diff links -ilname '[AQ]'
diff --git a/tests/common/iname.sh b/tests/common/iname.sh
index 8fcc443..c25a646 100644
--- a/tests/common/iname.sh
+++ b/tests/common/iname.sh
@@ -1,2 +1,2 @@
-skip_unless invoke_bfs -quit -iname PATTERN
+invoke_bfs -quit -iname PATTERN || skip
bfs_diff basic -iname '*F*'
diff --git a/tests/common/inum_bind_mount.out b/tests/common/inum_bind_mount.out
index a520de3..ede8749 100644
--- a/tests/common/inum_bind_mount.out
+++ b/tests/common/inum_bind_mount.out
@@ -1,2 +1,2 @@
-scratch/bar
-scratch/foo
+./bar
+./foo
diff --git a/tests/common/inum_bind_mount.sh b/tests/common/inum_bind_mount.sh
index e35ed4e..892713e 100644
--- a/tests/common/inum_bind_mount.sh
+++ b/tests/common/inum_bind_mount.sh
@@ -1,12 +1,9 @@
-skip_unless test "$SUDO"
-skip_unless test "$UNAME" = "Linux"
+test "$UNAME" = "Linux" || skip
-clean_scratch
-"$XTOUCH" scratch/{foo,bar}
-sudo mount --bind scratch/{foo,bar}
+cd "$TEST"
+"$XTOUCH" foo bar baz
-bfs_diff scratch -inum "$(inum scratch/bar)"
-ret=$?
+bfs_sudo mount --bind foo bar || skip
+defer bfs_sudo umount bar
-sudo umount scratch/bar
-return $ret
+bfs_diff . -inum "$(inum bar)"
diff --git a/tests/common/inum_mount.out b/tests/common/inum_mount.out
index 99c7511..99fa01e 100644
--- a/tests/common/inum_mount.out
+++ b/tests/common/inum_mount.out
@@ -1 +1 @@
-scratch/mnt
+./mnt
diff --git a/tests/common/inum_mount.sh b/tests/common/inum_mount.sh
index f9f4e2b..7facf57 100644
--- a/tests/common/inum_mount.sh
+++ b/tests/common/inum_mount.sh
@@ -1,12 +1,9 @@
-skip_unless test "$SUDO"
-skip_if test "$UNAME" = "Darwin"
+test "$UNAME" = "Darwin" && skip
-clean_scratch
-mkdir scratch/{foo,mnt}
-sudo mount -t tmpfs tmpfs scratch/mnt
+cd "$TEST"
+mkdir foo mnt
-bfs_diff scratch -inum "$(inum scratch/mnt)"
-ret=$?
+bfs_sudo mount -t tmpfs tmpfs mnt || skip
+defer bfs_sudo umount mnt
-sudo umount scratch/mnt
-return $ret
+bfs_diff . -inum "$(inum mnt)"
diff --git a/tests/common/ipath.sh b/tests/common/ipath.sh
index 9e6f8c5..7d05f31 100644
--- a/tests/common/ipath.sh
+++ b/tests/common/ipath.sh
@@ -1,2 +1,2 @@
-skip_unless invoke_bfs -quit -ipath PATTERN
+invoke_bfs -quit -ipath PATTERN || skip
bfs_diff basic -ipath 'basic/*F*'
diff --git a/tests/common/ls.sh b/tests/common/ls.sh
index 85ca39c..bc50d90 100644
--- a/tests/common/ls.sh
+++ b/tests/common/ls.sh
@@ -1,2 +1 @@
-clean_scratch
-invoke_bfs rainbow -ls >scratch/ls.out
+invoke_bfs rainbow -ls >"$OUT"
diff --git a/tests/common/maxdepth_incomplete.sh b/tests/common/maxdepth_incomplete.sh
index 536dcf5..0bcb461 100644
--- a/tests/common/maxdepth_incomplete.sh
+++ b/tests/common/maxdepth_incomplete.sh
@@ -1 +1 @@
-fail invoke_bfs basic -maxdepth
+! invoke_bfs basic -maxdepth
diff --git a/tests/common/mindepth_incomplete.sh b/tests/common/mindepth_incomplete.sh
index 19a3b21..6f55a42 100644
--- a/tests/common/mindepth_incomplete.sh
+++ b/tests/common/mindepth_incomplete.sh
@@ -1 +1 @@
-fail invoke_bfs basic -mindepth
+! invoke_bfs basic -mindepth
diff --git a/tests/common/mount.out b/tests/common/mount.out
index f7839fb..6253434 100644
--- a/tests/common/mount.out
+++ b/tests/common/mount.out
@@ -1,4 +1,4 @@
-scratch
-scratch/foo
-scratch/foo/bar
-scratch/mnt
+.
+./foo
+./foo/bar
+./mnt
diff --git a/tests/common/mount.sh b/tests/common/mount.sh
index 2732a68..c9abde5 100644
--- a/tests/common/mount.sh
+++ b/tests/common/mount.sh
@@ -1,13 +1,11 @@
-skip_unless test "$SUDO"
-skip_if test "$UNAME" = "Darwin"
+test "$UNAME" = "Darwin" && skip
-clean_scratch
-mkdir scratch/{foo,mnt}
-sudo mount -t tmpfs tmpfs scratch/mnt
-"$XTOUCH" scratch/foo/bar scratch/mnt/baz
+cd "$TEST"
+mkdir foo mnt
-bfs_diff scratch -mount
-ret=$?
+bfs_sudo mount -t tmpfs tmpfs mnt || skip
+defer bfs_sudo umount mnt
-sudo umount scratch/mnt
-return $ret
+"$XTOUCH" foo/bar mnt/baz
+
+bfs_diff . -mount
diff --git a/tests/common/newermt.sh b/tests/common/newermt.sh
index 3c5be68..e816b29 100644
--- a/tests/common/newermt.sh
+++ b/tests/common/newermt.sh
@@ -1 +1,3 @@
-bfs_diff times -newermt 1991-12-14T00:01
+bfs_diff times -newermt 1991-12-14T00:01 \
+ -newermt "1991-12-14 01:01+01:00" \
+ -newermt "19911213 20:31:00-0330"
diff --git a/tests/common/samefile_wordesc.sh b/tests/common/samefile_wordesc.sh
new file mode 100644
index 0000000..b5d158f
--- /dev/null
+++ b/tests/common/samefile_wordesc.sh
@@ -0,0 +1,4 @@
+# Regression test: don't abort on incomplete UTF-8 sequences
+export LC_ALL=$(locale -a | grep -Ei 'utf-?8$' | head -n1)
+test -n "$LC_ALL" || skip
+! invoke_bfs -samefile $'\xFA\xFA'