2011-01-28 07:42:51 -07:00
|
|
|
#!/usr/bin/env bash
|
2012-03-07 20:04:49 -07:00
|
|
|
# Copyright 2010 The Go Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file.
|
2010-04-27 20:36:39 -06:00
|
|
|
|
2011-01-28 07:42:51 -07:00
|
|
|
set -e
|
2015-06-14 20:52:07 -06:00
|
|
|
|
|
|
|
if ! which patch > /dev/null; then
|
|
|
|
echo "Skipping test; patch command not found."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2011-01-27 06:19:37 -07:00
|
|
|
wiki_pid=
|
2010-04-27 20:36:39 -06:00
|
|
|
cleanup() {
|
|
|
|
kill $wiki_pid
|
2015-06-16 20:46:06 -06:00
|
|
|
rm -f test_*.out Test.txt final-test.go final-test.bin final-test-port.txt a.out get.bin
|
2010-04-27 20:36:39 -06:00
|
|
|
}
|
2011-01-28 07:42:51 -07:00
|
|
|
trap cleanup 0 INT
|
2010-04-27 20:36:39 -06:00
|
|
|
|
2015-06-14 04:54:05 -06:00
|
|
|
rm -f get.bin final-test.bin a.out
|
2014-04-06 19:34:35 -06:00
|
|
|
|
2013-10-07 18:14:35 -06:00
|
|
|
# If called with -all, check that all code snippets compile.
|
2017-03-10 10:15:46 -07:00
|
|
|
if [ "$1" = "-all" ]; then
|
2013-10-07 18:14:35 -06:00
|
|
|
for fn in *.go; do
|
|
|
|
go build -o a.out $fn
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2012-03-07 20:04:49 -07:00
|
|
|
go build -o get.bin get.go
|
2015-06-14 04:54:05 -06:00
|
|
|
cp final.go final-test.go
|
|
|
|
patch final-test.go final-test.patch > /dev/null
|
|
|
|
go build -o final-test.bin final-test.go
|
|
|
|
./final-test.bin &
|
2011-01-27 06:19:37 -07:00
|
|
|
wiki_pid=$!
|
|
|
|
|
2014-03-17 20:03:03 -06:00
|
|
|
l=0
|
2015-06-14 04:54:05 -06:00
|
|
|
while [ ! -f ./final-test-port.txt ]
|
2014-03-17 20:03:03 -06:00
|
|
|
do
|
|
|
|
l=$(($l+1))
|
|
|
|
if [ "$l" -gt 5 ]
|
|
|
|
then
|
|
|
|
echo "port not available within 5 seconds"
|
|
|
|
exit 1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
2015-06-14 04:54:05 -06:00
|
|
|
addr=$(cat final-test-port.txt)
|
2014-03-17 20:03:03 -06:00
|
|
|
./get.bin http://$addr/edit/Test > test_edit.out
|
2011-01-28 07:42:51 -07:00
|
|
|
diff -u test_edit.out test_edit.good
|
2012-12-23 12:48:17 -07:00
|
|
|
./get.bin -post=body=some%20content http://$addr/save/Test > test_save.out
|
|
|
|
diff -u test_save.out test_view.good # should be the same as viewing
|
2011-01-28 07:42:51 -07:00
|
|
|
diff -u Test.txt test_Test.txt.good
|
|
|
|
./get.bin http://$addr/view/Test > test_view.out
|
|
|
|
diff -u test_view.out test_view.good
|
2010-04-27 20:36:39 -06:00
|
|
|
|
2011-01-28 07:42:51 -07:00
|
|
|
echo PASS
|