-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpipe-test.sh
executable file
·175 lines (141 loc) · 3.26 KB
/
webpipe-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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/bash
#
# Copyright 2014 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be found
# in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd
#
# Usage:
# ./webpipe-test.sh <function name>
set -o nounset
# TODO: make this a proper dep
. ~/hg/taste/taste.sh
#
# Components
#
# client
wp() {
./wp-dev.sh "$@"
}
xrender() {
./wp-dev.sh xrender "$@"
}
serve() {
./wp-dev.sh serve "$@"
}
#
# Demo files
#
# http://hci.stanford.edu/jheer/workshop/data/
big-csv() {
ln --verbose --force -s $PWD/testdata/census_marriage.csv ~/webpipe/input
}
# TODO: need a client to generate this data file.
#
# fs-treemap
treemap-testdata() {
~/hg/treemap/run.sh find-with-format-string '%s %p\n' . \
| tee plugins/treemap/testdata/tiny.treemap
}
zip-testdata() {
echo foo > _tmp/foo.txt
zip plugins/zip/testdata/tiny.zip _tmp/foo.txt
}
treemap-plugin() {
local dest=${1:-~/webpipe/input}
plugins/treemap/render $dest/demo.treemap 3
}
write-tiny() {
for p in html txt markdown csv json treemap zip; do
echo $p
wp show plugins/$p/testdata/tiny.$p
sleep 0.5
done
}
write-demo() {
local dest=~/webpipe/input
set -x
write-tiny
# TODO: generate png testdata
touch $dest/Rplot001.png
sleep 1
# TODO: typescript should be its own file type. People might want to use a
# different plugin. Need aliases.
wp show plugins/typescript/testdata/typescript
sleep 1
wp show plugins/dot/examples/cluster.dot
sleep 1
wp show testdata/file.unknown
sleep 1
}
#
# Tests
#
test-xrender-badport() {
xrender -p invalid
check $? -eq 1
}
test-xrender() {
xrender ~/webpipe/input ~/webpipe/s/webpipe-test <<EOF
$PWD/plugins/txt/testdata/example.txt
$PWD/plugins/html/testdata/example.html
EOF
# Make sure a nonexistent file doesn't stop the loop
xrender ~/webpipe/input ~/webpipe/s/webpipe-test <<EOF
$PWD/plugins/txt/testdata/example.txt
nonexistent
$PWD/plugins/html/testdata/example.html
EOF
}
test-serve() {
# Test it without a renderer.
local dev=$PWD/wp-dev.sh
# TODO: It expects a message with "files" on stdin. It could just take a
# line like '1.html'
local session=~/webpipe/s/webpipe-test
echo '<i>one</i>' > $session/1.html
{ echo '2:{}'; echo 1.html; } | $dev serve serve $session
}
# not fatal
test-recv-bad-fields() {
echo -n '0:}8:1:a,1:b,}' | ./wp-dev.sh recv ~/webpipe/input
echo $?
}
# fatal, because the stream could be messed up
test-recv-bad-message() {
echo -n 'abc' | ./wp-dev.sh recv ~/webpipe/input
echo $?
}
test-recv-empty() {
echo -n '' | ./wp-dev.sh recv ~/webpipe/input
echo $?
}
# TODO: 'wp-stub send' tests are broken. Semantics are unclear.
test-send() {
( echo wp-stub.sh;
echo nonexistent ) \
| ./wp-stub.sh send
}
# Since the stub can be copied to many machines, test that it an run with a
# non-bash shell.
test-stub-with-busybox() {
( echo wp-stub.sh;
echo nonexistent ) \
| busybox sh wp-stub.sh send
}
test-send-recv() {
local out=~/webpipe/input/wp-stub.sh
rm $out
echo wp-stub.sh \
| ./wp-stub.sh send \
| ./wp-dev.sh recv ~/webpipe/input
ls -al $out
diff wp-stub.sh $out
echo $?
}
#
# Publishing
#
publish-demo() {
./wp-dev.sh publish ~/webpipe/s/2014-03-23/5 dreamhost
}
"$@"