forked from dspinellis/dgsh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-sgsh.sh
executable file
·95 lines (77 loc) · 3.1 KB
/
test-sgsh.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
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
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
# Ensure that the generated test file matches the reference one
# File names are by conventions test/$base/out.{ok,test}
ensure_same()
{
local flags=$1
local base=$2
echo "$base.sh [$flags]"
if ! diff -rw test/$base/out.ok test/$base/out.test >/dev/null
then
echo "$base.sh: test/$base/out.ok and test/$base/out.test differ" 1>&2
exit 1
fi
}
# Include fallback commands in our executable path
export PATH="$PATH:test/bin"
LOGFILE=test/web-log-report/logfile
# Generate a small log file if it is not there
# See http://ita.ee.lbl.gov/html/contrib/ClarkNet-HTTP.html
CLARKNET=ftp://ita.ee.lbl.gov/traces/clarknet_access_log_Aug28.gz
if ! [ -f $LOGFILE ]
then
echo "Fetching web test data"
{
curl $CLARKNET 2>/dev/null ||
wget -O - $CLARKNET 2>/dev/null
} |
gzip -dc |
perl -ne 'print if ($i++ % 1000 == 0)' >$LOGFILE
fi
for flags in '' -m -S
do
rm -rf test/*/out.test
echo hello cruwl world | ./sgsh $flags -p . example/spell-highlight.sh >test/spell-highlight/out.test
ensure_same "$flags" spell-highlight
./sgsh $flags -p . example/map-hierarchy.sh test/map-hierarchy/in/a test/map-hierarchy/in/b test/map-hierarchy/out.test
ensure_same "$flags" map-hierarchy
./sgsh $flags -p . example/commit-stats.sh --until '{2013-07-15 23:59 UTC}' >test/commit-stats/out.test
ensure_same "$flags" commit-stats
./sgsh $flags -p . example/code-metrics.sh test/code-metrics/in/ >test/code-metrics/out.test
ensure_same "$flags" code-metrics
./sgsh $flags -p . example/duplicate-files.sh test/duplicate-files >test/duplicate-files/out.test
ensure_same "$flags" duplicate-files
./sgsh $flags -p . example/word-properties.sh <test/word-properties/LostWorldChap1-3 >test/word-properties/out.test
ensure_same "$flags" word-properties
./sgsh $flags -p . example/compress-compare.sh <test/word-properties/LostWorldChap1-3 | sed 's/:.*ASCII.*/: ASCII/;s|/dev/stdin:||' >test/compress-compare/out.test
ensure_same "$flags" compress-compare
./sgsh $flags -p . example/web-log-report.sh <test/web-log-report/logfile >test/web-log-report/out.test
ensure_same "$flags" web-log-report
(
cd test/text-properties
rm -rf out.test
mkdir out.test
cd out.test
../../../sgsh $flags -p ../../.. ../../../example/text-properties.sh <../../word-properties/LostWorldChap1-3
)
ensure_same "$flags" text-properties
done
# Outside the loop, because scatter -s is not compatible with -S
# The correct file was generated using
# LC_ALL=C tr -s ' \t\n\r\f' \\n <test/word-properties/LostWorldChap1-3 | sort | uniq -c | sed 's/^ *//' >test/parallel-word-count/out.ok
# An empty line is removed from the test output, because it can be generated
# by tr when the first line of a split file is empty. (In that case \n is not
# a repeated character that tr will remove.)
LC_ALL=C ./sgsh -p . example/parallel-word-count.sh <test/word-properties/LostWorldChap1-3 | sed '/^[0-9]* $/d' >test/parallel-word-count/out.test
ensure_same "" parallel-word-count
for i in example/*
do
echo -n "Testing graph of $i "
if ./sgsh -g pretty -p . $i | fgrep '???' >/dev/null
then
echo "FAIL: Graph for $i has unknown nodes" 1>&2
exit 1
fi
echo OK
done
exit 0