github.com/spotify/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/doc/articles/wiki/test.bash (about) 1 #!/usr/bin/env bash 2 # Copyright 2010 The Go Authors. All rights reserved. 3 # Use of this source code is governed by a BSD-style 4 # license that can be found in the LICENSE file. 5 6 set -e 7 wiki_pid= 8 cleanup() { 9 kill $wiki_pid 10 rm -f test_*.out Test.txt final-test.bin final-test.go a.out get.bin 11 } 12 trap cleanup 0 INT 13 14 # If called with -all, check that all code snippets compile. 15 if [ "$1" == "-all" ]; then 16 for fn in *.go; do 17 go build -o a.out $fn 18 done 19 fi 20 21 go build -o get.bin get.go 22 addr=$(./get.bin -addr) 23 sed s/:8080/$addr/ < final.go > final-test.go 24 go build -o final-test.bin final-test.go 25 (./final-test.bin) & 26 wiki_pid=$! 27 28 ./get.bin --wait_for_port=5s http://$addr/edit/Test > test_edit.out 29 diff -u test_edit.out test_edit.good 30 ./get.bin -post=body=some%20content http://$addr/save/Test > test_save.out 31 diff -u test_save.out test_view.good # should be the same as viewing 32 diff -u Test.txt test_Test.txt.good 33 ./get.bin http://$addr/view/Test > test_view.out 34 diff -u test_view.out test_view.good 35 36 echo PASS