2020-04-06 23:18:08 -07:00
|
|
|
#!/bin/sh
|
|
|
|
# Simple test suite
|
|
|
|
set -e
|
|
|
|
tmp="tests"
|
|
|
|
mkdir -p "$tmp"
|
|
|
|
trap 'rm -rf "$tmp"' EXIT
|
|
|
|
|
2020-04-07 02:05:41 -07:00
|
|
|
testdirs="d1 d2 d3 d4"
|
|
|
|
testfiles="f1 f2 f3"
|
2020-04-06 23:18:08 -07:00
|
|
|
for d in $testdirs; do
|
|
|
|
mkdir -p "$tmp/$d"
|
|
|
|
for f in $testfiles; do touch "$tmp/$d/$f"; done
|
|
|
|
done
|
|
|
|
|
2020-04-07 02:05:41 -07:00
|
|
|
./trash -v "$tmp/d1/f1" "$tmp/d1/f2" "$tmp/d2" "$tmp/d3"
|
|
|
|
./trash -v -f -u "$tmp/d1/f1"
|
|
|
|
./trash -v -f -u "$tmp/d2"
|
2020-04-06 23:18:08 -07:00
|
|
|
|
2020-04-07 02:05:41 -07:00
|
|
|
[ -e "$tmp/d1/f1" ]
|
|
|
|
! [ -e "$tmp/d1/f2" ]
|
|
|
|
[ -e "$tmp/d1/f3" ]
|
|
|
|
[ -e "$tmp/d2" ]
|
|
|
|
[ -e "$tmp/d2/f1" ]
|
|
|
|
! [ -e "$tmp/d3" ]
|
|
|
|
[ -e "$tmp/d4" ]
|
2020-04-06 23:18:08 -07:00
|
|
|
|
2020-04-07 02:05:41 -07:00
|
|
|
./trash -f -v -e "$tmp/d1/f2" "$tmp/d3"
|
|
|
|
|
|
|
|
echo "old" > "$tmp/over.txt"
|
|
|
|
./trash "$tmp/over.txt"
|
|
|
|
printf '\033[2mPausing 2sec to let file deletion time advance...\033[0m\n'
|
|
|
|
sleep 2
|
|
|
|
echo "new" > "$tmp/over.txt"
|
|
|
|
./trash -v "$tmp/over.txt"
|
|
|
|
./trash -v -u "$tmp/over.txt"
|
|
|
|
! [ -e "$tmp/over.txt" ]
|
|
|
|
[ -e "$tmp/over.txt" -a "$(cat "$tmp/over.txt")" = "new" ]
|
|
|
|
rm -f "$tmp/over.txt"
|
|
|
|
./trash -v -u "$tmp/over.txt"
|
|
|
|
[ -e "$tmp/over.txt" -a "$(cat "$tmp/over.txt")" = "old" ]
|
|
|
|
|
|
|
|
printf '\033[32;1mTests passed!\033[0m\n'
|