PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
Shell | 137 lines | 85 code | 27 blank | 25 comment | 3 complexity | 7240a5a3f4832e6f95506bad708d7135 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. #!/bin/sh
  2. # store.sh - test storing coverage reports with jscoverage-server
  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. . common.sh
  20. shutdown() {
  21. wget -q -O- --post-data= "http://127.0.0.1:${server_port}/jscoverage-shutdown" > /dev/null
  22. wait $server_pid
  23. }
  24. cleanup() {
  25. # rm -fr DIR
  26. # kill $server_pid
  27. shutdown
  28. if [ "$origin_server_pid" != "" ]
  29. then
  30. kill -9 $origin_server_pid
  31. fi
  32. }
  33. trap 'cleanup' 0 1 2 3 15
  34. if [ -z "$VALGRIND" ]
  35. then
  36. delay=0.2
  37. else
  38. delay=2
  39. fi
  40. rm -fr DIR
  41. $VALGRIND jscoverage-server --no-highlight --document-root=recursive --report-dir=DIR &
  42. server_pid=$!
  43. server_port=8080
  44. sleep $delay
  45. cat store.json | sed "s/@PREFIX@/\\//g" > TMP
  46. wget --post-file=TMP -q -O- http://127.0.0.1:8080/jscoverage-store > /dev/null
  47. cat store.expected.json | sed "s/@PREFIX@/\\//g" > TMP
  48. json_cmp TMP DIR/jscoverage.json
  49. cat store.json | sed "s/@PREFIX@/\\//g" > TMP
  50. wget --post-file=TMP -q -O- http://127.0.0.1:8080/jscoverage-store > /dev/null
  51. cat store.expected.json | sed "s/@PREFIX@/\\//g" | sed "s/,1/,2/g" > TMP
  52. json_cmp TMP DIR/jscoverage.json
  53. # try invalid method
  54. echo 405 > EXPECTED
  55. ! curl -f -w '%{http_code}\n' http://127.0.0.1:8080/jscoverage-store 2> /dev/null > ACTUAL
  56. diff EXPECTED ACTUAL
  57. # try with a path
  58. cat store.json | sed "s/@PREFIX@/\\//g" > TMP
  59. wget --post-file=TMP -q -O- http://127.0.0.1:8080/jscoverage-store/DIR > /dev/null
  60. cat store.expected.json | sed "s/@PREFIX@/\\//g" > TMP
  61. json_cmp TMP DIR/DIR/jscoverage.json
  62. shutdown
  63. cd recursive
  64. perl ../server.pl > /dev/null 2> /dev/null &
  65. origin_server_pid=$!
  66. cd ..
  67. rm -fr DIR
  68. $VALGRIND jscoverage-server --no-highlight --proxy --report-dir=DIR > OUT 2> ERR &
  69. server_pid=$!
  70. server_port=8080
  71. sleep $delay
  72. # test with proxy
  73. cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP
  74. wget --post-file=TMP -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/jscoverage-store > /dev/null
  75. cat store.expected.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP
  76. json_cmp TMP DIR/jscoverage.json
  77. cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP
  78. wget --post-file=TMP -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/jscoverage-store > /dev/null
  79. cat store.expected.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" | sed "s/,1/,2/g" > TMP
  80. json_cmp TMP DIR/jscoverage.json
  81. # test cached source
  82. rm -fr DIR
  83. cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP
  84. wget --post-file=TMP -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/jscoverage-store > /dev/null
  85. cat store.expected.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:8000\\//g" > TMP
  86. json_cmp TMP DIR/jscoverage.json
  87. shutdown
  88. rm -fr DIR
  89. $VALGRIND jscoverage-server --no-highlight --proxy --report-dir=DIR > OUT 2> ERR &
  90. server_pid=$!
  91. server_port=8080
  92. sleep $delay
  93. # store JSON with bad source URLs
  94. cat store.json | sed "s/@PREFIX@//g" > TMP
  95. wget --post-file=TMP -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/jscoverage-store > /dev/null
  96. json_cmp store-bad-source-urls.expected.json DIR/jscoverage.json
  97. sort ERR -o ERR
  98. diff --strip-trailing-cr store-bad-source-urls.expected.err ERR
  99. shutdown
  100. rm -fr DIR
  101. $VALGRIND jscoverage-server --no-highlight --proxy --report-dir=DIR > OUT 2> ERR &
  102. server_pid=$!
  103. server_port=8080
  104. sleep $delay
  105. # store JSON with unreachable source URLs
  106. cat store.json | sed "s/@PREFIX@/http:\\/\\/127.0.0.1:1\\//g" > TMP
  107. wget --post-file=TMP -q -O- -e 'http_proxy=http://127.0.0.1:8080/' http://127.0.0.1:8000/jscoverage-store > /dev/null
  108. json_cmp store-unreachable-source-urls.expected.json DIR/jscoverage.json
  109. sort ERR -o ERR
  110. diff --strip-trailing-cr store-unreachable-source-urls.expected.err ERR