1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
#!/bin/bash
set -e
export TZ='UTC'
script_dir=$(dirname "$(realpath "$0")")
base_dir=$(dirname "$script_dir")
dir=$(realpath "$script_dir/../testdata/run_test")
root="/tmp/zfind/root"
if [[ ! -d $root ]]; then
echo "must run run_test_prep first"
exit 1
fi
# setup
status1=$(
cd $base_dir
git status --porcelain
)
$script_dir/build
rm -rf $dir
mkdir -p $dir
function zft {
local name=$1
shift
local path=$1
shift
echo "- $name"
cd $root/$path
"$base_dir/zfind" "$@" > "$dir/$name.txt"
}
# run actual tests
zft plain01 day/car
zft csv01 day/car 'type!="dir"' --csv
zft csv02 way/job 'type="file"' --csv-no-head
zft link01 / 'name like "party-%" and type="file"'
zft link02 / 'name like "party-%" and type="file"' -L
zft link03 / 'container like "%.tar.xz" and archive="tar" and name ilike "Art-%"' -L
zft arc01 day --archive-separator=": " 'path like "life/%" and archive="zip"'
zft name01 / 'name="service-friend.md"' -l
zft name02 / 'name like "air%"' -l
zft name03 / 'name ilike "%History%" and type="dir"' .
zft ext01 / 'ext in ("jpg","jpeg") and size>100k'
zft ext02 / 'ext in ("jpg","jpeg") and size>250k and (not container or container like "%.tar.gz")' -l
zft date01 / 'date < "2002"' -l
zft date02 / 'date between "2004" and "2005-12-31"' -l
zft size01 / 'size < 1K and type="file"' -l
zft reg01 / 'name rlike ".*\\.tar\\.gz"'
zft reg02 way 'name rlike "(.+-){2}" and size>200k'
zft reg03 / 'name rlike "^[abc].*-[a-d]"'
# check result
status2=$(
cd $base_dir
git status --porcelain
)
if [ -n "$status2" ]; then
if [ -n "$status1" ]; then
echo "run_tests was started with a dirty git directory, please verify the results manually."
exit 1
fi
echo "run_tests detected changes in the test output"
echo "$status2"
cd $base_dir
git diff
exit 1
else
echo "run_tests: OK"
fi
|