-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.sh
executable file
·52 lines (44 loc) · 1.36 KB
/
test.sh
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
#!/bin/bash
# lightweight shell tester for slb
set -euo pipefail
testfiles=$(find examples -maxdepth 1 -name '*.txt')
echo "found test files:"
for f in $testfiles ; do
du -h "$f"
done
cargo build --release
cwd=$(pwd)
echo
test_dir=$(mktemp -d)
echo "test directory: $test_dir"
# comment below to keep files around
trap "rm -rf $test_dir" EXIT
echo
pushd "$test_dir"
for f in $testfiles ; do
echo "testing $f"
f="$cwd/$f"
b=$(basename "$f")
awk -f "$cwd/examples/wc.awk" "$f" > "expected-$b"
"$cwd/target/release/slb" \
--mapper 'tr "[:space:]" "\n" | rg -v "^$"' \
--folder "awk '{a[\$0]++}END{for(k in a)print k,a[k]}'" \
--infile "$f" \
--outprefix "actual-$b."
cat actual-${b}.* > "actual-$b"
rm actual-${b}.*
sort -k2nr -k1 -o "expected-$b" "expected-$b"
sort -k2nr -k1 -o "actual-$b" "actual-$b"
diff "expected-$b" "actual-$b" >/dev/null
split -n l/10 "$f" split-${b}-
"$cwd/target/release/slb" \
--mapper 'tr "[:space:]" "\n" | rg -v "^$"' \
--folder "awk '{a[\$0]++}END{for(k in a)print k,a[k]}'" \
--infile split-${b}-* \
--outprefix "actual-split-$b."
cat actual-split-${b}.* > "actual-split-$b"
rm actual-split-${b}.*
sort -k2nr -k1 -o "actual-split-$b" "actual-split-$b"
diff "actual-$b" "actual-split-$b" >/dev/null
done
popd >/dev/null