Skip to content

Commit fefa3bc

Browse files
committed
tests/run-tests.sh minor fixes + documenting
1 parent 264988c commit fefa3bc

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

tests/run-tests.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
#!/bin/bash
22

3+
# 1) start server:
4+
# without caching:
5+
# REDIS_HOST=None CHEATSH_PORT=50000 python bin/srv.py
6+
# (recommended)
7+
# with caching:
8+
# REDIS_PREFIX=TEST1 CHEATSH_PORT=50000 python bin/srv.py
9+
# (for complex search queries + to test caching)
10+
# 2) configure CHTSH_URL
11+
# 3) run the script
12+
313
TMP=$(mktemp /tmp/cht.sh.tests-XXXXXXXXXXXXXX)
414
TMP2=$(mktemp /tmp/cht.sh.tests-XXXXXXXXXXXXXX)
515
TMP3=$(mktemp /tmp/cht.sh.tests-XXXXXXXXXXXXXX)
616
trap 'rm -rf $TMP $TMP2 $TMP3' EXIT
717

818
export CHTSH_URL=http://cht.sh:50000
9-
CHTSH_SCRIPT=$(dirname $(dirname $(readlink -f "$0")))/share/cht.sh.txt
19+
CHTSH_SCRIPT=$(dirname "$(dirname "$(readlink -f "$0")")")/share/cht.sh.txt
1020

1121
i=0
1222
failed=0
1323
{
1424
if [ -z "$1" ]; then
1525
cat -n tests.txt
1626
else
17-
cat -n tests.txt | sed -n "$(echo $* | sed 's/ /p; /g;s/$/p/')"
27+
cat -n tests.txt | sed -n "$(echo "$*" | sed 's/ /p; /g;s/$/p/')"
1828
fi
1929
} > "$TMP3"
2030
while read -r number test_line; do
@@ -25,14 +35,13 @@ while read -r number test_line; do
2535
else
2636
eval "curl -s $CHTSH_URL/$test_line" > "$TMP"
2737
fi
28-
diff results/"$number" "$TMP" > "$TMP2"
29-
if [ "$?" != 0 ]; then
38+
if ! diff results/"$number" "$TMP" > "$TMP2"; then
3039
echo "FAILED: [$number] $test_line"
3140
((failed++))
3241
fi
3342
((i++))
3443
done < "$TMP3"
3544

36-
echo TESTS/OK/FAILED "$i/$[i-failed]/$failed"
45+
echo TESTS/OK/FAILED "$i/$((i-failed))/$failed"
3746

3847

0 commit comments

Comments
 (0)