/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/tests/charset.sh

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs · Shell · 110 lines · 74 code · 17 blank · 19 comment · 2 complexity · 74b96d2a809d994ac5a0aa193dd6199a MD5 · raw file

  1. #!/bin/sh
  2. # charset.sh - test jscoverage-server with different charset values
  3. # Copyright (C) 2008 siliconforks.com
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License along
  16. # with this program; if not, write to the Free Software Foundation, Inc.,
  17. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. set -e
  19. shutdown() {
  20. wget -q -O- --post-data= "http://127.0.0.1:${proxy_server_port}/jscoverage-shutdown" > /dev/null
  21. wait $proxy_server_pid
  22. }
  23. cleanup() {
  24. shutdown
  25. kill -9 $origin_server_pid
  26. }
  27. trap 'cleanup' 0 1 2 3 15
  28. export PATH=.:..:$PATH
  29. if [ -z "$VALGRIND" ]
  30. then
  31. delay=0.2
  32. else
  33. delay=2
  34. fi
  35. if jscoverage-server --version | grep -q 'iconv\|MultiByteToWideChar'
  36. then
  37. character_encoding_support=yes
  38. else
  39. character_encoding_support=no
  40. fi
  41. $VALGRIND jscoverage-server --proxy --no-highlight > OUT 2> ERR &
  42. proxy_server_pid=$!
  43. proxy_server_port=8080
  44. ./http-server-charset &
  45. origin_server_pid=$!
  46. sleep $delay
  47. case "$character_encoding_support" in
  48. yes)
  49. cat ../report.js > EXPECTED
  50. cat javascript-utf-8.expected/javascript-utf-8.js | sed 's/javascript-utf-8.js/http:\/\/127.0.0.1:8000\/utf-8.js/g' >> EXPECTED
  51. curl -s -x 127.0.0.1:8080 http://127.0.0.1:8000/utf-8.js > ACTUAL
  52. diff EXPECTED ACTUAL
  53. ;;
  54. *)
  55. echo 500 > EXPECTED
  56. ! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://127.0.0.1:8000/utf-8.js 2> /dev/null > ACTUAL
  57. diff EXPECTED ACTUAL
  58. ;;
  59. esac
  60. shutdown
  61. $VALGRIND jscoverage-server --proxy > OUT 2> ERR &
  62. proxy_server_pid=$!
  63. proxy_server_port=8080
  64. sleep $delay
  65. case "$character_encoding_support" in
  66. yes)
  67. cat ../report.js > EXPECTED
  68. cat javascript.expected/javascript-iso-8859-1.js | sed 's/javascript-iso-8859-1.js/http:\/\/127.0.0.1:8000\/iso-8859-1.js/g' >> EXPECTED
  69. curl -s -x 127.0.0.1:8080 http://127.0.0.1:8000/iso-8859-1.js > ACTUAL
  70. diff EXPECTED ACTUAL
  71. ;;
  72. *)
  73. echo 500 > EXPECTED
  74. ! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://127.0.0.1:8000/iso-8859-1.js 2> /dev/null > ACTUAL
  75. diff EXPECTED ACTUAL
  76. ;;
  77. esac
  78. # bogus charset
  79. echo 500 > EXPECTED
  80. ! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://127.0.0.1:8000/bogus.js 2> /dev/null > ACTUAL
  81. diff EXPECTED ACTUAL
  82. # malformed encoding
  83. case "$character_encoding_support" in
  84. yes)
  85. status=502
  86. ;;
  87. *)
  88. status=500
  89. ;;
  90. esac
  91. echo $status > EXPECTED
  92. ! curl -f -w '%{http_code}\n' -x 127.0.0.1:8080 http://127.0.0.1:8000/malformed.js 2> /dev/null > ACTUAL
  93. diff EXPECTED ACTUAL