http urls monitor.

test.sh 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/bash
  2. # fail out of the script if anything here fails
  3. set -e
  4. set -o pipefail
  5. # set the path to the present working directory
  6. export GOPATH=`pwd`
  7. function git_clone() {
  8. path=$1
  9. branch=$2
  10. version=$3
  11. if [ ! -d "src/$path" ]; then
  12. mkdir -p src/$path
  13. git clone https://$path.git src/$path
  14. fi
  15. pushd src/$path
  16. git checkout "$branch"
  17. git reset --hard "$version"
  18. popd
  19. }
  20. # Remove potential previous runs
  21. rm -rf src test_program_bin toml-test
  22. go get github.com/pelletier/go-buffruneio
  23. go get github.com/davecgh/go-spew/spew
  24. go get gopkg.in/yaml.v2
  25. go get github.com/BurntSushi/toml
  26. # get code for BurntSushi TOML validation
  27. # pinning all to 'HEAD' for version 0.3.x work (TODO: pin to commit hash when tests stabilize)
  28. git_clone github.com/BurntSushi/toml master HEAD
  29. git_clone github.com/BurntSushi/toml-test master HEAD #was: 0.2.0 HEAD
  30. # build the BurntSushi test application
  31. go build -o toml-test github.com/BurntSushi/toml-test
  32. # vendorize the current lib for testing
  33. # NOTE: this basically mocks an install without having to go back out to github for code
  34. mkdir -p src/github.com/pelletier/go-toml/cmd
  35. mkdir -p src/github.com/pelletier/go-toml/query
  36. cp *.go *.toml src/github.com/pelletier/go-toml
  37. cp -R cmd/* src/github.com/pelletier/go-toml/cmd
  38. cp -R query/* src/github.com/pelletier/go-toml/query
  39. go build -o test_program_bin src/github.com/pelletier/go-toml/cmd/test_program.go
  40. # Run basic unit tests
  41. go test github.com/pelletier/go-toml -covermode=count -coverprofile=coverage.out
  42. go test github.com/pelletier/go-toml/cmd/tomljson
  43. go test github.com/pelletier/go-toml/query
  44. # run the entire BurntSushi test suite
  45. if [[ $# -eq 0 ]] ; then
  46. echo "Running all BurntSushi tests"
  47. ./toml-test ./test_program_bin | tee test_out
  48. else
  49. # run a specific test
  50. test=$1
  51. test_path='src/github.com/BurntSushi/toml-test/tests'
  52. valid_test="$test_path/valid/$test"
  53. invalid_test="$test_path/invalid/$test"
  54. if [ -e "$valid_test.toml" ]; then
  55. echo "Valid Test TOML for $test:"
  56. echo "===="
  57. cat "$valid_test.toml"
  58. echo "Valid Test JSON for $test:"
  59. echo "===="
  60. cat "$valid_test.json"
  61. echo "Go-TOML Output for $test:"
  62. echo "===="
  63. cat "$valid_test.toml" | ./test_program_bin
  64. fi
  65. if [ -e "$invalid_test.toml" ]; then
  66. echo "Invalid Test TOML for $test:"
  67. echo "===="
  68. cat "$invalid_test.toml"
  69. echo "Go-TOML Output for $test:"
  70. echo "===="
  71. echo "go-toml Output:"
  72. cat "$invalid_test.toml" | ./test_program_bin
  73. fi
  74. fi